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 tabstop=4 :retab
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.
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
v
to select lines or test with cursor keysy
to copy the selection or press d
to cut the selection'>
to skip to the end of the selectionp
to paste under the cursor or SHIFT+p
to paste after the cursoryy
(more info :help yy ) or cut using dd
.p
.
The clipboard is buffer +. To copy to clipboard, do “+y and [movement].
So, gg”+yG will copy the whole file.
Similarly, to paste from clipboard, “+p
Alternatively:
gg”*yG
:%y+
:%s/bla/blubs/
Complex replace with reference:
:%s/rtrim(\(.*\),"0")/zerotrim(\1)/
to repeat, press “:”, then the cursor up