User Tools

Site Tools


linux:vi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:vi [2020/09/07 19:02] Wulf Rajeklinux:vi [2023/05/29 11:55] (current) – external edit 127.0.0.1
Line 31: Line 31:
 That makes the default paste buffer map to X's clipboard. 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. 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''
 +<code>
 +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
 +</code>
 +
 +===== Cut, Copy & Paste =====
 +
 +  - Press ''v'' to select lines or test with cursor keys
 +  - Then press ''y'' to copy the selection or press ''d'' to cut the selection
 +  - Then press ''%%'%%>'' to skip to the end of the selection
 +  - Then press ''p'' to paste under the cursor or ''SHIFT+p'' to paste after the cursor
 +
 +  - Copy the entire line by pressing ''yy'' (more info :help yy ) or cut using ''dd''.
 +  - Paste the line by pressing ''p''.
 +
 +===== Copy whole file to clipboard =====
 +
 +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+
 +
 +===== Search & Replace =====
 +
 +<code>
 +:%s/bla/blubs/
 +</code>
 +
 +Complex replace with reference:
 +<code>
 +:%s/rtrim(\(.*\),"0")/zerotrim(\1)/
 +</code>
 +
 +to repeat, press ":", then the cursor up
 +
linux/vi.1599501750.txt.gz · Last modified: 2023/05/29 11:53 (external edit)