How do I remove trailing whitespace from all lines?
:%s/\s\+$//
The :%s/\s\+$// command removes trailing whitespace (spaces and tabs) from every line in the file.
2277 results for "@a"
:%s/\s\+$//
The :%s/\s\+$// command removes trailing whitespace (spaces and tabs) from every line in the file.
".p
The ".
registers #registers #editing #insert-mode #normal-mode #productivity
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.
X
The X command deletes the character to the left of the cursor (before it).
augroup name | autocmd! | ... | augroup END
Using augroup with autocmd! inside prevents duplicate autocommands from accumulating when you reload your vimrc.
"%p
The % register in Vim always contains the name of the current file.
registers #registers #editing #insert-mode #productivity #filename
cc
The cc command deletes the entire content of the current line (preserving indentation) and enters insert mode.
>
In visual mode, pressing > indents all selected lines by one shiftwidth.
:set cursorline
The cursorline option highlights the entire line where the cursor is positioned.
n
After performing a search with / or ?, pressing n repeats the search in the same direction to find the next match.
:mksession and :source
The :mksession command saves the current Vim session (windows, buffers, tabs, cursor positions) to a file.
:%S/old/new/g (vim-abolish)
vim-abolish by Tim Pope provides :%S (Subvert), a substitute command that preserves the case pattern of the original text.
(
The ( motion moves the cursor backward to the start of the current or previous sentence.
:set hlsearch
The hlsearch option highlights all matches of the current search pattern throughout the file, making it easy to see where matches occur.
/{pattern}
The / command initiates a forward search in the file.
:set nobackup noswapfile
Disabling backup and swap files prevents Vim from creating extra files alongside your source code.
auto-pairs plugin
auto-pairs automatically inserts closing brackets, parentheses, and quotes when you type the opening one.
{
The { motion moves the cursor backward to the previous blank line, jumping to the beginning of the current or previous paragraph.
:%s/\V literal.text/replacement/g
The \V (very nomagic) flag treats all characters as literal except for \.
:set autoindent
The autoindent option copies the indentation from the current line when starting a new line.