How to use vim horizonal movements

Horizontal movements in Vim refer to the navigation and movement commands that allow users to traverse the text horizontally within the editor

As stated in the article [vim - Vertical movements] the best way to learn how to use vim horizontal movements is to disable the arrows and pageUp/pageDown keys.

Vim provides a range of commands for moving the cursor left or right by characters, words, or specific positions within a line. They provide users with precise control over their cursor position, allowing for efficient navigation, editing, and manipulation of text within the editor.

The horizontal movements can be divided into several categories depending on the level of movement that you are going to perform:

  • Words: each sequence of characters up to a special character is considered a word
  • Blocks of text: each sequence of characters up to a white space is considered a block
  • Occurrence: find an occurrence of a specific character from the cursor position
  • Character: move only one character

The main horizonal movements to the right are the following:

  • w: jump to the next word. It considers any special character as another word
  • W: jump to the word after the next whitespace
  • f<char>: finds the next occurrence of that character in the line and jumps to it
    • ;: repeats the find operation
  • l: moves to the next character
  • $: moves to the end of the line
There are equivalent movements for moving to the left:

  • b: jump to the previous word. It considers any special character as another word
  • B: jump to the word after the previous whitespace
  • F<char>: finds the previous occurrence of that character in the line and jumps to it
    • ;: repeats the find operation
  • h: moves to the previous character
  • 0: moves to the beginning of the line
  • _: moves to the first character of the line
Here is an example of these movements in action:

vim horizontal movements


Popular posts from this blog

How to setup NeoVim configuration file

WebAssembly (Wasm): Fixing the Flaws of Applets

How to query Outlook from PowerShell