Skip to content

Commit d0364f3

Browse files
author
Igor Irianto
authored
Merge pull request iggredible#7 from djavrell/master
Ch2 - Add some precision about buffer
2 parents 890a6dd + 6d27123 commit d0364f3

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

ch2_buffers_windows_tabs.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
# Buffers, Windows, and Tabs
22

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.
44

55
In this chapter, I will explain how buffers, windows, and tabs work in Vim.
66

77
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`.
88

99
# Buffers
1010

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>`.
1216

1317
```
1418
vim file1.js
1519
```
1620

1721
![one buffer displayed with highlight](./img/screen-one-buffer-file1-highlighted.png)
1822

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.
2024

2125
Exit Vim. This time, open two new files:
2226

@@ -111,7 +115,7 @@ And here is a list of useful window Ex commands:
111115
:new filename Create new window
112116
```
113117

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.
115119

116120
# Tabs
117121

@@ -155,7 +159,7 @@ vim -p file1.js file2.js file3.js
155159
```
156160
# Moving in 3D
157161

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`.
159163

160164
![cartesian movement in x and y axis](./img/cartesian-xy.png)
161165

0 commit comments

Comments
 (0)