linux:vi
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:vi [2019/12/28 16:28] – Wulf Rajek | linux:vi [2023/05/29 11:55] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== VI tips ====== | ====== VI tips ====== | ||
| + | ===== Quick save ===== | ||
| + | Press '' | ||
| ===== Set tab size and convert tabs to spaces ===== | ===== Set tab size and convert tabs to spaces ===== | ||
| Line 29: | 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 '' | When a bit of text is highlighted in a terminal, it can be pasted into vim by simply press '' | ||
| + | |||
| + | ===== Default 4 tab spaces ===== | ||
| + | |||
| + | in '' | ||
| + | < | ||
| + | filetype plugin indent on | ||
| + | " show existing tab with 4 spaces width | ||
| + | set tabstop=4 | ||
| + | " when indenting with '>', | ||
| + | set shiftwidth=4 | ||
| + | " On pressing tab, insert 4 spaces | ||
| + | set expandtab | ||
| + | </ | ||
| + | |||
| + | ===== Cut, Copy & Paste ===== | ||
| + | |||
| + | - Press '' | ||
| + | - Then press '' | ||
| + | - Then press '' | ||
| + | - Then press '' | ||
| + | |||
| + | - Copy the entire line by pressing '' | ||
| + | - Paste the line by pressing '' | ||
| + | |||
| + | ===== 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 ===== | ||
| + | |||
| + | < | ||
| + | : | ||
| + | </ | ||
| + | |||
| + | Complex replace with reference: | ||
| + | < | ||
| + | : | ||
| + | </ | ||
| + | |||
| + | to repeat, press ":", | ||
| + | |||
linux/vi.1577550525.txt.gz · Last modified: (external edit)