Run Normal commands across lines
:%normal! I#
Example
Normal mode. Lines: alpha, beta. Include the space after # in the command.
alpha
beta- :%normal! I# <CR> Prefix both lines · # alpha, # beta
# alpha
# betaDetails & 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
- Use :%normal! I# and press <CR>; the space after # is intentional.
- Replace % with a smaller range when needed.
- Inspect the result before writing the file.