# Tag Info

5

You have to use the i option. This is in the help page: i In-word expansion - By default a snippet is expanded only if the tab trigger is the first word on the line or is preceded by one or more whitespace characters. A snippet with this option is expanded regardless of the preceding character. In other words, the snippet can ...

5

Main Ideas There are 3 cases to consider (reworded slightly from the original question): a) If not in an itemize environment, create one, and place the cursor after the first \item. b) If in an itemize environment and if the list item is not empty, create a new \item. c) If in an itemize environment and if the list item is empty, delete the line and jump out ...

5

:UltiSnipsEdit will automatically open ultisnips for current filetype. From there you can see that it's supposed to be python.snippets.

3

The problem is that you have updated your plugins in the transition Linux to Mac. This also brings a major update of Vimtex, in which the syntax plugin has been included as part of Vimtex. Part of the syntax script changes are to simplify the math zones. The exact issue you raise is discussed here, and this comment should provide the required change, ...

2

Change the entire format to Google's... It's not documented, but the Python snippets file from vim-snippets does allow you to specify docstring style. Simply add let g:ultisnips_python_style = 'google' to your configuration, and the snippet will behave accordingly. When adding exception in a forward trigger, the docstring will add a "Raises" section (...

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

Put the check in a function so it’s not a mess: function react#add_snips() abort if search('styled-components', 'nw') != 0 UltiSnipsAddFiletypes css endif endfunction (This can go in ~/.vim/autoload/react.vim) And then call the function: augroup react autocmd! autocmd Filetype javascript,typescript call react#add_snips augroup END Alternatively,...

2

UltiSnips uses a strategy similar to how Vim detects :h ftplugins. That is, it will look for the filenames that match the following pattern in your UltiSnips directory: ft.snippets, ft_*.snippets, or ft/*, where ft is replaced with your Vim filetype (python, c, etc.) and * matches any string including the empty string. A table from :h UltiSnips-how-snippets-...

2

You need to use the vimrc file (~/.vimrc or ~/.vim/vimrc on MacOS, Linux/Unix) to configure most of initialization, in particular plug-ins. The gvimrc file is mostly reserved for additional settings that are only to be used to configure GUI-specific settings, such as which font to use in GUI versions of Vim such as MacVim. See :help initialization, which ...

2

The following snippet worked out for me: snippet pder(\w*) "Description" rw \\frac{\\partial^{!p snip.rv=findSum(match.group(1))}}{!p snip.rv=printd("\\partial",match.group(1))} $0 endsnippet with global !p def findSum(str1): # A temporary str1ing temp = 0 # holds sum of all numbers # present in the str1ing ... 2 I got it to work: global !p def mycontext(char): x = vim.current.window.buffer y = vim.current.window.cursor[0] z = vim.current.window.cursor[1] try: return x[y-1][z-1] + x[y-1][z] != char except: return True endglobal context "mycontext('()')" snippet ( &... 1 Yes, it's possible to use parts of the snippet trigger in the output, but it's not as simple as using a matching character class on each side. To correctly configure this, you need to use an r flag to use a regular expression in the trigger, use a capturing group inside parens for the character class (the trigger needs to be inside quotes as well.) And then ... 1 Simply extend the snippet to (\d)pder(\w*) and handle the second submatch appropriately. 1 Because of Jake Grossman's comment, I eventually realized the$ in the regex trigger should be escaped: (Also had to use python interpolation) snippet "\$(.+)\$" "whatever" r $$!p snip.rv = match.group(1)$$ $0 endsnippet The trigger right after snippet will match anything between$ and capture it in a group (with the ()) In the ...

1

What about writing your own mapping for TAB that analyses its context? if it detect ^\s*\\item\s*$on the current line, it clears the line then jumps over the end of the current itemize/enumerate/... environment otherwise it runs the default mapping. In lh-brackets, I have a function that may help to override existing mappings: lh#bracket#enrich_imap() &... 1 global !p def insert_before_unique(name): vim.command('/unique_text') snip.expand_anon(name + '\n\n\n') endglobal post_jump "if snip.tabstop == 0: insert_before_unique(snip.tabstops[1].current_text)" snippet trigger "tricky stuff"$1 endsnippet This seems to do the trick. Or close to it. If you type trigger and hit tab you'll be ...

1

The error you are getting is happening because your Vim doesn't include support for Python, which is required by UltiSnips, as that plug-in is implemented in Python for the most part. My recommendation is that you should get a Vim binary from your distribution. You mentioned using Linux Mint, so make sure you are not using a vim-tiny package, since that ...

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

This works for markdown files with the vimwiki filetype. The only change needed is the addition ["VimwikiMath", "VimwikiEqIn"] to texMathZones. texMathZones = ['texMathZone' + x for x in ['A', 'AS', 'B', 'BS', 'C', 'CS', 'D', 'DS', 'E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS', 'J', 'JS', 'K', 'KS', 'L', 'LS', 'DS', 'V', 'W', 'X', 'Y', 'Z', 'AmsA', '...

1

Like statox said, you should really write you own snippets. But I understand it is nice to have a set to look at, see what others are doing. One post I thought was really helpful was "How I'm able to take notes in mathematics lectures using LaTeX and Vim" From there, you can also find his github, with all his snippets. I find it a bit too complex, ...

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