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

How do I quickly append text to the end of a word under the cursor in Vim?

Answer

ea

Explanation

The ea compound shortcut moves to the last character of the current word with e, then enters insert mode after the cursor with a. It is the fastest way to add a suffix, punctuation, or closing character to a word without navigating to the end of the line first.

How it works

  • e moves the cursor to the last character of the current (or next) word
  • a enters insert mode after the cursor position — equivalent to pressing l then i
  • Together, ea positions you immediately after the word's final character, ready to type

This is distinct from A, which always jumps to the end of the line regardless of where the cursor is.

Example

Given the text, with the cursor anywhere on the word config:

load config

Press ea, type _file, then <Esc>:

load config_file

With A, you would get the same result only if the cursor was already on the last word of the line.

Tips

  • Ea (uppercase E) treats consecutive non-whitespace characters as one WORD, so it skips over punctuation within a token — useful for editing things like foo.bar as a single unit
  • The reverse motion is bi: b goes to the beginning of the word, i enters insert mode before the cursor
  • You can precede with a count: 2ea appends after the end of the second word ahead of the cursor
  • In operator-pending mode, e works as a motion too — de deletes to the end of the word, ye yanks to the end

Next

How do I add custom markers or icons in Vim's sign column next to specific lines without any plugins?