How do I move the cursor to the other end of a visual selection?
o (in visual mode)
While in visual mode, pressing o swaps the cursor to the opposite end of the selection.
o (in visual mode)
While in visual mode, pressing o swaps the cursor to the opposite end of the selection.
<C-]> / <C-t>
The command jumps to the definition of the keyword under the cursor using a tags file, and jumps back.
:Telescope live_grep
Telescope's livegrep picker provides real-time regex search across your entire project as you type.
Treesitter incremental selection with grn/grc
nvim-treesitter provides incremental selection that expands based on the syntax tree rather than simple text patterns.
:source % or :'<,'>source
The :source command executes Vimscript from a file.
command-line #command-line #vimscript #workflow #development
:set statusline=%f\ %m%r%h%w\ %=%l/%L\ %p%%
Vim's statusline option accepts printf-style format codes that display file info, position, mode, and any custom expression.
:%s/pattern/\=MyFunc(submatch(0))/g
The \= prefix in Vim's substitute replacement invokes the expression register, which can call any Vimscript function.
:%s/pattern/\=@0/g
The \=@0 replacement expression inserts the contents of register 0 (last yank) as the replacement text.
:{range}!command
The :{range}!command syntax pipes the specified lines through an external shell command and replaces them with the output.
command-line #command-line #shell #filtering #unix #ex-commands
"-p
The small delete register ("-) captures text from delete operations that are less than one line — like dw, x, dt.
=i{ or =ap
The = operator performs smart indentation based on Vim's filetype-aware indent rules.
:resize N / :vertical resize N
The :resize and :vertical resize commands set a window to an exact number of lines or columns.
/pattern/+N or /pattern/-N
Vim's search command accepts an offset that places your cursor on a line relative to the match.
/\%>10l\%<20lpattern
Vim's \%>Nl and \%10l matches only after line 10 \%10l\%10l\%<20lold/new/g Combine with column restrictions for precise region targeting Tips Line numbers in \%
". / "% / ": / "# registers
Vim has four read-only special registers that automatically contain useful contextual information.
registers #registers #special-registers #workflow #productivity
:help registers
Vim has 10 types of registers, each serving a specific purpose.
:%s/,/\r/g
In Vim's substitute command, \r in the replacement string inserts a newline.
qq /pattern<CR> {commands} q
By incorporating a search command inside a macro, you can make it jump to the next occurrence of a pattern before performing its edits.
oil.nvim: edit directory listing like a buffer
oil.
:find filename
The :find command searches for a file by name across all directories in your path setting and opens it.
buffers-windows #buffers #file-management #navigation #workflow