How do I run a normal mode command on every line in a range?
:{range}normal {commands}
The :normal command executes normal mode keystrokes from the command line.
command-line #command-line #ex-commands #editing #normal-mode
:{range}normal {commands}
The :normal command executes normal mode keystrokes from the command line.
command-line #command-line #ex-commands #editing #normal-mode
:10,20w newfile.txt
Use :10,20w newfile.
:%!sort
Use :%!command to filter the entire buffer through a shell command.
:verbose map <key>
Use :verbose map to see the mapping definition and the file/line where it was set.
<C-r>/ or q/
Press q/ to open search history in a window.
:set tabstop?
Append ? to any option name to query its value.
:redir @a | silent messages | redir END
Use :redir to capture command output.
:!ls
Use :! followed by any shell command.
:g/pattern/p
Use :g/pattern/p to print all matching lines.
:10,20d
Specify a line range before a command.
:r !date
Use :r !command to read the output of a shell command into the buffer below the cursor.
:10,15m 25
Use :m (move) with a range and destination.
:%normal A;
Use :%normal followed by normal mode keystrokes.
:marks
Use :marks to display all current marks with their line numbers, column positions, and file/text.
:10,15t 25
Use :t (copy) with a range and destination.
<C-f> on command line
While typing a command, press to open the command-line editing window.
:args *.py
Use :args *.
:argdo %s/old/new/ge | update
Use :argdo to execute a command in every file in the argument list.
<C-r>=system('cmd')
In command-line mode, =system('command') evaluates the shell command and inserts its output into the command line.
:s/pattern/replace/flags
The substitute command supports several flags that modify its behavior.