~ / ex
10
Ex Commands
The command line: ranges, :t and :m, :normal across lines, :substitute, :global and repeating the last command.
- 01
Line ranges: :d, :j and friends
Put a range in front of an Ex command to work on lines without moving to them.
:{N}:{N},{M}d:.,$d:.,+{N}d:{N},{M}j:{N},{M}j!:'<,'>:% - 02
Copy and move lines: :t and :m
Duplicate or move whole lines to any address with one command.
:t.:{N}t.:t$:t0:m0:m$:m+1:m-2 - 03
Normal mode on many lines: :normal
Type the same Normal-mode keys on every line of a range.
:%normal {keys}:'<,'>normal {keys}:{range}normal . - 04
Substitute: :s, ranges and flags
Replace text on a line, in a range or everywhere, with & for the whole match.
:s/{old}/{new}/:s/{old}/{new}/g:%s/{old}/{new}/g:'<,'>s/{old}/{new}/&\&nvim - 05
Matching lines: :g, :v and :sort
Run a command on every line that matches (or doesn't), and sort lines.
:g/{pattern}/d:v/{pattern}/d:g/^/m0:g/{pattern}/t$:sort:sort u:sort n:sort! - 06
Repeat the last Ex command: @: and @@
Run the previous command line again, here or anywhere else.
@:{count}@:@@ - 07
Grab the word under the cursor: <C-r><C-w>
Insert the word (or WORD) under the cursor into the command line.
<C-r><C-w><C-r><C-a><C-r><C-l><C-r>{register}nvim