I navigate by big words much more often would like to just type w and b instead of W and B every time. I wonder if Vim has a setting for this.
1 Answer
Vim is very customizable. You can customize the behavior of every key. For normal mode w
and b
, you could do
nnoremap w W
nnoremap b B
To replicate this behavior in a visual selection, and after an operator (such as d
, c
, y
), you could do
xnoremap w W
onoremap w W
xnoremap b B
onoremap b B
In the above, the x
and o
refer to visual and operator-pending modes respectively.
You could extend these, to include
- the navigation to the end of WORDS with
e
, andge
- using
W
,B
,E
,gE
to navigate by words instead of WORDS
Have a look at :h usr_05.txt
(notably, sections 5.1 and 5.3) for more information.
-
This answers the question as it was asked: it will work for navigation. Note that this will not affect visual and operator-pending modes. You would also have to define the same mappings as
vnoremap
andonoremap
to have consistency across modes. Commented May 20 at 8:54 -
@Friedrich means
xnoremap
, notvnoremap
. It would also be good to suggest the "swap" (nnoremap W w
) so that you can still navigate by words as needed.– D. Ben Knoble ♦Commented May 21 at 16:18 -
-
@D.BenKnoble I see no reason to exclude select mode (although I never use it). That's probably why I'm not aware why to prefer
:xnoremap
to:vnoremap
. Would you care to elaborate? Commented May 21 at 18:16 -
1@Friedrich in select mode (which I admittedly rarely use), the “printable” keys delete the selected text and start inserting (like a traditional editor: highlight with mouse, type to wipe away and insert new content). So mapping characters like w, b in select mode doesn’t make sense, usually.– D. Ben Knoble ♦Commented May 21 at 20:02
:help
(as opposed to regular words).