How do I dynamically build and run Ex commands from strings in Vim?
:execute 'normal! ' . count . 'j'
The :execute command evaluates a string as an Ex command, enabling dynamic command construction.
:execute 'normal! ' . count . 'j'
The :execute command evaluates a string as an Ex command, enabling dynamic command construction.
:cabbrev tn tabnew
Command-line abbreviations with cabbrev let you create short aliases for frequently used Ex commands.
command-line #command-line #abbreviation #shortcuts #productivity
<C-f> (from command-line mode)
When you are partway through typing a long or complex Ex command on the : prompt, you can press to open the command-line window.
:argdo %s/old/new/g | update
The :argdo command runs an Ex command on every file in the argument list (the files you opened Vim with, or added via :argadd).
:verbose set {option}?
:verbose set {option}? shows the current value of an option and reports exactly which file set it last — the full path and line number.
<C-r><C-f>
While typing a command, inserts the filename under the cursor in the buffer at the command-line prompt.
:args **/*.py
Vim's argument list (arglist) is a named list of files that you can operate on as a group.
:%!{command}
The ! filter command in Vim sends a range of lines to an external program as standard input, then replaces those lines with the program's standard output.
<C-r>:
Vim stores your last executed Ex command in the read-only : register.
:v/pattern/command
:v (short for :vglobal) is the inverse of :g.
:{range}normal {commands}
The :normal command executes normal mode keystrokes from the command line.
command-line #command-line #ex-commands #editing #normal-mode
<C-r><C-w>
When typing a command on the Vim command line, pressing inserts the word currently under the cursor.
: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.