User Tools

Site Tools


linux:vi

This is an old revision of the document!


VI tips

Quick save

Press SHIFT + ZZ which is equivalent to :x which is equivalent to :wq, except that it only saves if the file has been changed.

Set tab size and convert tabs to spaces

:set tabstop=4
:retab

Turn off autoindent when you paste code

To toggle this in VI on the fly to switch off auto-indent

:set paste

and to switch it back on

:set nopaste

In .vimrc this can be set:

set copyindent

Another alternative via .vimrc is:

set clipboard=unnamed

That makes the default paste buffer map to X's clipboard.
When a bit of text is highlighted in a terminal, it can be pasted into vim by simply press p to paste. Similarly, one can yank things in vim (e.g. YY to yank the current line into the buffer) and middle click in any window to paste it.

linux/vi.1599501750.txt.gz · Last modified: 2023/05/29 11:53 (external edit)