linux:vi
This is an old revision of the document!
Table of Contents
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.
Default 4 tab spaces
in ~/.vimrc
filetype plugin indent on " show existing tab with 4 spaces width set tabstop=4 " when indenting with '>', use 4 spaces width set shiftwidth=4 " On pressing tab, insert 4 spaces set expandtab
Cut, Copy & Paste
- Press
v
to select lines or test with cursor keys - Then press
y
to copy the selection or pressd
to cut the selection - Then press
'>
to skip to the end of the selection - Then press
p
to paste under the cursor orSHIFT+p
to paste after the cursor
- Copy the entire line by pressing
yy
(more info :help yy ) or cut usingdd
. - Paste the line by pressing
p
.
linux/vi.1599502468.txt.gz · Last modified: 2023/05/29 11:53 (external edit)