4 ms·
Could 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
by rustyminnow 3y ago
Could 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