|
1 | 1 | # Buffers, Windows, and Tabs |
2 | 2 |
|
3 | | -If you have used a modern text editor, you are probably familiar with windows and tabs. Vim has three abstractions instead of two: buffers, windows, and tabs. |
| 3 | +If you have used a modern text editor, you are probably familiar with windows and tabs. Vim has three abstractions instead of two: buffers, windows, and tabs. |
4 | 4 |
|
5 | 5 | In this chapter, I will explain how buffers, windows, and tabs work in Vim. |
6 | 6 |
|
7 | 7 | Before you start, make sure you have `set hidden` option in your `vimrc`. Without this, whenever you switch buffers, Vim will prompt you to save the file (you don't want that if you want to move quickly between buffers). For more information, check out `:h hidden`. |
8 | 8 |
|
9 | 9 | # Buffers |
10 | 10 |
|
11 | | -A buffer is the in-memory text of a file. When you open a file in Vim, it creates a new buffer. From your terminal, open a new file `file1.js`: |
| 11 | +A buffer is a in-memory space where you can write and edit some text. When you are opening a new file in vim its content will be bound to a new buffer: |
| 12 | + 1. From within vim, open a new buffer `:new` (create a new empty buffer) |
| 13 | + 2. From your terminal, open a new file `file1.js` (create a new buffer with `file1.js` bind to it) |
| 14 | + |
| 15 | +If your buffer isn't bound to a file yet but you want to save its content, you can save it with `:w </path/to/file>`. |
12 | 16 |
|
13 | 17 | ``` |
14 | 18 | vim file1.js |
15 | 19 | ``` |
16 | 20 |
|
17 | 21 |  |
18 | 22 |
|
19 | | -What you are seeing is `file1.js` *buffer*. Whenever we open a new file, Vim creates a new buffer. |
| 23 | +What you are seeing is `file1.js` *buffer*. Whenever we open a new file, Vim creates a new buffer. |
20 | 24 |
|
21 | 25 | Exit Vim. This time, open two new files: |
22 | 26 |
|
@@ -111,7 +115,7 @@ And here is a list of useful window Ex commands: |
111 | 115 | :new filename Create new window |
112 | 116 | ``` |
113 | 117 |
|
114 | | -For more, check out `:h window`. Take your time to understand them. |
| 118 | +For more, check out `:h window`. Take your time to understand them. |
115 | 119 |
|
116 | 120 | # Tabs |
117 | 121 |
|
@@ -155,7 +159,7 @@ vim -p file1.js file2.js file3.js |
155 | 159 | ``` |
156 | 160 | # Moving in 3D |
157 | 161 |
|
158 | | -Moving between windows is like traveling two-dimensionally along X-Y axis in a Cartesian coordinate. You can move to the top, right, bottom, and left window with `Ctrl-W h/j/k/l`. |
| 162 | +Moving between windows is like traveling two-dimensionally along X-Y axis in a Cartesian coordinate. You can move to the top, right, bottom, and left window with `Ctrl-W h/j/k/l`. |
159 | 163 |
|
160 | 164 |  |
161 | 165 |
|
|
0 commit comments