This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:vi [2018/01/26 17:13] – [Useful Commands] tmade | linux:vi [2026/04/07 16:08] (current) – [Visual Mode] tmade | ||
|---|---|---|---|
| Line 12: | Line 12: | ||
| \> #A word ends with | \> #A word ends with | ||
| :set hlsearch | :set hlsearch | ||
| - | % #Jump to closing bracket | + | % #Jump to closing bracket, when curser is on " |
| + | # #Jump to function, when curser is on function or where the function is called (and vice versa) | ||
| | | ||
| ==== Edit ==== | ==== Edit ==== | ||
| Line 27: | Line 28: | ||
| ct" | ct" | ||
| . #Repeat last command/ insert etc. | . #Repeat last command/ insert etc. | ||
| - | | + | :%d #Clear all lines |
| ==== Replace ==== | ==== Replace ==== | ||
| Line 51: | Line 52: | ||
| :w !sudo tee % #Save file with sudo rights | :w !sudo tee % #Save file with sudo rights | ||
| :wq !sudo tee % #Save and quit file with sudo rights | :wq !sudo tee % #Save and quit file with sudo rights | ||
| + | :set paste #to avoid linefeeds by pasting code | ||
| + | :set nopaste | ||
| + | :syntax on | ||
| + | :syntax off # | ||
| | | ||
| + | ====Visual Mode==== | ||
| + | If you can´t enter text with putty and right mouse click, set | ||
| + | set mouse-=a | ||
| + | in file | ||
| + | ~/.vimrc | ||
| + | |||
| + | or | ||
| + | |||
| + | :set mouse= | ||
| + | | ||
| + | inside VI. | ||
| + | | ||
| + | Adapt to it - with mouse mode turned on, the new way to paste is | ||
| + | shift-right-click | ||
| + | |||
| + | ====Multi-edit==== | ||
| + | To edit various lines: | ||
| + | |||
| + | - strg +v | ||
| + | - mark all lines with arrow up/ down | ||
| + | - press " | ||
| + | - press tab or space | ||
| + | - escape | ||
| + | | ||
| + | |||
| + | |||
| | | ||