vim
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
vim [2024/02/13 00:06] – karcio | vim [2024/07/24 17:53] (current) – karcio | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | [[vimrc|vim config file]] | + | * [[vimrc|vim config file]] |
- | + | * [[vimshortcut|vim shortcuts]] | |
- | {{tag> | + | * [[vimcompile|vim compile]] |
- | + | ||
- | ==== vim shortcuts ==== | + | |
- | + | ||
- | __**vim modes**__ | + | |
- | + | ||
- | * normal mode - " | + | |
- | * insert mode - " | + | |
- | * command mode - ":" | + | |
- | + | ||
- | __**Normal mode**__ | + | |
- | + | ||
- | **h** - move left | + | |
- | + | ||
- | **j** - move down | + | |
- | + | ||
- | **k** - move up | + | |
- | + | ||
- | **l** - move right | + | |
- | + | ||
- | **w** - jump to next word | + | |
- | + | ||
- | **W** - jump to next string | + | |
- | + | ||
- | **b** - jump to previous word | + | |
- | + | ||
- | **B** - jump to previous string | + | |
- | + | ||
- | **0** - move to first position in line | + | |
- | + | ||
- | **$** - move to end of the line | + | |
- | + | ||
- | **z + enter** - move to the top | + | |
- | + | ||
- | **2gg** or **2G** - move to line 2 | + | |
- | + | ||
- | **ctrl g** show how many lines in file | + | |
- | + | ||
- | + | ||
- | __delete__ | + | |
- | + | ||
- | **x** - delete char where cursor is | + | |
- | + | ||
- | **X** - delete char before cursor | + | |
- | + | ||
- | **dw** - __d__ - delete __w__ - motion | + | |
- | + | ||
- | **dl** - delete word on left | + | |
- | + | ||
- | **dk** - delete up line | + | |
- | + | ||
- | **dh** - delete down line | + | |
- | + | ||
- | **dj** - delete word on right | + | |
- | + | ||
- | **d0** - delete all to begin line | + | |
- | + | ||
- | **dd** or **D**- delete line | + | |
- | + | ||
- | **2dd** or **2D**- delete 2 lines | + | |
- | + | ||
- | **5dw** - delete 5 words ( delete word 5 times) | + | |
- | + | ||
- | **3w** - move to third word (repeat word motion 3 times) | + | |
- | + | ||
- | **d3w** - delete 3 words | + | |
- | **2d3w** - delete 3 words 2 times | + | |
- | + | ||
- | **.** - repeat last operation | + | |
- | + | ||
- | + | ||
- | __cut, | + | |
- | + | ||
- | **y** then **p** - copy and paste before cursor | + | |
- | + | ||
- | **y** then **P** - copy and paste after cursor | + | |
- | + | ||
- | **yy** then **p** - copy line and paste | + | |
- | + | ||
- | **v** then **h,j,k,l** to select text, then **p** - select text and paste | + | |
- | + | ||
- | **dd** then **p** - cut line then paste after cursor line | + | |
- | + | ||
- | **dd** then **P** - cut line then paste before cursor line | + | |
- | + | ||
- | ==== How to Map Keyboard Shortcuts in Vim ==== | + | |
- | + | ||
- | In the mapping section we will add shortcuts | + | |
- | + | ||
- | Key mapping syntax is like this: | + | |
- | + | ||
- | < | + | |
- | map_mode < | + | |
- | </ | + | |
- | + | ||
- | ===== Popular Mapping Modes in Vim ===== | + | |
- | + | ||
- | Here are a few popular mapping modes and probably the most useful and important. | + | |
- | < | + | |
- | nnoremap – Allows you to map keys in normal mode. | + | |
- | inoremap – Allows you to map keys in insert mode. | + | |
- | vnoremap – Allows you to map keys in visual mode. | + | |
- | </ | + | |
- | + | ||
- | ===== Comment out Multiple Lines ===== | + | |
- | + | ||
- | | + | |
- | - Press the **Ctrl + V** keys to enable visual mode. | + | |
- | - Select all the lines you wish to comment out using the **up** and **down** arrow keys or the letters **k** and **j**. | + | |
- | - Vim will insert a highlight at each line’s beginning to indicate the selected line | + | |
- | - With the target lines selected, press **Shift + I** to enter insert mode. | + | |
- | - Enter the comment symbol for the target file. In this case, must insert the pound (#) symbol to comment Python code. | + | |
- | - Press the ESC key, and Vim will comment out all the selected lines. | + | |
- | + | ||
- | ===== Uncomment Multiple Lines ===== | + | |
- | + | ||
- | - Start by navigating to the line you wish to uncomment, then press **Ctrl + V** to activate the visual block mode. | + | |
- | - Select all the lines you want to uncomment using the **up** and **down** arrow keys or the letters **k** and **j**. | + | |
- | - Once your lines are selected, press the **X** key to remove the comments. | + | |
+ | {{tag> | ||
vim.1707782793.txt.gz · Last modified: 2024/02/13 00:06 by karcio