Is there a way to display column numbers so that I could navigate similarly within a line?
Not really. If you are looking for column precision, there is the |
motion. 50|
will jump to the 50th column (one column being a character). I don't see this being that helpful unless you're writing a script or dealing with a well known text format.
Are there any other good techniques for quickly and accurately navigating within a line?
Yes! You can find them in :help motion.txt
.
Within the current line:
e
or b
- You're already familiar with these and their friends.
^
- Move to the first character on the line.
0
- Move to the first column on the line.
$
- Move to the last column of the line.
g_
- Move to the last character on the line.
f
and F
- Forward and backward, respectively. Press one of these, then the character you want to jump to. e.g. fb
will jump to the next b
in the line. If you press ;
, you'll jump to the next one. Pressing ,
will go in the opposite direction.
t
and T
- The same as above, but the cursor will land just before the character.
It might not seem ideal at first, but if you know you need to get to the last b
in the line, you can press $Fb
to get to it instead of pressing fb
and mashing ;
a few times.
Move by searching:
You are looking at where you need to move your cursor, so searching is a valid way to get there. /abc
will jump to the first occurrence of abc
. Pressing n
or N
will move your cursor between all the matches. gn
and gN
will move the cursor and select the match in visual mode.
But, searching will move beyond the current line, which is not within the current line like you mentioned. To stay within the line, you can select it with shift-v and search with /\%Vabc
. \%V
causes the search to only happen within the visual selection.
Plugins:
- easymotion - This gives you shortcuts based on the kind of text jump you want.
- vim-sneak - Similar to easymotion, but is more like
f
, F
mentioned above combined with searching.
f
/F
/t
/T
can be quite useful, and with easy motion, it becomes easier to use them. Have a look at the examples in the README.navigating one character or word at a time
.