Questions tagged [snippets]
Questions about the usage of snippets within Vim.
67
questions
0
votes
0
answers
19
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
36
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
561
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
1
answer
109
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
207
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
2k
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
126
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
268
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
72
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 ...
0
votes
0
answers
59
views
How can I import snippets from VsCode Extensions into vim?
Im new to vim and I need all snippets in this VsCode extension in vim. I put its link in below:
https://marketplace.visualstudio.com/items?itemName=xabikos.JavaScriptSnippets
How can I import them in ...
0
votes
1
answer
525
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
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 #####.
...
1
vote
1
answer
34
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
80
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
...
0
votes
1
answer
83
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
<---...
1
vote
0
answers
86
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 ...
3
votes
1
answer
280
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
118
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 | ...
2
votes
0
answers
51
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
78
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
91
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
189
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 ...
4
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
77
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
2
answers
351
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
vote
1
answer
77
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
171
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
68
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 ...
1
vote
1
answer
131
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?
0
votes
1
answer
325
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
106
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 ...
3
votes
1
answer
379
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}})$...
4
votes
1
answer
192
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
89
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
207
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
668
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 ...
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
337
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
| ...
0
votes
1
answer
370
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
186
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
1
answer
924
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 ...
1
vote
0
answers
372
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 ...
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/...
4
votes
3
answers
772
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 ...
2
votes
2
answers
738
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
212
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
666
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,...
1
vote
1
answer
311
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>...
2
votes
1
answer
93
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 ...