# Tag Info

29

I've been using ultisnips for several weeks now. I think the main advantages of this plugin are the following: It is pretty fast even with a great number of snippets available. The basic syntax to define a new snippet is easy to understand, thus it is easy to quickly create a new snippet doing what you want to do. (For more complex snippets some additional ...

20

I've been using the original SnipMate since I started using Vim. It doesn't have external dependencies. It uses a very simple syntax. It is very easy to set up. It has been abandoned since 2009. I have nothing to complain about.

10

Here is a list of features from mu-template. Discl.: I'm its maintainer. Template-files can be expanded: automatically when opening a new buffer (unless deactivated from the .vimrc), explicitly through menus or the command line, from the INSERT-mode in a snippet-like fashion ; from the VISUAL-mode to surround the selection with a snippet -- the surrounding ...

10

SnipMate and UltiSnips are the two most popular snippet engine for Vim. Both are inspired from TextMate's snippet syntax. UltiSnips can run all SnipMate snippets but also have additional syntax to make it more powerful. A good rule of thumb is that if your Vim has python support, then use UltiSnips. If not, then use SnipMate. UltiSnips dropped support for ...

8

Currently there is no way to do this in UltiSnips. There is an open feature-request on Github for it though. Personally, I would like an alias functionality for triggers as indicated here too. Let's hope SirVer (the maintainer of UltiSnips) will think so too and include it in the future :)

7

I think you can get the same result as in the video with this code: ${1/(".*)|.*/(?1:comment => )/}${1:"some comment"}${1/(".*)|.*/(?1:, )/} It can be broken down into 3 parts: ┌ mirror of tabstop n°1 │ ┌ substitution ┌─┤┌─────────────────────────┤ (A)${1/(".*)|.*/(?1:comment => )/} ┌ tabstop n° 1 ...

5

Although there is no specific syntax for aliases you can achieve the same effect by using post_jump: # c.snippets global !p def expand(snip): if snip.tabstop != 1: return vim.eval('feedkeys("\<C-R>=UltiSnips#ExpandSnippet()\<CR>")') endglobal snippet incstdlib "#include <stdlib.h>" !b #include <stdlib.h> /* exit(), ...

5

The codes which keys produce varies wildly by terminal. vim tries to guess which escape sequences corresponds to which keycodes (<f1> etc) based on the $TERM variable and terminfo. The shifted f-keys are not standardized and they do not have termcap/terminfo entries. In this case, vim falls back to the xterm ones. Note, wherever ^[ is written, this ... 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. 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 ... 4 If your template expander plugin doesn't support snippets local to the current buffer, i.e. if b:UltiSnipsSnippetDirectories is not understood in your case, you can ask the maintainers to use this variable if defined, or the global one otherwise -- this is the best course of action or you can use another snippet engine that supports local snippets or you ... 4 It's difficult to point out where your problem is, since you didn't really describe what exactly you did; but this is how I added a custom PHP snippet file: I installed http://github.com/SirVer/ultisnips and http://github.com/honza/vim-snippets I created ~/.vim/UltiSnips/php.snippets with the contents: extends php, html snippet 42 The universe, life, and ... 4 From :help UltiSnips-adding-snippets (section 4.1): UltiSnips iterates over the snippet definition directories looking for files with names of the following patterns: ft.snippets, ft_*.snippets, or ft/*, where "ft" is the 'filetype' of the current document and "*" is a shell-like wildcard matching any string including the empty string. The ... 4 You can manually fix the indent by typing CTRL-F (this is documented at :help indentkeys-format). Thus, an autonomous solution would be to issue this key-press after snippet expansion. global !p def fix_indent(snip): vim.eval('feedkeys("\<c-f>")') endglobal post_expand "fix_indent(snip)" snippet it "Individual item" b \item$0 endsnippet

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#...

3

The problem comes from the fact that your Vim setup supports python, but python is not installed on your system. When Vim has the 'python' and/or 'python3' features enabled that means that it provides an interface to interact with python code: you can make Vim to ask the system to execute a python statement or a whole python code. Even if the interface is ...

3

First of all :h UltiSnips-snippet-search-path tells us: Snippet definition files are stored in snippet directories. A snippet directory must be a subdirectory of a directory defined in the 'runtimepath' option. Which makes me think that you can not create snippets directories anywhere since that would mean constantly add your current path to ...

3

Apparently Ultisnips only does this for tab as early adopters of the plugin complained that it broke supertab. It's worth asking the maintainer whether he'd be willing to fix this for <CR> too. That being said, there is a workaround that's described in the docs: let g:ulti_expand_or_jump_res = 0 "default value, just set once function! ...

3

You want to use UltiSnipsAddFiletypes. As the docs say: The UltiSnipsAddFiletypes command allows for explicit merging of other snippet filetypes for the current buffer. For example, if you edit a .rst file but also want the Lua snippets to be available you can issue the command > :UltiSnipsAddFiletypes rst.lua To automatically set the filetype ...

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

UltiSnips has the extends keyword. You pass a comma separated list of filetypes to it and it will load the snippets for those filetypes before the snippets in the file the keyword is used in. Example: extends c, obj-c This way you can have a "cpp.snippets" file which "extends" your c filetype and obj-c type. The documentation doesn't mention cyclic ...

2

Unfortunately <c-i> and <tab> are parsed as the exact same key by most terminals. You can follow a discussion about this on this neovim issue: https://github.com/neovim/neovim/issues/176 The easiest solution is to pick a different mapping for jumping backwards, like <leader>i. If you really want this fixed, I suggest following the linked ...

2

I don't think you have to do that for Pathogen + UltiSnips + vim-snippets. I have such setup and only thing in my vimrc is let g:UltiSnipsExpandTrigger="<c-j>". Both plugins are in ~/.vim/bundle.

2

From documentation on :nnoremap: :no[remap]! {lhs} {rhs} […] Disallow mapping of {rhs}, to avoid nested and recursive mappings. But the whole point of your mapping is to use recursive mapping of Tab! Use :nmap instead. Alternatively, and even preferably, use the following: nnoremap KEYCOMBO iULTISNIPTRIGGER <esc>:call UltiSnips#ExpandSnippet(...

2

Neocomplete is an alternative that may have different snippets and is compatible with the UltiSnips repository. Other than that if you can't find what you are looking for, you might have to create your own as statox stated.

2

This is because of this line in UtliSnips documentation: UltiSnips comes without snippets. The default snippets can be found here: https://github.com/honza/vim-snippets UltiSnips is just an engine, you need to install/create own snippets. I use those recommended vim-snippets and they work like a charm.

2

g:UltiSnipsSnippetDirectories are used to search snippets, it's default to ['UltiSnips'], there are 2 kinds of settings: relative path let g:UltiSnipsSnippetDirectories = ['UltiSnips','foo'] UltiSips will loop each path in runtimepath to search for child directory named UltiSnips and foo, and use them as snippets source. Note that "snippets" is reserved ...

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

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 (...

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