4 ms·
I 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 yo
by mrzool 3y ago
I 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.
- soraminazuki 3y agoCorrection: <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> was supposed to be this: <Esc>:Man strftime<CR><CTRL-F><Repeat last key 7 times to scroll through the man page>:q<CR>gi<CTRL-R>=strftime("%Y-%m-%dT%H:%M:%S%z")<CR>
- tuatoru 3y ago:r!date -Iseconds
- dbalatero 3y agoWhich vim way are you refering to? I'd like to check it out but I have no idea what to look for.
- mrzool 3y agoApologies, I haven't logged in for a while. This article by Drew Neil explains it better than I ever could: http://vimcasts.org/blog/2012/08/on-sharpening-the-saw/ http://vimcasts.org/blog/2012/08/on-sharpening-the-saw/
- wruza 3y agoI’m using snippets all the time, e.g. there are snippets for express app, telegraf bot, Intl stuff, frontend boilerplates, etc etc. I could map or abbr these and map placeholder jumps, but that quickly becomes unmaintainable and typo-prone. Snippets are great in that you can just paste existing code and parametrize it, then update when needed. Also I dislike the fact that you have to actively prevent these expansions instead of actively triggering them.