Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
22

I've been using ultisnips for several weeks now: I think the main advantages of this plugins 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 create quickly a new snippet doing what you want to do. (For more complex snippets some ...


12

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.


7

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


6

Honza's UltiSnips Snippet gentbl<number>x<number> available in the repository https://github.com/honza/vim-snippets/blob/master/UltiSnips/tex.snippets Using this snippet which uses the python interpolation feature of UltiSnips, you can enter e.g. gentbl5x3<tab> which will expand to \begin{tabular}{||||} & & \\ & &...


4

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. In my .vimrc, I load (using ...


4

I came across a solution that suits me well, it may be useful for you also. I add some mappings/abbreviations in insert mode starting with \ (or any character you like, and use not all the time): " use an abbreviation (css debugging) iabbrev \r *{color: red !important;} " use a mapping (html doctype insertion) inoremap \doctype <!DOCTYPE map PUBLIC "-//...


4

You could probably implement this as a snippet by leveraging Ultisnips's Interpolation feature (VimCasts demo). As an alternative, I whipped up a simplistic function to generate a matrix template on the current line per your sample: function! CreateMatrix(rows, ...) abort let cols = a:0 ? a:1 : 3 let matrix = ['\begin{bmatrix}'] call extend(matrix, ...


3

When you register it this way, your new autocommand will be triggered after all other autocommands registered on the same event, in particular after the one that sources your ftplugin -- I suppose you define the mapping in an ftplugin (*). You could change that, probably by changing the order between this line and the :filetype xxxx in your .vimrc, but this ...


3

The inoremap <expr><TAB> ... also has a <Plug>-mapping on the right-hand side of the mapping. These mappings only get expanded when you use :imap. So, though you should normally use :noremap, this is one exceptional case where you need to allow recursive mappings.


3

As multiple people have said in various comments, check out :h skeleton. This sounds like just what your looking for. However if you want a little more customizability you can try the following... Detecting when a file is "created" might be hard, since vim creates files by writing buffers to files. But you can detect when you write to a file with the ...


2

All you need to do is to insert a \ before the <tab> Now the code will look like this instead: execute "normal! o\<tab>"


2

Discl. I'm maintaining an alternative to c.vim. As such, I don't use it and I don't know its intricacies. If you've installed c.vim into ~/.vim/cvim and if by % vim ~/.vim/cvim/c-support/templates/Templates you are editing the original files shipped with the plugin, it's probably a bad idea. Indeed, next time you'll update the plugin, you'll lose all your ...


2

It's because you indent the snippet options ('keywords'), by not following the help example (:h neosnippet-snippet-syntax). So, you need: snippet stdlib options head alias std #include<stdlib.h>${0} BTW, I'm not sure if ${0} is needed at all, in this example.


2

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


1

Try this: snippet guard "add guard to functions" b if !exists('*`!p snip.rv = re.search('\S+\s+(\S+)\(', snip.v.text.splitlines()[0]).group(1)`') ${VISUAL} endif ${0:jump here <C-j>} endsnippet The `!p snip.rv = ...` part is a python interpolation. The evaluation of the expression to the right of the assignment operator after snip.rv replaces ...


1

The answer is synchronized placeholders; I just couldn't find anything online/in the manual because I didn't know the terminology. The correct snippet would be: snippet thing abbr thing #ifndef THING_${1:something}_H #define THING_$1_H #include <something.h> BEGIN_DECLS // ... END_DECLS #endif /* THING_$1_H */ For ...


1

There exist many ways to define snippets for control statements: via abbreviations or via snippets. I remember a Q/A about abbreviations versus snippet plugins. TL;DR: We can achieve the same things with both. The main difference is that snippet plugins provide a much simpler way to define maintainable code snippets. For instance, in my lh-cpp plugin you ...


1

This answer was actually provided by the author himself. In his own words: It seems like a common enough problem that someone should have addressed it. But apparently, not yet. It is necessary to map a solution, and here are a some of the possibilities: inoremap <C-f> <esc>f>a inoremap - create a map that works in insert mode <C-f> ...


1

This should work: snippet fn option word abbr () => {} (${1}) => {${2}} You can find the necessary information if you read :h neosnippet-snippet-syntax, in particular the help under the snippet keyword option: - options [options] (Optional) Options influence the snippet behavior. The possible values are: + word This snippet expands by ...


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