dozius/keypirinha-snippets

Improve multiline support

Opened this issue · 1 comments

at-ng commented

The way multi line works for snippets currently it seems initial white space is ignored. This can be a problem because sometimes you want to start a line with some indentation. One way to solve this would be to change this line from

data[path][snippet_key] = snippet_string

to just something like

data[path][snippet_key] = snippet_string.replace('|||', '')

Then you could start each line where you want to maintain indentation with " |||". Another option would be to do this

data[path][snippet_key] = snippet_string.replace('\\n', '\n')

Then you can maintain the indentation by doing everything on the same line, a bit more annoying to work with though but sometimes it might be better so maybe both could be supported.

I think the most intuitive way to handle this would be to use surrounding quotes where leading and/or trailing white space needs to be preserved. I'd gladly accept a pull request that implements general use handling of quote enclosed strings.