Intermediate Vim
This is largely a TODO learning list for myself. I’m certainly not a Vim newbie, but I still have some gaping holes in my skills:
-
Navigating between buffers quickly
-
Jumping around in files
-
Getting the cursor right there quickly without a lot of
hjkl
I really enjoyed this talk by Leeren Chang titled "Vim: Tutorial on Editing, Navigation, and File Management (2018)":
I knew maybe a third of the tips, but I use only a few of them. This is exactly the stuff I wanna get better at.
Specifically:
Movement
-
Navigating to the High, Middle, or Low parts of the visible document with
H
,M
,L
-
Putting the current line at the top, middle, or bottom of the screen with
zt
,zz
,zb
-
Scrolling buffer up/down without moving cursor with
Ctrl-e
,Ctrl-y
Jumping around
-
Using bookmarks with
m<letter>
to set and'<letter>
to return -
Going to the last change with
'.
and cycling withg;
andg,
(list with:changes
) -
Going to recent cursor positions ("jumps") with
Ctrl-o
andCtrl-i
(list with:jumps
)
The bookmarks are one of the few things I’d always meant to pick up and actually had picked up before watching this video. But, of course, they require some advance planning - you have to realize in advance that you’ll want to return to a spot. I’m excited about the change and "jump" lists because those essentially "bookmarks in retrospect".
Finding buffers
The old :ls
to list and b <part of filename>
to switch to buffer works okay.
"Jump list on disk": One of my favorite tricks is to put a list of files (relative paths to the root of the project) I’m working on in a text file. Then I can use gf
to go to that file. Recently, I discovered Ctrl+6
to "go back" to the previous buffer.
For the advanced version of "jump list on disk", I use VimWiki at work and I intersperse notes with filenames with a special syntax highlighting scheme so I can visually differentiate between the file paths and notes at a glance. I also have a custom gw
shortcut that always takes me back to whatever wiki page I was looking at. It’s stupid simple: nnoremap gw :b wiki<cr>
. I absolutely love it.
It will be really interesting to discover this card a while from now and see how many of the above tips I’ve put into practice.