Getting around quickly with vim is one of the keys to not only working more quickly, but also being able to more easily reuse macros and the repeat (dot) command. In this example, I will show the difference between the w, b, and e key and the capital (shift) variant in normal mode.
# this is only a comment to show that 'w', 'b', and 'e' jump a word at a time # this is some random code to show 'W', 'B', and 'E' jump to spaces foo.bar = function { cat.meow().toString; dog(); }
In vim normal mode:
- w will jump to the start of the next word
- e will jump to the end of the current word
- b will go back to the start of the previous word
Capital/Shift variants will instead act on a WORD definition. Vim help defines a word as “A WORD consists of a sequence of non-blank characters, separated with white space. An empty line is also considered to be a WORD.”
In the above example, cat.meow().toString is treated very different with w vs W key strokes. Copy and paste the above block into vim, navigate to c in the word cat. Now try pressing w. Go back to c and try W.
As you can see, w jumps to m in meow. W jumps you to the d in dog().
Capital/Shift variants are a great way to skip down lines of code.