Closed JJK96 closed 5 years ago
It's this line that is responsible for the alignment: https://github.com/occivink/kakoune-snippets/blob/master/snippets.kak#L154
You can change it to exec -itersel -draft '<a-s><a-;>1&'
and it will work for this case, but it might have undesirable consequences on other multi-line snippets, I need to think about it
Maybe introduce ${space}
placeholder, that will be much like ${indent}
? Though if #6 will be implemented, I believe that ${indent}
will not be needed anymore, and so will ${space}
I don't think snippet files will solve the indentation problem, we inherently need something dynamic so that you don't have to match your snippet definition with your preferred indentwidth
.
One thing that we could say is that instead of using ${indent}
, leading tabs are automatically converted to match indentwidth
. Thoughts on this?
Btw the undesirable consequence I was mentioning is for example your ability to do
set -add snippets 'For-loop' 'for' %{for (int $1 = 0; $1 < $2; ++$1) {
${indent}$3
}}
as that will be interested like that in the buffer:
for (int $1 = 0; $1 < $2; ++$1) {
${indent}$3
}
However, that particular problem should be solved by snippet files so I'm inclined to go with the change I mentioned earlier.
leading tabs are automatically converted to match indentwidth. Thoughts on this?
I think this is a nice solution, then the snippet more closely corresponds to the result upon expanding. One problem for me would be that I would need to insert a literal tab, currently my tabs are automatically converted to spaces. This wouldn't be a big problem however.
What if language determines that it should be indented with spaces? Should snippet definition contain tabs or spaces?
One problem for me would be that I would need to insert a literal tab
At the beginning of the line? I think that this is really rare case for snippets.
I don't think it is, If you have a snippet that inserts a block, then you usually want indentation. If we do this implementation:
leading tabs are automatically converted to match indentwidth
Then you would need a tab character at the beginning of the line.
I have the following snippets
I would like to have the whilespace before the
*
characters to persist into the snippets, currently it seems to be removed