How do I execute the current line as a shell command and insert the output?
:.!sh
The :.
command-line #editing #ex-commands #shell #filtering #productivity
:.!sh
The :.
command-line #editing #ex-commands #shell #filtering #productivity
:args **/*.js | argdo %s/old/new/ge | update
The argument list (arglist) is Vim's mechanism for loading a set of files and running commands across all of them.
command-line #command-line #ex-commands #arglist #productivity #batch #editing
:%s/\(pattern1\)\(pattern2\)/\2\1/g
Vim's substitute command supports capture groups that let you match parts of text, remember them, and rearrange or reuse them in the replacement.
:g/pattern/yank A
The :g command combined with yank A (uppercase A to append) lets you collect every line matching a pattern into a single register without overwriting previous c
command-line #editing #ex-commands #global-command #registers #filtering
:{range}command
Every Ex command in Vim can be preceded by a range that specifies which lines it should operate on.
command-line #command-line #ex-commands #ranges #editing #productivity
:vsplit
The :vsplit command (or :vs for short) splits the current window vertically, creating a new window side-by-side with the current one.
:registers
The :registers command displays the contents of all Vim registers, showing you exactly what text is stored in each one.
:w !sudo tee %
The :w !sudo tee % command lets you save a file that requires root permissions, even if you forgot to open Vim with sudo.
:set colorcolumn=80
The :set colorcolumn=80 command displays a vertical highlight at column 80, giving you a visual guide for line length.
:set tabstop=4 shiftwidth=4 expandtab
The :set tabstop=4 shiftwidth=4 expandtab command configures Vim to use 4-space indentation with spaces instead of tab characters.
:set list
The :set list command makes invisible characters visible by displaying them as special symbols.
:'<,'>sort
The :'sort command sorts the currently selected lines in visual mode alphabetically.
:r filename
The :r filename command reads the contents of filename and inserts them into the current buffer below the cursor line.
:'<,'>normal @a
The :'normal @a command executes the macro stored in register a on every line within the current visual selection.
:!command
The :!command syntax lets you execute any shell command directly from within Vim without leaving the editor.
:s/old/new/g
The :s/old/new/g command replaces all occurrences of old with new on the current line only.
:bnext
The :bnext (or :bn for short) command switches to the next buffer in Vim's buffer list.
:tabnew filename
The :tabnew filename command opens a file in a new tab page in Vim.
buffers-windows #buffers-windows #tabs #ex-commands #navigation
:terminal
The :terminal command opens an interactive terminal emulator directly inside a Vim window.
:bprev
The :bprev (or :bp for short) command switches to the previous buffer in Vim's buffer list.