How do I convert all tabs to spaces in a file in Vim?
:retab
How it works The :retab command replaces all tab characters in the current buffer with the appropriate number of spaces, based on your current tabstop and expan
399 results for "it at"
:retab
How it works The :retab command replaces all tab characters in the current buffer with the appropriate number of spaces, based on your current tabstop and expan
<C-t> and <C-d> in insert mode
When typing in insert mode, you can adjust the current line's indentation without leaving to normal mode.
r{char}
The r{char} command replaces the character under the cursor with {char} without ever entering insert mode.
:%s/\<word\>/replacement/g
How it works In Vim's regular expressions, \ are word boundary anchors: \ matches the end of a word.
\v
Vim's default regex mode ("magic") requires backslashes before many special characters: \(, \ , \+, \{.
zf{motion}
Vim supports several fold methods, but manual folding with zf gives you precise control over exactly which lines to collapse.
ct{char}
The ct{char} command deletes everything from the cursor up to (but not including) the specified character and drops you into insert mode.
editing #editing #motions #normal-mode #text-objects #productivity
<C-r>0
In Insert mode, {reg} pastes the contents of any register inline at the cursor.
<C-w>^
Vim tracks the alternate buffer — the last file you were editing before the current one.
:'<,'>s/\%Vpattern/replacement/g
When you press : after making a visual selection, Vim inserts ' to restrict the substitution to the selected lines.
visual-mode #visual-mode #search #editing #ex-commands #normal-mode
o (in Visual mode)
When you make a Visual selection in Vim, the cursor sits at one end while the other end is anchored.
:s/old/new/g
The :s/old/new/g command replaces all occurrences of old with new on the current line only.
g; and g,
Vim tracks every position where you made a change in the changelist.
:syntax sync fromstart
Vim's syntax highlighting engine does not always parse the entire file from the beginning — it uses sync points to determine where to start parsing for the vi
<C-q> (Telescope)
While inside any Telescope picker, pressing sends all current results to the quickfix list and closes the picker.
<C-y> and <C-e>
In Insert mode, copies the character at the same column position from the line above the cursor, and copies the character from the line below.
:tab split
:tab split opens the current buffer in a brand new tab page, giving you a second independent view of the same file.
:bufdo
When you need to apply the same change to every file you have open in Vim, switching to each buffer manually is tedious and error-prone.
42G
The 42G command jumps the cursor directly to line 42 in the current file.
:nnoremap <buffer> <leader>r :!python %<CR>
How it works By adding to a mapping command, the mapping only applies to the current buffer.