Setup vim » Historie » Version 2
Jeremias Keihsler, 10.10.2023 07:37
1 | 2 | Jeremias Keihsler | h1. basic vim usage |
---|---|---|---|
2 | 1 | Jeremias Keihsler | |
3 | the most vim-style way of getting help for @vim@ is starting vim and entering @:help@ |
||
4 | |||
5 | for doing some basic editing the following sequences should be enough. |
||
6 | |||
7 | One edits a file in @vim@ by issuing the command: |
||
8 | <pre><code class="bash"> |
||
9 | vim file-to-edit |
||
10 | </code></pre> |
||
11 | |||
12 | The vim editor has three modes: |
||
13 | * *command mode* letters or sequence of letters interactively command vim. Commands are case sensitive. The ESC key can end a command. |
||
14 | * *insert mode* Text is inserted. The ESC key ends insert mode and returns you to command mode. One can enter insert mode with the "i" (insert), "a" (insert after), "A" (insert at end of line), "o" (open new line after current line) or "O" (Open line above current line) commands. |
||
15 | * *command line mode* One enters this mode by typing ":" which puts the command line entry at the foot of the screen. |
||
16 | |||
17 | 2 | Jeremias Keihsler | h2. command mode |
18 | 1 | Jeremias Keihsler | |
19 | |_.key |_.action | |
||
20 | |x |delete character under cursor | |
||
21 | |dd |delete current line | |
||
22 | |yy |copy (yank) current line | |
||
23 | |p |paste | |
||
24 | |i |change to @insert@ mode | |
||
25 | |||
26 | h3. insert mode |
||
27 | |||
28 | edit text freely, press @<ESC>@ when you are finished. |
||
29 | |||
30 | 2 | Jeremias Keihsler | h2. command line mode |
31 | 1 | Jeremias Keihsler | |
32 | |_.key |_.action | |
||
33 | | :help<enter> | get help | |
||
34 | | :w<enter> | save | |
||
35 | | :q!<enter> | exit w/o saving | |
||
36 | | :wq<enter> | exit w/ saving | |
||
37 | | :/foo | search for @foo@ forward | |
||
38 | | :?bar | search for @bar@ backward | |
||
39 | | n | after search, go to next occurrence | |
||
40 | | N | after search, go to previous occurrence | |
||
41 | | :%s/foo/bar/gc | replace all @foo@ with @bar@ but ask for confirmation | |