Vim Recall繁體中文

Run Normal commands across lines

:%normal! I#

Example

Normal mode. Lines: alpha, beta. Include the space after # in the command.

Before
alpha
beta
  1. :%normal! I# <CR> Prefix both lines · # alpha, # beta
After
# alpha
# beta
Details & Vim help

Apply a Normal-mode edit to every line in a range.

Reuse a familiar cursor operation instead of constructing a substitution.

The ! bypasses mappings. Literal <Esc> text is not decoded by :normal; special keys need literal control characters or :execute with escaped key notation, such as "\<Esc>". The command consumes a following | as keys.

I starts insertion before the first nonblank on each line. The trailing insertion is ended when :normal finishes.

Try it in Vim

  1. Use :%normal! I# and press <CR>; the space after # is intentional.
  2. Replace % with a smaller range when needed.
  3. Inspect the result before writing the file.