Skip to main content

Questions tagged [snippets]

Questions about the usage of snippets within Vim.

Filter by
Sorted by
Tagged with
2 votes
1 answer
1k views

How to insert a snippet with UltiSnips?

I am using the setup I found in this answer: UltiSnips and YouCompleteMe namely: " if you use Vundle, load plugins: Bundle 'ervandew/supertab' Bundle 'Valloric/YouCompleteMe' Bundle 'SirVer/...
0 votes
0 answers
37 views

LuaSnip VScode snippets for Apex not showing

In Neovim I tried adding my own VSCode style snippets for Apex programming language to LuaSnip and I can't get it to work. This is my packer.lua file: vim.cmd [[packadd packer.nvim]] return require('...
0 votes
1 answer
899 views

How to add custom snippets for neovim to a particular location when using friendly-snippets

I have friendly-snippets(https://github.com/rafamadriz/friendly-snippets), which works. The (python) snippets that it uses are installed at $HOME/.local/share/nvim/site/pack/packer/start/friendly-...
1 vote
1 answer
99 views

nvim `select mode` uses wrong keymap for the "first" character

title: "The wrong keymap is used for the first typed character" summary: When entering a snippet my nvim seems to assume the keymap for the fist "typed" character is qwerty, and ...
0 votes
0 answers
26 views

How can write snippet with arguments to extent?

I have write an small snippet for html-table to extend when editing rst file: vim .vim/bundle/vim-snippets/UltiSnips/rst.snippets snippet html-table "put html" i .. raw:: html <...
1 vote
1 answer
76 views

Migrating from Latex-Suite to vimtex

So I've been using latex-suite for a few years, and I realised recently that vimtex has some nice features (especially the text objects). So I'm tempted to use that instead, but it would require me to ...
2 votes
1 answer
1k views

Insert Doxygen comments automatically

I use nvim with coc and clangd as the language server on a ubuntu 22.04 machine. I mainly use it to code in c++ when I code. What I want is to automatically generate doxygen style comments to describe ...
0 votes
2 answers
418 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 votes
1 answer
51 views

How can make the expansion to take effect in any type of file?

If I add the following lines in html.snippets: snippet "(\S+)(\d+)" "Repeat token n times" r `!p snip.rv = int(match.group(2)) * match.group(1)` endsnippet #5 can expand to #####. ...
0 votes
1 answer
228 views

Attempt to index local tmp error for dynamic node (LuaSnip)

I am trying to create a snippet that changes based on the optional lua pattern input, but I am getting an error about a local tmp for the dynamic node. The desired outcome for typing $cup$ is $\cup$ ...
-1 votes
1 answer
393 views

vimtex#syntax#in_mathzone with tree-sitter and texlab

Vimtex provides the very useful family of functions vimtex#syntax#in_mathzone(), vimtex#syntax#in_comment() and vimtex#env#is_inside('...'), which come in handy for context sensitive snippets, e.g. ...
0 votes
1 answer
99 views

Detecting conflicting snippet trigger keyboard shortcut

Is there a way to detect incompatible snippet triggers? Say: snippet st "superscript" iA <---snippet body---> endsnippet vs snippet bst "binary spanning tree data" iA <---...
5 votes
2 answers
2k 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 ...
0 votes
1 answer
3k views

How to set up LuaSnip in NeoVim w/LSP-Zero?

I'm trying to enable snippets in my auto-completion but they are only working for lua files and nothing else. I ve been messing around with nvim-cmp and luasnip itself and even downloaded friendly ...
3 votes
1 answer
172 views

What is the meaning of [LS] and other symbols in Vim completion menu?

I installed coc.nvim, vim-snippets and ultisnips for my snippets in my Vim (gVim on Windows). I don't know the meaning of [LS] , [B] , m, S and [S] in this picture. This picture shows part of my ...
1 vote
1 answer
513 views

How can I see a list of snippets in my Vim?

I installed vim-snippets, ultisnips and coc.nvim in my Vim (gVim on Windows). How can I see a list of snippets that I can use in my current open file? For example, when I'm editing a .js file, I want ...
0 votes
1 answer
103 views

How can I open MDN link in coc.css popup?

Sorry for my English. I installed coc-nvim plugin in my vim (gvim in windows) after that I insert CocInstall coc-css command for css snippets. In this picture I highlighted MDN Reference. How can I ...
3 votes
1 answer
423 views

What does ${VISUAL} do in snippets?

What is the difference between them? With ${VISUAL} : snippet if "if ... then (if)" b if [[ ${1:condition} ]]; then ${0:${VISUAL}} fi endsnippet Without ${VISUAL} : snippet if "if ....
1 vote
1 answer
114 views

Ultisnips dynamic tabstop generation with custom justified option

It seems possible to have ultisnips produce a dynamically sized array as specified here: https://github.com/SirVer/ultisnips/blob/master/doc/examples/tabstop-generation/README.md The array environment ...
1 vote
1 answer
39 views

How can make the trigger_word as argument to python?

The syntax of UltiSnips's snippet is as below: snippet trigger_word [ "description" [ options ] ] The upper method can convert all characters in the string into upper case: "string&...
0 votes
1 answer
106 views

How can call python in snippet?

I want to expand ptest into welcome python in file ending with html. Add these lines in html.snippets(located in vim-snippets/UltiSnips): snippet ptest !p print("welcome python") endsnippet ...
6 votes
1 answer
2k views

Triggering UltiSnips with enter

Is there any possible way to do expand trigger in UltiSnips with enter? I've tried <Enter>, <Return>, and <CR>. It works to trigger but doesn't work for new line. And I've tried to &...
1 vote
0 answers
106 views

Why can't I jump backforward when pressing Shift+Tab key in Ultisnips?

I have added the line in .vimrc: let g:UltiSnipsJumpBackwardTrigger="<s-tab>" Edit a test.py, type ifee and Tab to expand it; upon pressing Tab, the cursor jumps into next region. Why ...
1 vote
1 answer
142 views

Which python.snippets file will be called?

There are two python.snippets in vim-snippets folder: debian@debian:~/.vim/bundle$ ls vim-snippets/snippets | grep python python.snippets debian@debian:~/.vim/bundle$ ls vim-snippets/UltiSnips | ...
1 vote
1 answer
123 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: ...
2 votes
0 answers
58 views

Parse files, hidden from the user

I am working on a snippet for C/C++ that can generate switch statements with cases from the types that an enum can have. So far I have some code that can get the type location from the language server....
1 vote
1 answer
92 views

Smart way to type latex `\SI{..}{..}` macro in vim (snipped/autocompletion)

A physics high school student of mine is typesetting latex documents using vim. I noticed however that he doesn't use the siunitx package which typesets units properly. However the syntax for example \...
1 vote
1 answer
227 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 ...
3 votes
1 answer
417 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}})$...
5 votes
1 answer
1k 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. ...
2 votes
1 answer
91 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> ...
1 vote
1 answer
155 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?
1 vote
1 answer
84 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
200 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 ...
50 votes
4 answers
32k 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 ...
0 votes
1 answer
78 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 ...
0 votes
1 answer
394 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 ...
1 vote
1 answer
99 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 ...
0 votes
0 answers
28 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 ...
4 votes
1 answer
246 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&...
1 vote
1 answer
994 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 ...
0 votes
0 answers
247 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
750 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 ...
2 votes
2 answers
770 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. ...
4 votes
3 answers
3k 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
346 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 | ...
4 votes
3 answers
790 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 ...
0 votes
1 answer
403 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{...
0 votes
1 answer
212 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 ...
1 vote
0 answers
388 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 ...