3 ms·
UltiSnips – Snippet Solution for Vim
- grozmovoi 3y agoI wonder how the health of this project will be affected by cody/copilot? Genuinely wondering if it's wort spending time setting up ultisnips vs. learning to use copilot well. Like, I prefer to have my own snippets and set them up the way I want, but hey - the convenience of LLMs... idk
- DiabloD3 3y agoIt isn't worth considering LLMs for code, and I don't think they can ever solve the issue in a way that satisfies all the legal and ethical constraints. Also, why wouldn't you just use both? Snippets let you quickly use known patterns, LLMs let you quickly write the more generic case of boilerplate that doesn't align well with snippet use.
- jyunwai 3y agoI like using UltiSnips to easily write lengthy commands, when typesetting mathematical notes using Vim as a text editor for the LaTeX software. For example, if I want to add an image to a document, the necessary full command to type this might be `\includegraphics[scale=0.5]{Image_file_name}`, which is a lot to type for image-heavy documents. But with UltiSnips, I can write any shortcut (e.g. by typing `img` and pressing the `Tab` key or alternatively letting it auto-complete depending on my snippet setting), then the whole command is typed out: `\includegraphics[scale=0.5]{$1}$0`. My cursor would immediately be placed at the $1 position, and pressing the `Tab` key would take me outside to the $0 position, so I can keep typing. It's simple and predictable for myself as a user to easily write the full command, whereas I predict that a solution that uses an large language model (LLM) for this context may add complexity without making the task easier for my purposes (though LLM-based software may be more useful in other contexts).
- imran-iq 3y agoOne of these things needs an internet connection to function. The other does not.
- grozmovoi 3y agopoint for utilsnips
- dbalatero 3y agoThere's plenty of snippets that are well known per language/framework, and might as well be instant AND consistent instead of spinning on an API call.
- xigoi 3y agoSnippets are deterministic, so you can use them without having to check their output.
- grozmovoi 3y agothat's valid
- freeplay 3y agoIf you're using Neovim, check out LuaSnip: https://github.com/L3MON4D3/LuaSnip https://github.com/L3MON4D3/LuaSnip
- mrzool 3y agoI might be old fashioned, but I think that if you learn the Vim way you'll have no use for a snippet manager. Also, that using a snippet manager will prevent you from learning the Vim way.
- rustyminnow 3y agoCould you elaborate? Are you talking about :abbreviate and such? As a heavy vim user for years, I've found myself getting more value out of snippets as of late.
- soraminazuki 3y agoTo create a box around a text without snippets, type this: # section #<Esc>yyP:s/./#/g<CR>yyjpo Instead of the more convenient: box<CTRL-X><CTRL-J>section<CTRL-J> And to insert the current date and time in ISO 8601 format, type this: <Esc>:Man strftime<CR><CTRL-F><Repeat last key 7 times to scroll through the man page>:q<CR>gi=strftime("%Y-%m-%dT%H:%M:%S%z")<CR> Instead of this: iso8601<CTRL-X><CTRL-J> To complete long snippets of text, type this: <Esc>:r path/to/snippet.txt<CR>kJ/<placeholder><CR>cgn<replacement text 1><Esc>cgn<replacement text 2><Esc>cgn Instead of this: snippet<CTRL-X><CTRL-J><replacement text><CTRL-J><replacement text 1><CTRL-J><replacement text 2><CTRL-J> The last one might not sound so bad until you realize that you can't have dynamic content in snippets, can't go back to previous placeholders without undoing every change made along the way, can't treat two different placeholders as being equivalent, and most importantly, can't reuse countless useful snippets made by the community. Support for plugins is a first class feature of Vim. While I agree that being aware of the built-in features is a good thing, there's no shame in using plugins that extend Vim in a useful way.
- rustyminnow 3y agoI wasn't familiar with gn, thanks! Using :r for snippets is neat too, if crude. GP was clearly gatekeeping, but by asking sincerely I hoped to learn something new. And so I have! All the best.
- 3y ago
- prabir 3y agoMy go to these days has been https://github.com/hrsh7th/vim-vsnip https://github.com/hrsh7th/vim-vsnip. It is compatible with LSP and VSCode snippet format. Since it is in pure VimScript you don’t need to battle configuring python just to get the plug-in to work.
- wruza 3y agoUgh, this format is just hostile to bigger snippets and snippet-rich approach. That said, it was vscode experience. Pretty sure I can easily create a couple of vim macros for [un]jsoning lines, so maybe it’s worth comparing vs snipmate.