How do I copy the word under the cursor regardless of cursor position within it?
yiw
How it works The command yiw yanks (copies) the inner word under the cursor.
yiw
How it works The command yiw yanks (copies) the inner word under the cursor.
:'<,'>!command
How it works Vim can pipe selected text through any external shell command, replacing the selection with the command's output.
:let @a=getline('.')<CR>@a
How it works Instead of recording keystrokes interactively, you can write a sequence of Vim commands as plain text in your buffer and then execute that text as
:if condition | execute 'normal cmd' | endif
How it works Vim macros can include Ex commands with conditional logic.
:%s/foo/bar/g | %s/baz/qux/g | w
The (bar) character in Vim's command line acts as a command separator, allowing you to chain multiple ex commands together on a single line.
:'<,'>g/pattern/command
How it works The :g (global) command is one of Vim's most powerful features.
qa0f=20i <Esc>20|C= <Esc>lDjq
How it works Aligning text on a delimiter such as = without plugins requires a clever macro technique.
:iabbrev teh the
Vim's abbreviation feature lets you define automatic text replacements that trigger as you type.
qa{edits}@bq
How it works Vim macros can call other macros, creating a modular system of reusable building blocks.
:'<,'>copy'>
How it works The :copy command (or its abbreviation :t) duplicates lines to a specified destination.
qama{edits}'aq
How it works When a macro needs to jump to different parts of the file and then return to a starting position, marks are the perfect tool.
v%
How it works The % motion jumps to the matching bracket, parenthesis, or brace.
qabi"<Esc>ea"<Esc>wq
How it works This macro wraps the current word in double quotes and moves to the next word, making it easy to repeat across a line or file.
U, u, or ~ in visual mode
How it works When you have text selected in visual mode, you can change its case with three simple keys: U - Convert the entire selection to UPPERCASE u - Conve
:!ls -la
Vim lets you execute any shell command directly from within the editor using the :! (bang) command.
qa:s/old/new/g<CR>jq
How it works You can combine Ex commands like :s (substitute) with macro recording to create powerful repeatable find-and-replace operations that go beyond what
do (diffget) / dp (diffput)
How it works When you open two files in diff mode (using vim -d file1 file2 or :windo diffthis), Vim highlights the differences between them.
qa0f:dwj0q
How it works When recording a macro that you plan to repeat across multiple lines, the key technique is to end the macro positioned on the next line, ready for
autoload/myplugin.vim
The autoload mechanism in Vim lets you write plugins whose functions are only loaded into memory when they are first called.
v, V, or Ctrl-V while in visual mode
How it works Vim has three visual modes, and you can switch between them without losing your current selection: v - Characterwise visual mode (select individual