Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [snippets]

Questions about the usage of snippets within Vim.

Filter by
Sorted by
Tagged with
1 vote
1 answer
81 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 ...
molleweide's user avatar
0 votes
0 answers
25 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 <...
showkey's user avatar
  • 1,140
1 vote
1 answer
70 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 ...
Ronak M Soni's user avatar
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 ...
FalcoGer's user avatar
  • 149
0 votes
1 answer
203 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$ ...
TrustinN's user avatar
-1 votes
1 answer
360 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. ...
Gargantuar's user avatar
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 ...
Marcello Fitton's user avatar
3 votes
1 answer
166 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 ...
mohamadi_arch's user avatar
1 vote
1 answer
477 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 ...
mohamadi_arch's user avatar
0 votes
1 answer
98 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 ...
mohamadi_arch's user avatar
0 votes
1 answer
801 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-...
baxx's user avatar
  • 1,025
-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 #####. ...
newview's user avatar
  • 301
1 vote
1 answer
38 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&...
newview's user avatar
  • 301
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 ...
newview's user avatar
  • 301
0 votes
1 answer
96 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 <---...
Tryer's user avatar
  • 247
1 vote
0 answers
102 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 ...
newview's user avatar
  • 301
3 votes
1 answer
407 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 ....
newview's user avatar
  • 301
1 vote
1 answer
137 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 | ...
newview's user avatar
  • 301
2 votes
0 answers
56 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....
c60cb859's user avatar
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 \...
dp21's user avatar
  • 13
1 vote
1 answer
112 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 ...
Tryer's user avatar
  • 247
1 vote
1 answer
221 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 ...
Alex867's user avatar
  • 33
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. ...
Revise's user avatar
  • 221
2 votes
1 answer
87 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> ...
GlinesMome's user avatar
0 votes
2 answers
411 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, ...
SergioAraujo's user avatar
  • 1,175
1 vote
1 answer
82 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 ...
Maths Wizzard's user avatar
1 vote
1 answer
197 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 ...
Maths Wizzard's user avatar
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 ...
Diesel's user avatar
  • 103
1 vote
1 answer
151 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?
Lai32290's user avatar
  • 275
0 votes
1 answer
389 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 ...
Pham Hung's user avatar
  • 153
1 vote
1 answer
119 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: ...
somboku's user avatar
  • 11
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 ...
BaRud's user avatar
  • 491
3 votes
1 answer
413 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}})$...
jfab's user avatar
  • 31
4 votes
1 answer
238 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&...
BaRud's user avatar
  • 491
1 vote
1 answer
97 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 ...
BaRud's user avatar
  • 491
0 votes
0 answers
242 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 ...
Samselvaprabu's user avatar
5 votes
2 answers
746 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 ...
deomanu01's user avatar
  • 119
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 ...
mister nobody's user avatar
1 vote
1 answer
344 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 | ...
Nitin's user avatar
  • 235
0 votes
1 answer
392 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{...
algae's user avatar
  • 121
0 votes
1 answer
206 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 ...
Jeff's user avatar
  • 163
1 vote
1 answer
985 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 ...
Biggybi's user avatar
  • 2,760
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 ...
hyggan's user avatar
  • 11
1 vote
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/...
fbence's user avatar
  • 677
4 votes
3 answers
789 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 ...
mbl's user avatar
  • 319
2 votes
2 answers
767 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. ...
CIsForCookies's user avatar
0 votes
1 answer
216 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#...
FailureGod's user avatar
1 vote
1 answer
701 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,...
BaRud's user avatar
  • 491
1 vote
1 answer
316 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>...
SergioAraujo's user avatar
  • 1,175
2 votes
1 answer
94 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 ...
geoffjay's user avatar
  • 141