1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
# Vim is Modal
<h6>Logan</h6>
- Hopefully you've done the [Quick Start](intro.md) and are ready to learn more about Vim. Here we will go over some of the concepts behind Vim.
Vim is "modal", meaning that how one interacts with the editor is dependant on the current mode. In other words, modes can be likened to "states", and the state Vim is in determines what actions are available to the user.
This documentation will cover three such "modes": Normal Mode, Insert Mode, and Visual Mode.
The current mode, if it is not normal mode, is displayed in the bottom left corner:

## Insert Mode
<h6>Tyler</h6>
Insert mode is the mode in which text is entered into the document. In this mode, the keyboard is interpreted as text input, and the text cursor is visible.
Common ways of entering insert mode are listed below.
| Command | Description |
| ------- | --------------------------------------------- |
| `i` | Insert before the cursor |
| `I` | Insert at the beginning of the line |
| `a` | Append after the cursor |
| `A` | Append at the end of the line |
| `o` | Create a new line below the cursor and insert |
| `O` | Create a new line above the cursor and insert |
## Visual Mode
<h6>Authored by Alaina D</h6>
Visual mode is the mode in which text is selected. In this mode, the text cursor is visible, and the text is highlighted. To enter visual mode, press `v` while in Normal mode (hint: to switch to normal mode, hit `ESC`--then press `v` to get to Visual mode).
In Visual mode, you may highlight text (using your cursor, of course) by navigating around within your file. While you are in visual mode, Vim will highlight the text that is currently selected. For this reason, Visual mode is very useful for selecting multiple words, lines, or paragraphs of text. You can even select the entire file's text in Visual mode, if you would like to.
While Vim is in Visual mode, text will become selected as you move your cursor around the document. Vim will automatically highlight the selected text, which makes it easier (in real-time) for you to see which text you are selecting.

If you would like to deslect your text, hit `ESC` to go back to Normal mode, navigate your cursor to your desired location, and then re-enter visual mode by pressing `v`.
### Navigation in Visual Mode
In Visual mode, you are free to navigate Vim similar to how you navigate in Normal mode. Below this paragraph, you will find a table of helpful navigation commands in Vim (the commands work the same in normal mode and in Visual mode).
#### Simple Navigation
| Command | Description |
| ------- | ----------------------------------------- |
| `h` | `(←)` Move the cursor left one character |
| `j` | `(↓)` Move the cursor down one line |
| `k` | `(↑)` Move the cursor up one line |
| `l` | `(→)` Move the cursor right one character |
#### Word-By-Word Navigation/By-Character Navigation
| Command | Description |
| ------- | -------------------------------------------------------------------------------------------------------------------- |
| `w` | Move the cursor to the beginning of the next word |
| `e` | Move the cursor to the end of the next word |
| `b` | Move the cursor to the beginning of the previous word |
| `4j` | Move the cursor down 4 lines (you may combine any number with j or k to move up \_\_\_ number of lines |
| `3h` | Move the cursor to the left 3 characters (you may combine any number with h or l to move \_\_\_ number of characters |
#### Multi-line Navigation/Line-By-Line Navigation
| Command | Description |
| ----------- | -------------------------------------------------------------------------------------------------------------------- |
| `0` | Move the cursor to the beginning of the line |
| `$` | Move the cursor to the end of the line |
| `^` | Move the cursor to the first non-whitespace character of the line |
| `SHIFT + g` | Move the cursor to the end of the file |
| `gg` | Move the cursor to the beginning of the file |
| `4j` | Move the cursor down 4 lines (you may combine any number with j or k to move up \_\_\_ number of lines |
| `3h` | Move the cursor to the left 3 characters (you may combine any number with h or l to move \_\_\_ number of characters |
#### Deleting Text in Visual Mode
To delete your selected block of text, first enter visual mode using `v` (as mentioned above). Once you have selected the text that you would like to delete, press `d` for delete. When you press `d`, the section of text which you have selected will be deleted. If you would like to undo your deletion, press `u` to undo.
**NOTE: when you use `d` to delete text, Vim will automatically return to Normal mode (this means that you will need to press `v` to get back to Visual mode)**
#### Copy/Paste Text Using Visual Mode
To copy text in Visual mode, you must first enter Visual mode (using `v`, as mentioned above). You will then select your desired block of text by moving your cursor over the desired text. Once you have selected the text that you want to copy, press 'y' to copy the text. Once you have copied your selected text, you may return to normal mode and use `SHIFT + p` or `p` to paste your desired text (`SHIFT + p` will paste text _before_ your cursor, while `p` will paste text _after_ your cursor). Please note that the text will be pasted wherever your cursor happens to be at the moment.
**NOTE: when you use `y` to copy (yank) text, Vim will automatically return to Normal mode (this means that you will need to press `v` to get back to Visual mode)**
## Normal mode
<h6>Logan</h6>
Normal mode is the default mode when Vim is first run, and the mode which a user will spend most of their time, as it is the "main" mode; a user enters other modes through Normal mode, and exiting those modes brings the users back to Normal mode. such as navigating text, delete and yank (vim-ology for "cut" and "paste") text, and changing into other .
Normal mode is also the mode in which a user enters other modes, such as Insert Mode and Visual Mode. When in any other mode, a user can always go back to Normal mode by pressing the `<Esc>` key.
### Cursor Movement
In normal mode, no keyboard input is interpreted as text input. Instead, the keyboard is used to move the text cursor around the document.
As an example, the text cursor can be moved using the `h`, `j`, `k`, and `l` keys. These keys are the most efficient way to navigate the cursor due to their placement on the homerow.
Note that this collection is not exhaustive, but rather a collection of the most common and useful commands. For a full list of commands, see this [Vim Cheat Sheet](https://vim.rtorr.com/).
#### The Essentials
| Command | Description |
| ------- | ----------------------------------------- |
| `h` | `(←)` Move the cursor left one character |
| `j` | `(↓)` Move the cursor down one line |
| `k` | `(↑)` Move the cursor up one line |
| `l` | `(→)` Move the cursor right one character |

#### By Word
| Command | Description |
| ------- | ----------------------------------------------------- |
| `w` | Move the cursor to the beginning of the next word |
| `e` | Move the cursor to the end of the next word |
| `b` | Move the cursor to the beginning of the previous word |

#### By Line
| Command | Description |
| ------- | ----------------------------------------------------------------- |
| `0` | Move the cursor to the beginning of the line |
| `$` | Move the cursor to the end of the line |
| `^` | Move the cursor to the first non-whitespace character of the line |

### Actions
"Actions" in normal mode are commands that perform some sort of action on the text. These can be anything from deleting text to toggling the case of some text.
Typically there are two parts of a action in normal mode: the "operator" and a (sometimes optional) "motion". The operator is the action to be performed, and the motion is the text to perform the action on.
For example, with the command `d` as the "delete" operator, and the motion `w` as the "forward word" motion, together, form the command `dw`. This would delete any text under the cursor until the end of the word.
#### Repeating
In normal mode, actions and movements can be repeated by prefixing them with a number. For example, `3j` will move the cursor down three lines, and `10w` would go forward ten words.

#### Cut/Copy & Paste
The action of copying a piece of text and pasting it somewhere else is a very common task in text editing, and Vim has a few ways to do this. Though, Vim uses the terminology "yank" and "put" instead of "copy" and "paste".
1. To yank (or copy) text, the `y` operator is used in conjunction with a motion.
2. To cut text, the `d` operator is used in conjunction with a motion.
3. To put (or paste) text, the `p` operator is used. This operator puts the text that was last yanked or cut at the cursor.
A specific property exists on the yank and cut operators: repeating them will yank or cut the entire line. For example, `yy` will yank the entire line, and `dd` will cut the entire line.
Therefore, the following are all examples of valid commands:
| Command | Description |
| ------- | ----------------------------------------------------------------- |
| `yy` | Yank (copy) the entire line |
| `dd` | Cut (delete) the entire line |
| `y$` | Yank (copy) from the cursor to the end of the line |
| `dw` | Cut (delete) the word under the cursor |
| `p` | Put (paste) the text that was last yanked or cut after the cursor |

_Examples of the `d` and `y` operators, and repeating actions_
#### Searching
Vim has a built-in search feature that allows users to search for text in the document. The search feature is accessed by pressing the `/` key, and the search term is entered after the `/` key.

#### Replacing Text
Vim also has a powerful search and replace feature which can accessed via the `:%s` command.
The `:%s` command is similar the `sed` UNIX utility (see [this](https://unix.stackexchange.com/questions/159367/using-sed-to-find-and-replace) stackexchange post as a quick example of the syntax) and takes two regex joined by forward slashes: the first is the text to search for, and the second is the text to replace it with. For example, `:%s/foo/bar/` will replace the first instance of `foo` with `bar` in the document.

# Making Vim Your Own: Installing Plugins
<h6>Eric</h6>
While Vim in it's own element can be a powerful tool, it is still just a text editor. Plugins can be installed to customize and improve the Vim editor, and add more functionality that Vim doesn't have on it's own. Vim version 8+ is required, and you can check by launching Vim.

Vim looks in a specific directory, ~/.vim/pack/[whatever you want]/start.
If this PATH doesn't exist, create one using the `mkdir` command in the terminal, or navigating to the directory in your file manager, and put any downloaded packages inside of it.

Terminal file structure

Manager file structure
Vim will find them at boot, and they will be applied when it is launched. You can find packages anywhere on the internet, in the form of zipped folders, repositories, etc. A great website to find ones is [Vim Awesome](https://vimawesome.com).
|