Questions tagged [snippets]

Questions about the usage of snippets within Vim.

Filter by
Sorted by
Tagged with
1 vote
1 answer
17 views

Mapping snippet trigger in visual mode

I'm using the UltiSnips plugin. When selecting text, you can press the trigger key to enter Insert mode, and the deleted text can then be used in a subsequent snippet. The snippet I'm using is as ...
  • 13
4 votes
1 answer
138 views

Moving from Ultisnips to LuaSnip?

I recently decided to switch my init.vim to init.lua as I'm using Neovim and opted to use LuaSnip over UltiSnips - previously, CoC autocomplete and UltiSnips were clashing over the same tab triggers. ...
  • 71
2 votes
1 answer
49 views

UtliSnips - dynamically add placeholders along the way

I have a snippet defined as followed: data ${1:Type} = ${2:Constructor} | ${3:Constructor} I'd like to have new cases added along the way: data T = A " <Tab> | B " <Tab> ...
0 votes
1 answer
104 views

nvim: How do I insert a luasnip for BufNewFile "_skel"

I am using nvim-cmp and luasnips and I have a _skel snippet, I would like to create an autocmd to trigger this snippet for New Files: I already have some code: local status_ok, packer = pcall(require, ...
  • 1,047
1 vote
1 answer
48 views

VIM and UltiSnips delay with pound "#" key

Consider the following snippet context "math()" snippet "([a-zA-Z])#" "Vectors" riA \mathbf{`!p snip.rv=match.group(1)`} endsnippet The expected behaviour is that if I ...
1 vote
1 answer
65 views

Ultisnips not working with space

I have the following snippet context "math()" snippet `v([a-zA-Z]) ` "bb" A ``rv = '\\mathbf{' + m[1] + '}'`` endsnippet Now, most of my snippets work, however, snippets with ...
0 votes
1 answer
55 views

List of Acronyms / Abbreviations for a paper

What is the best way in Vim to handle abbreviations for a paper? For example: When working with Artificial Intelligence (AI) there must be .... and furthermore AI enables you to.... And later in the ...
  • 103
1 vote
1 answer
48 views

How to share snippet between typescript and typescriptreact?

I use UltiSnips to manage my snippets and I have a few snippets in typescriptreact but I'm not able to use them in typescript. Is there a way to share snippets between them?
  • 183
0 votes
0 answers
34 views

Finding a way to remove right brackets of the lsp completion

Is there any way to remove the > in .h>? As the gif above, it duplicates the one in the #include <> snippet. Both completion seems to be provided by the lsp. environment Neovim v0.6.1 ddc....
  • 1
0 votes
1 answer
152 views

How can use Tab to navigate completion list

I use both coc.nvim and Ultisnip for completion in vim. coc-snippet does not support some feature in Ultisnip so I use Ultisnip instead But I have a problem is <Tab> for trigger completion in ...
0 votes
1 answer
65 views

How can I set up some personal snippets for shebang lines or python exception handlers?

I want to to add some functions to my vimrc and want to achieve, e.g., I type :bang and it adds a shebang into the file I type class foo:<ENTER> it automatically adds except KeyboardInterrupt: ...
0 votes
0 answers
27 views

snippets visual is not selected when there is overfull warning

Disclmair: this is a question about using vim to write LaTeX. I don't know if this behaviour is visible in other languages also. I use Ultisnips with honza/vim-snippets to expand latex snippets. If ...
  • 437
2 votes
1 answer
219 views

Ultisnips: autocompletion of (). Make snippet not expand again

I want to make a Ultisnips snippet for auto completion of (), "", {}, etc. I have Tab as my expand and jump forward key. My snippet is: snippet ( "parenthesis" iA (${1:${VISUAL}})$...
  • 21
4 votes
1 answer
70 views

Snippets only working when preceeded by space

I have created my snippets in texmath.snippets as: priority -50 snippet \d "dot" Aw \dot{$1} endsnippet snippet ^^ "superscript" A ^{$1} endsnippet snippet __ "subscript&...
  • 437
1 vote
1 answer
58 views

Ultisnips capital and lower character in same snippet

I am trying to expand my snippets. I use Ultisnips. ofcourse, I can have snippet 'a "greek alpha" A \alpha endsnippet and snippet 'A "greek alpha" A \Alpha endsnippet and both ...
  • 437
0 votes
0 answers
88 views

Is there any snippet generator available for vim?

In vscode/atom/sublime there is a snippet generator. https://snippet-generator.app/ Likewise any snippet generator or plugin to generate present in vim? Can I store snippet in my project github and ...
5 votes
2 answers
521 views

Where do I define UtliSnips snippets for Python?

I am using UltiSnips for my snippets. I have only used LaTeX snippets with UltiSnips, which I defined in a tex.snippets file inside of an UltiSnips directory in my runtimepath. Now, I would like to ...
  • 119
4 votes
3 answers
2k views

create own snippets

I'm rather new to vim. And I don't like much to install many packages. I use html, javascript and react.js, and i would like to create some simple way to type and then have the correct snippet on the ...
1 vote
1 answer
239 views

UltiSnips: Can I add text outside snippet boundaries? (e.g. Near a search result)

Is there any way that UltiSnips can be made to seek for a text in document and execute some snippet at the position of text? Explanation of Intent :- Say I have the following text file abcde klsdfl | ...
  • 235
0 votes
1 answer
286 views

Vim snippets with arguments

I'm trying to create snippets without using any plugins. For instance, nnoremap ,eq :-1read $HOME/.vim/snips/.eq.tex<CR>o<TAB> inserts the contents of .eq.tex: \begin{equation} \end{...
  • 121
0 votes
1 answer
145 views

how much effort would be required to use Bitbucket Snippets with any of the popular snippet plugins?

I am brand new to the realm of snippets in vi[m] and have been doing a little reading here, on Fandom, and the repos on github. I notice that vim-snippets has been mentioned a few times in terms of ...
  • 163
1 vote
1 answer
611 views

Unmap <c-n> / <c-p> in completion menu to use as previous / next snippet placeholder with Coc

My completion mappings scheme with coc is the following: <c-@> (ctrl-space): trigger the menu / use the selected item (or the first one) <c-j> and <c-k>: navigate the list (or also ...
  • 2,580
1 vote
0 answers
292 views

Provide arbitrary arguments to a snippet in UltiSnips

There are numerous occasions where you might want to have another optional argument in your snippet. Lets say I want to have a numbered list for example. Preferably I'd call something like enum3 which ...
  • 11
1 vote
1 answer
953 views

How to insert a snippet with Ultisnips

I am using the setup I found in this answer: https://stackoverflow.com/a/22253548/2241241 namely " if you use Vundle, load plugins: Bundle 'ervandew/supertab' Bundle 'Valloric/YouCompleteMe' Bundle '...
  • 479
4 votes
3 answers
644 views

Is it possible to create a snippet to "expand" struct members to fill?

In the type of c programming that I do day to day, I often have to "fill" struct members in order to pass them to an API. For example: struct measurement { double start_time; double end_time; double ...
  • 299
2 votes
2 answers
605 views

How to change the docstring format of the snippets by Ultisnips?

Using the snippets plugin I'm able to get: class MyClasnippets(object): """Docstring for MyClasnippets. """ def __init__(self): """TODO: to be defined. """ from just typing class. ...
0 votes
1 answer
178 views

Ultisnips Sinppets in current scope on blank line

Background I'm using UltiSnips in conjunction with some autocomplete plugins. I have this line controlling the behavior of enter inoremap <expr> <cr> \ !empty(UltiSnips#...
1 vote
1 answer
538 views

localleader is not obeyed

for my fortran code, I have defined: au FileType fortran let maplocalleader = "`" # i have tried \` as well. For fortran filetype in vim, :echo maplocalleader is showing ` as expected. But, then,...
  • 437
1 vote
1 answer
277 views

How to capture the name of a function on ultisnips plugin?

I have created a guard snippet (ultisnips) in order to add on my existing functions: snippet guard "add guard to functions" b if !exists('*${1:func_name}') ${VISUAL} endif ${0:jump here <C-j>...
  • 1,047
2 votes
1 answer
82 views

Reuse value in snippet

I recently switched to using neovim + deoplete + neosnippets and I'm trying to get a snippet to do a thing that I'm pretty sure that I've been able to do in UltiSnips. In a template I'd like to be ...
  • 141
0 votes
1 answer
138 views

inoremap inserts unwanted tabs

I recently made myself custom insert mode keybindings to type faster in LaTeX. However, When I use them, Vim adds tabs that weren't part of the original keybinding. Example: Here is my inoremap: ...
-1 votes
1 answer
294 views

Insert C/C++ loops and statements templates automatically [closed]

How do I insert C/C++-type loops and statements templates automatically in Vim?
  • 916
5 votes
2 answers
1k views

Easiest way to insert LaTeX matrix?

Recently I found myself in a situation that need to type in quite a number of matrices to LaTeX by hand, so I was wondering if there are some tools that can help me to save some keystrokes. The ...
2 votes
1 answer
595 views

Trigger reindentation after snippet has expanded to word in 'indentkeys'

The ftplugin vimtex provides the file indent/tex.vim with following line setlocal indentkeys+=[,(,{,),},],\&,=item,=else,=fi 'indentkeys' 'indk' string (default "0{,0},:,0#,!^F,o,O,e") ...
  • 4,080
3 votes
0 answers
108 views

Disable a specific set of snippets in SnipMate

Is it possible to tell SnipMate to ignore a specific set of snippets? Let's take vim-snippets/snippets/javascript/javascript-jquery.snippets as an example. When editing a JavaScript file, all snippet ...
1 vote
1 answer
29 views

Fields in templates without resorting to commented-out lists (aka are drop-down options possible?)

I do a lot of work in plain TeX and XeTeX, editing the documents in vim, and have a variety of templates which I use to make the process more efficient. As you might expect, these use quite a lot of ...
  • 13
2 votes
0 answers
259 views

Comprehesive support for graphviz (linting/autocompletion/snippets)

Vim comes with some support (syntax highlighting) out of the box for the DOT language (graphviz) In addition, I found the plugin: https://github.com/wannesm/wmgraphviz.vim, which provides integrated ...
2 votes
1 answer
496 views

Skip over closing html tag?

Plugins such as snipMate, emmet and many others allow me to quickly insert opening and closing html tags. For example by typing span and hitting the correct key (TAB for snipMate, <C-y>, for ...
3 votes
1 answer
1k views

Execute normal is inserting "<tab>" instead of hitting tab key

I am trying to make a function that creates a new line and hits the tab key (aka 2 spaces / 4 spaces; what ever is set). I can do it easily with a keybinding: :inoremap <leader>ind <esc>...
1 vote
1 answer
301 views

<Plug> was printed to the buffer instead of execute

I am using neovim with deoplete.nvim and neosnippet.vim. I am trying to make TAB key do both navigating through the popup menu and expand snippets when it's able to. Here is my config. " <TAB>: ...
0 votes
1 answer
567 views

Expanding snippet in line using neosnippet

I'm using neosnippet to define and expand my snippets. I have the following snippet defined for javascript development snippet fn abbr () => {} (${1}) => {${2}} I can insert this snippet ...
  • 103
3 votes
1 answer
2k views

auto insert text when creating a new file [duplicate]

Is there a way to auto insert text in vim when a new file is created? Maybe there is a plugin for it? Here is what I'm talking about: I work a lot with C/C++ and Python. Very often I need to create ....
  • 669
0 votes
1 answer
137 views

Header from Templates not appearing in newly created C source files

First, I did: % vim ~/.vim/cvim/c-support/templates/Templates From there, I changed my User Macros to their desired values. I then saved my changes. In Vim, I went to Normal Mode and entered: :!...
0 votes
1 answer
139 views

Neosnippet expands to "options head"

I am creating my firsts neosnippet-snippets in c.snip, it looks like that: snippet head options head //////////////////////////////////////////////////////////////////////////////// // ${1:...
45 votes
4 answers
29k views

What is the difference between the vim snippets plugins?

There is a great number of snippets plugins for vim: ultisnips, snipmate, xptemplate, neosnippet and a lot more. They all have pros and cons and more or less dependencies. So far I've been using ...
  • 46.8k
3 votes
1 answer
169 views

Good method for saving and inserting commonly used snippets

I often need to insert the same text into a file. My approach has been to put the text into my vimrc as a variable: let map='<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">' And ...