vimtricks.wiki Concise Vim tricks, one at a time.

How do I delete the character before the cursor?

Answer

X

Explanation

The X command deletes the character to the left of the cursor (before it). It is the backspace equivalent in normal mode.

How it works

  • X deletes one character to the left
  • The cursor moves left to fill the gap
  • Accepts a count: 3X deletes 3 characters to the left

Example

hello

With the cursor on o, pressing X deletes l:

helo

Tips

  • x deletes the character under the cursor (forward delete)
  • X is the backward version
  • 5X deletes 5 characters to the left
  • In visual mode, x and X both delete the selection

Next

How do you yank a single word into a named register?