How do I search for a pattern only within a specific range of lines in Vim?
:/start/,/end/s/pattern/replacement/g
You can restrict a substitution to a range defined by two patterns.
:/start/,/end/s/pattern/replacement/g
You can restrict a substitution to a range defined by two patterns.
:set autoread
The autoread option tells Vim to automatically re-read a file when it detects the file has been changed outside of Vim.
@=
The @= command lets you type a Vimscript expression and execute the result as if it were a macro.
\u and \l in :s replacement
Vim's substitute command supports special case modifiers in the replacement string that let you change the case of captured text on the fly.
:center
The :center command pads a line with leading spaces so the text is centered within a given width.
:'<,'>m'>+1
The :m command with the visual range moves selected lines.
:vimgrep /pattern/ **/*.py
By specifying a file glob pattern with :vimgrep, you can restrict the search to specific file types.
:let @b = @a
The :let @b = @a command copies the contents of register a into register b.
:set updatetime=250
The updatetime option controls how long Vim waits after you stop typing before triggering certain events (like swap file writes and CursorHold autocommands).
V select then :norm A text
Selecting lines and running :norm A text appends the same text to the end of every selected line.
:set termguicolors
The termguicolors option enables 24-bit RGB color support, allowing color schemes to use millions of colors instead of the terminal's 256-color palette.
<C-r>=system('cmd')
In command-line mode, =system('command') evaluates the shell command and inserts its output into the command line.
:s/pattern/replace/flags
The substitute command supports several flags that modify its behavior.
:set belloff=all
The belloff=all option disables all error bells and visual bells in Vim.
:bwipeout
The :bwipeout command (:bw) completely removes a buffer from Vim's memory, including its marks, options, and variables.
:enew
The :enew command creates a new unnamed empty buffer in the current window.
:TestNearest (vim-test)
vim-test provides commands to run tests from within Vim.
:Git command (e.g., :Git status)
vim-fugitive by Tim Pope is a comprehensive Git wrapper for Vim.
:Make (vim-dispatch)
vim-dispatch by Tim Pope provides asynchronous build commands in Vim.
:set textwidth=80
The textwidth option sets the maximum width for text.