4

Use remap to trigger expansion imap "prg prg<c-a> or exe printf('imap "prg prg%s', g:UltiSnipsExpandTrigger) But not this: imap <expr> "prg 'prg' . g:UltiSnipsExpandTrigger g:UltiSnipsExpandTrigger is a variable, map won't figure out special key code of it's value for you. Manual expansion inoremap "prg prg<c-r>=UltiSnips#...


2

I use <esc>A, it's 2.5 key strokes(0.5 for shift), it's not the shortest solution, but it's the most natural one if you are used to move around in normal mode. IMO, <esc> doesn't count as a keystroke. <c-o>A works too, but I don't like it, I can't remember the last time i use :h i_CTRL-O . You can also create a map for this: inoremap <...


2

I add my comment as answer with the complete snippet file. Negative Lookbehind Assertion in Python Regular Expressions Python documentation: https://docs.python.org/3/library/re.html#index-23 (?<!...) Important limitation: Similar to positive lookbehind assertions, the contained pattern must only match strings of some fixed length. Patterns which ...


2

It seems that when you copied the snippet you forgot to add the indentation spaces in the python snippet conditional code as shown in the error message: Executed snippet code: 1 2 if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']: 3 snip.rv = ' ' 4 else: 5 snip.rv = '' 6 Try to change it to: snippet im "create an inline ...


2

From this video: UltiSnips evaluates each text object that might have a dependency on some types of text multiple times, to make sure that all dependencies are properly updated. To prevent the date from being updated several times, you could switch to a python interpolation, and use the guard if not snip.c. For example, you could replace this: ** ...


2

Thanks to husB for point me the dynamic tabstop generation, i don't know why it isn't in the doc. The final snippet: global !p def create_line_plhldr(snip): num = int(snip.buffer[snip.line].strip()) snip.buffer[snip.line] = '' anon_snippet_body = '${1:unidad}.${2:ejercicio} )' for var in range(2, int(num)+1): anon_snippet_body +=...


2

I do not know whether you have found a solution in the mean time, but according to this post https://stackoverflow.com/questions/606191/convert-bytes-to-a-string you have to decode the bytes object, so that the snippet becomes: snippet 'math(.*)math' "math" wr `!p import subprocess code = match.group(1) code = 'ToString[' + code + ',TeXForm]' res = ...


1

You should only set a default value on the first occurrence of the placeholder, that way it works. From :help UltiSnips-mirrors: [...] A mirrored tabstop can have a default value defined. Only the first instance of the tabstop need have a default value. Mirrored tabstop will take on the default value automatically. While the help says "need", it only ...


1

Nevermind, I figured out how to implement it as a custom context snippet: snippet { "braces" "snip.column == len(snip.buffer[snip.line]) - 1" e { $0 } endsnippet


1

The syntax to use a Vimscript expression in UltiSnips is `!v ...`, so I think what you're looking for is: snippet fakeint `!v fake#int()` endsnippet See :help UltiSnips-vimscript for all the details. Note that you don't necessarily need to use a snippet manager to use the vim-fake functions, in Insert mode you could simply use CTRL-R = to insert the ...


1

Those snippets mentioned in the question have the auto-expand option enabled, as there is an 'A' included in the options of each snippet (eg. bA, wA). To disable auto-expansion of a snippet, remove the 'A'. For example, snippet mk "Math" w $${1}$`!p if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']: snip.rv = ' ' else: snip.rv = '' `$2 endsnippet ...


1

Set nocompatible When you use a separate vimrc through the -u command-line flag, the nocompatible option will not be automatically set, as it is when using the normal user vimrc file. See :help compatible-default for more details. You should either add set nocompatible to the top of your alternative vimrc file, or pass Vim the -N command-line option in ...


1

UltiSnips#SnippetsInCurrentScope return all snippets whose trigger matches the current word, I think the match here means =~, not ==. You need to check word before cursor and the triggers by yourself: function! s:is_ultisnips_expandable() " get word before cursor let word = matchstr(getline('.'), printf('\v\w*%%%dc\w', col('.') - 1)) if(empty(word)) ...


Only top voted, non community-wiki answers of a minimum length are eligible