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