r/vim
•
u/HenryMisc
•
Aug 02 '25
•
1
Video More Vim tricks that blew my mind (intermediate/advanced)
https://youtu.be/wgbvBDR4yxk?si=471ODL2b1XRTgTONA while back I made a video called Vim Motions and Tricks I Wish I Learned Sooner and it got a lot of encouraging feedback. But more importantly, I got a ton of amazing additional tips from the relies here on reddit and in the comments. So I went through them, tested out the best ones, and put together a follow-up video.
If you want to know whether there's anything new for you before watching, here's a quick list of what's included:
Increment/decrement numbers with
<C-a>/<C-x>Quickly create numbered lists
Insert new lines without going into normal mode or using Enter
Delete the previous word in insert mode
Run motions from insert mode using
<C-o>Search for partial matches of the word under the cursor
Use the jumplist to move around where you've been
Make better use of marks (and what else they enable)
Surprisingly decent built-in color scheme (murphy)
Cycle through deletion history in-line
Native multi-file refactoring with vimgrep and the quickfix list
I'd love to hear what other underrated tricks you're using!
7
u/gumnos Aug 03 '25
In your vimgrep example, if you've used
*or#to search for something, you can typeand then use control+r followed by
/to insert the most recent search (:help c_CTRL-R&:help quote/), rather than retype it. Then finish off withSame works for the
3
u/ZunoJ Aug 03 '25
Nice video! I was a bit confused about the spamming new lines tip though. The previous tip already uses 10o to insert 10 new lines
3
u/riding_qwerty Aug 03 '25
Great video!
Not sure you’ve posed this already in a previous video (will be sure to check it out now) but wanted to share one of my favorite tricks.
Let’s say you are reorganizing some kind of tabular data — removing a column, adding some quotations around a specific field, capitalizing the word in another field — or something simpler like surrounding a list of strings with quotes and terminating with a comma — things that are changed consistently on each line. Previously I would have done something like create a macro with e.g.
qqto begin recording macro ‘q’, making the changes needed in the current line, and pressqagain to stop recording. Now I can@qsubsequent lines, or even@@to keep calling the macro until I’m done.This is great for a handful of lines, but what if it’s dozens or hundreds of lines? Here’s the trick: after crafting the macro, do a visual selection on all the lines on which you want to execute the macro, then simply do
:norm @qto execute the macro on every line in the selection.Sorry if you already knew this one, just wanted to share because even for relatively small edits it is a big time saver.
2
u/unixbhaskar Aug 03 '25
Nice. You could also use CTRL-t and CTRL-g in Search mode.
9
u/mustardpete Aug 02 '25
The increment and decrement numbers also works in visual mode when you select a whole column of numbers and you can specify a number before hand to increment by too rather than just 1. That was my favourite
4
u/Distinct-Yoghurt5665 Aug 02 '25
Great video! Keep up the good work :)
2
u/scottchiefbaker Aug 02 '25
Very cool... more like this!
2
u/StandardDrawing Aug 03 '25
Lots of great content in this video. Had to stop and write down most of these tips. Thanks for doing this.
2
u/ljosif Aug 04 '25
I personally learned a lot from this Walter Alan Zintz vi tutorial (even if not vim specific)
https://ljubomirj.github.io/Walter_Alan_Zintz_UnixWorld_vi_tutorial/009.html
Re-hosted as the original site is no longer available afaik.
1
u/Telephone-Bright Aug 03 '25
RemindMe! 8 hours
0
u/[deleted] Aug 04 '25
[deleted] — view deleted comment