Whenever I try to use a snippet (using snipMate) after a word, without a space, it does not work. So I have to hit space, type my snippet, hit tab, and then eliminate the space. Is there a better way of doing this? Is there a way to get the snipppets to work even immediately after a word? Here is what I mean:

let us say my snippet is this:

snippet test
        <some code>${1}</code>${2}

typical use:

hello test[TAB]

turns into this:

hello <some code>|</code>

but if I try this:

hellotest[TAB]

it turns into this:

hellotest_____

the _ being white space. Is there a way to fix this?

有帮助吗?

解决方案

Vim abbreviations can be of three types (full-id, end-id, and non-id, cp. :help abbreviations), which help solve this problem. snipMate, however, allows all non-whitespace characters for snippet names, and therefore has to rely on whitespace for separation.

You have to modify the parsing of the snippet name, in plugin/snipMate.vim, it's in the function TriggerSnippet():

let word = matchstr(getline('.'), '\S\+\%'.col('.').'c')

其他提示

There's no setting to that effect if that's what you ask. You will have to look at the source and do the change there yourself, I'm afraid.

Also, it can probably seen as a limitation but it's definetely not a bug so what you are after is an improvement, not a "fix". My advice, though, is to use it as it was designed: having triggers work even if they are part of another word makes no sense at all. Spaces are the most natural way of separating ideas and words.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top