Skip to content

Commit

Permalink
Update the chapter headings
Browse files Browse the repository at this point in the history
  • Loading branch information
iggredible committed May 29, 2021
1 parent 7443ffb commit f5712e6
Show file tree
Hide file tree
Showing 28 changed files with 120 additions and 120 deletions.
4 changes: 2 additions & 2 deletions ch00_read_this_first.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You can go far using Vim without knowing any Vimscript, but knowing it will help

This guide is written for both beginner and advanced Vimmers. It starts out with broad and simple concepts and ends with specific and advanced concepts. If you're an advanced user already, I would encourage you to read this guide from start to finish anyway, because you will learn something new!

## How To Transition To Vim From Using A Different Text Editor
## How to Transition to Vim From Using a Different Text Editor

Learning Vim is a satisfying experience, albeit hard. There are two main approaches to learn Vim:

Expand All @@ -39,7 +39,7 @@ Everyone programs differently. Upon introspection, you will find that there are

Once you can edit at 50% of the original speed, it's time to go full-time Vim.

## How To Read This Guide
## How to Read This Guide

This is a practical guide. To become good in Vim you need to develop your muscle memory, not head knowledge.

Expand Down
4 changes: 2 additions & 2 deletions ch01_starting_vim.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ There are several ways to exit Vim. The most common one is to type:

You can type `:q` for short. That command is a command-line mode command (another one of Vim modes). If you type `:` in normal mode, the cursor will move to the bottom of the screen where you can type some commands. You will learn about the command-line mode later in chapter 15. If you are in insert mode, typing `:` will literally produce the character ":" on the screen. In this case, you need to switch back to normal mode. Type `<Esc>` to switch to normal mode. By the way, you can also return to normal mode from command-line mode by pressing `<Esc>`. You will notice that you can "escape" out of several Vim modes back to normal mode by pressing `<Esc>`.

## Saving A File
## Saving a File

To save your changes, type:

Expand Down Expand Up @@ -159,7 +159,7 @@ vim -O5 hello1.txt hello2.txt

If you need to suspend Vim while in the middle of editing, you can press `Ctrl-z`. You can also run either the `:stop` or `:suspend` command. To return to the suspended Vim, run `fg` from the terminal.

## Starting Vim The Smart Way
## Starting Vim the Smart Way

You can pass the `vim` command with different options and flags, just like any terminal commands. One of the options is the command-line command (`+{cmd}` or `-c cmd`). As you learn more commands throughout this guide, see if you can apply it on start. Also being a terminal command, you can combine `vim` with many other terminal commands. For example, you can redirect the output of the `ls` command to be edited in Vim with `ls -l | vim -`.

Expand Down
4 changes: 2 additions & 2 deletions ch02_buffers_windows_tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ To start Vim with multiple tabs, you can do this from the terminal:
vim -p file1.js file2.js file3.js
```

## Moving In 3D
## Moving in 3D

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

Moving between buffers is like traveling across the Z axis in a Cartesian coordinate. Imagine your buffer files lining up across the Z axis. You can traverse the Z axis one buffer at a time with `:bnext` and `:bprevious`. You can jump to any coordinate in Z axis with `:buffer filename/buffernumber`.

You can move in *three-dimensional space* by combining window and buffer movements. You can move to the top, right, bottom, or left window (X-Y navigations) with window navigations. Since each window contains buffers, you can move forward and backward (Z navigations) with buffer movements.

## Using Buffers, Windows, and Tabs The Smart Way
## Using Buffers, Windows, and Tabs the Smart Way

You have learned what buffers, windows, and tabs are and how they work in Vim. Now that you understand them better, you can use them in your own workflow.

Expand Down
12 changes: 6 additions & 6 deletions ch03_searching_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The goal of this chapter is to introduce you to how to search quickly in Vim. Be

This chapter is divided into two parts: how to search without plugins and how to search with [fzf.vim](https://github.com/junegunn/fzf.vim) plugin. Let's get started!

## Opening And Editing Files
## Opening and Editing Files

To open a file in Vim, you can use `:edit`.

Expand Down Expand Up @@ -59,7 +59,7 @@ Autocomplete also works with `:find`:

You may notice that `:find` looks like `:edit`. What's the difference?

## Find And Path
## Find and Path

The difference is that `:find` finds file in `path`, `:edit` doesn't. Let's learn a little bit about this `path`. Once you learn how to modify your paths, `:find` can become a powerful searching tool. To check what your paths are, do:

Expand Down Expand Up @@ -111,7 +111,7 @@ You might be thinking to add the entire project directories so when you press `t

You can add the `set path+={your-path-here}` in your vimrc. Updating `path` takes only a few seconds and doing this will save you a lot of time.

## Searching In Files With Grep
## Searching in Files With Grep

If you need to find in files (find phrases in files), you can use grep. Vim has two ways of doing that:

Expand Down Expand Up @@ -260,7 +260,7 @@ Since you will be using this command frequently, it is good to have this mapped.
nnoremap <silent> <C-f> :Files<CR>
```

## Finding In Files
## Finding in Files

To search inside files, you can use the `:Rg` command.

Expand Down Expand Up @@ -309,7 +309,7 @@ You might wonder, "Well, this is nice but I never used `:grep` in Vim, plus can'

That is a very good question. You may need to use `:grep` in Vim to do search and replace in multiple files, which I will cover next.

## Search And Replace In Multiple Files
## Search and Replace in Multiple Files

Modern text editors like VSCode makes it very easy to search and replace a string across multiple files. In this section, I will show you two different methods to easily do that in Vim.

Expand All @@ -332,7 +332,7 @@ The second method is to search and replace in select files. With this method, yo
3. Select all files you want to perform search-and-replace on. To select multiple files, use `<Tab>` / `<Shift-Tab>`. This is only possible if you have the multiple flag (`-m`) in `FZF_DEFAULT_OPTS`.
4. Run `:bufdo %s/pizza/donut/g | update`. The command `:bufdo %s/pizza/donut/g | update` looks similar to the earlier `:cfdo %s/pizza/donut/g | update` command. The difference is instead of substituting all quickfix entries (`:cfdo`), you are substituting all buffer entries (`:bufdo`).

## Learn Search The Smart Way
## Learn Search the Smart Way

Searching is the bread-and-butter of text editing. Learning how to search well in Vim will improve your text editing workflow significantly.

Expand Down
8 changes: 4 additions & 4 deletions ch04_vim_grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ It is easy to get intimidated by the complexity of Vim commands. If you see a Vi

This is the most important chapter in the entire guide. Once you understand the underlying grammatical structure, you will be able to "speak" to Vim. By the way, when I say *Vim language* in this chapter, I am not talking about Vimscript language (Vim's built-in programming language, you will learn that in later chapters).

## How To Learn A Language
## How to Learn a Language

I am not a native English speaker. I learned English when I was 13 when I moved to the US. There are three things you need to do to learn to speak a new language:

Expand Down Expand Up @@ -60,7 +60,7 @@ c Delete text, save to register, and start insert mode

Btw, after you yank a text, you can paste it with `p` (after the cursor) or `P` (before the cursor).

## Verb And Noun
## Verb and Noun

Now that you know basic nouns and verbs, let's apply the grammar rule, verb + noun! Suppose you have this expression:

Expand Down Expand Up @@ -152,7 +152,7 @@ t XML tags

To learn more, check out `:h text-objects`.

## Composability And Grammar
## Composability and Grammar

Vim grammar is subset of Vim's composability feature. Let's discuss composability in Vim and why this is a great feature to have in a text editor.

Expand Down Expand Up @@ -201,7 +201,7 @@ This composable behavior echoes Unix philosophy: *do one thing well*. An operato

Motions and operators are extendable. You can create custom motions and operators to add to your Vim toolbelt. The [`vim-textobj-user`](https://github.com/kana/vim-textobj-user) plugin allows you to create your own text objects. It also contains a [list](https://github.com/kana/vim-textobj-user/wiki) of user-made custom text objects.

## Learn Vim Grammar The Smart Way
## Learn Vim Grammar the Smart Way

You just learned about Vim grammar's rule: `verb + noun`. One of my biggest Vim "AHA!" moments was when I had just learned about the uppercase (`gU`) operator and wanted to uppercase the current word, I *instinctively* ran `gUiw` and it worked! The word was uppercased. At that moment, I finally began to understand Vim. My hope is that you will have your own "AHA!" moment soon, if not already.

Expand Down
6 changes: 3 additions & 3 deletions ch05_moving_in_file.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ch05. Moving In A File
# Ch05. Moving in a File

In the beginning, moving with a keyboard feels slow and awkward but don't give up! Once you get used to it, you can go anywhere in a file faster than using a mouse.

Expand Down Expand Up @@ -118,7 +118,7 @@ const hello = "world";

With your cursor at the start of the line, you can go to the last character in current line (";") with one keypress: `$`. If you want to go to "w" in "world", you can use `fw`. A good tip to go anywhere in a line is to look for least-common-letters like "j", "x", "z" near your target.

## Sentence And Paragraph Navigation
## Sentence and Paragraph Navigation

Next two navigation units are sentence and paragraph.

Expand Down Expand Up @@ -338,7 +338,7 @@ For more, check out `:h jump-motions`.

Why are jumps useful? Because you can navigate the jump list with `Ctrl-O` to move up the jump list and `Ctrl-I` to move down the jump list. You can jump across different files, which I will discuss more in the next part.

## Learn Navigation The Smart Way
## Learn Navigation the Smart Way

If you are new to Vim, this is a lot to learn. I do not expect anyone to remember everything immediately. It takes time before you can execute them without thinking.

Expand Down
10 changes: 5 additions & 5 deletions ch06_insert_mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Insert mode is the default mode of many text editors. In this mode, what you typ

However, that does not mean there isn't much to learn. Vim's insert mode contains many useful features. In this chapter, you will learn how to use these insert mode features in Vim to improve your typing efficiency.

## Ways To Go To Insert Mode
## Ways to Go to Insert Mode

There are many ways to get into insert mode from the normal mode. Here are some of them:

Expand All @@ -23,7 +23,7 @@ gI Insert text at the start of line (column 1)

Notice the lowercase / uppercase pattern. For each lowercase command, there is an uppercase counterpart. If you are new, don't worry if you don't remember the whole list above. Start with `i` and `o`. They should be enough to get you started. Gradually learn more over time.

## Different Ways To Exit Insert Mode
## Different Ways to Exit Insert Mode

There are a few different ways to return to the normal mode while in the insert mode:

Expand Down Expand Up @@ -52,7 +52,7 @@ You can pass a count parameter before entering insert mode. For example:

If you type "hello world!" and exit insert mode, Vim will repeat the text 10 times. This will work with any insert mode method (ex: `10I`, `11a`, `12o`).

## Deleting Chunks In Insert Mode
## Deleting Chunks in Insert Mode

When you make a typing mistake, it can be cumbersome to type `<Backspace>` repeatedly. It may make more sense to go to normal mode and delete your mistake. You can also delete several characters at a time while in insert mode.

Expand Down Expand Up @@ -120,7 +120,7 @@ In general, Vim looks at the text in all available buffers for autocompletion so

Autocomplete is a vast topic in Vim. This is just the tip of the iceberg. To learn more, check out `:h ins-completion`.

## Executing A Normal Mode Command
## Executing a Normal Mode Command

Did you know Vim can execute a normal mode command while in insert mode?

Expand Down Expand Up @@ -154,7 +154,7 @@ Ctrl-O dtz Delete from current location till the letter "z"
Ctrl-O D Delete from current location to the end of the line
```

## Learn Insert Mode The Smart Way
## Learn Insert Mode the Smart Way

If you are like me and you come from another text editor, it can be tempting to stay in insert mode. However, staying in insert mode when you're not entering a text is an anti-pattern. Develop a habit to go to normal mode when your fingers aren't typing new texts.

Expand Down
8 changes: 4 additions & 4 deletions ch07_the_dot_command.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ch07. The Dot Command
# Ch07. the Dot Command

In general, you should try to avoid redoing what you just did whenever possible. In this chapter, you will learn how to use the dot command to easily redo the previous change. It is a versatile command for reducing simple repetitions.

Expand All @@ -22,7 +22,7 @@ let three = "3";

Here the dot command repeated the `cwconst<Esc>` sequence. It saved you from typing eight keystrokes in exchange for just one.

## What Is A Change?
## What Is a Change?

If you look at the definition of the dot command (`:h .`), it says that the dot command repeats the last change. What is a change?

Expand Down Expand Up @@ -94,7 +94,7 @@ Let's remove all the z's. Starting from the first character on the first line, v

When you deleted a column of three z's (`Ctrl-vjjd`), it was counted as a change. Visual mode operation can be used to target multiple lines as part of a change.

## Including A Motion In A Change
## Including a Motion in a Change

Let's revisit the first example in this chapter. Recall that the command `/letcwconst<Esc>` followed by `n . n .` replaced all "let" with "const" in the following expressions:

Expand All @@ -110,7 +110,7 @@ There is a faster way to accomplish this. After you searched `/let`, run `cgncon

When you are editing, always be on the lookout for motions that can do several things at once like `gn` whenever possible.

## Learn The Dot Command The Smart Way
## Learn the Dot Command the Smart Way

The dot command's power comes from exchanging several keystrokes for one. It is probably not a profitable exchange to use the dot command for single key operations like `x`. If your last change requires a complex operation like `cgnconst<Esc>`, the dot command reduces nine keypresses into one, a very profitable trade-off.

Expand Down
14 changes: 7 additions & 7 deletions ch08_registers.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Ctrl-R a
Where `a` is the register symbol. Now that you know how to store and retrieve registers, let's dive in!


## The Unnamed Register
## The Unnamed Register

To get the text from the unnamed register, do `""p`. It stores the last text you yanked, changed, or deleted. If you do another yank, change, or delete, Vim will automatically replace the old text. The unnamed register is like a computer's standard copy / paste operation.

Expand Down Expand Up @@ -144,7 +144,7 @@ To get the text from register a, run `"ap`. You can use all twenty-six alphabeti

Sometimes you may want to add to your existing named register. In this case, you can append your text instead of starting all over. To do that, you can use the uppercase version of that register. For example, suppose you have the word "Hello " already stored in register a. If you want to add "world" into register a, you can find the text "world" and yank it using A register (`"Ayiw`).

## The Read-Only Registers
## The Read-only Registers

Vim has three read-only registers: `.`, `:`, and `%`. They are pretty simple to use:

Expand Down Expand Up @@ -218,35 +218,35 @@ The black hole register is like the `/dev/null` of registers.

To paste your last search (`/` or `?`), you can use the last search pattern register (`"/`). To paste the last search term, use `"/p`.

## Viewing The Registers
## Viewing the Registers

To view all your registers, use the `:register` command. To view only registers "a, "1, and "-, use `:register a 1 -`.

There is a plugin called [vim-peekaboo](https://github.com/junegunn/vim-peekaboo) that lets you to peek into the contents of the registers when you hit `"` or `@` in normal mode and `Ctrl-R` in insert mode. I find this plugin very useful because most times, I can't remember the content in my registers. Give it a try!

## Executing A Register
## Executing a Register

The named registers are not just for storing texts. They can also execute macros with `@`. I will go over macros in the next chapter.

Keep in mind since macros are stored inside Vim registers, you can accidentally overwrite the stored text with macros. If you store the text "Hello Vim" in register a and you later record a macro in the same register (`qa{macro-sequence}q`), that macro will overwrite your "Hello Vim" text stored earlier.

## Clearing A Register
## Clearing a Register

Technically, there is no need to clear any register because the next text that you store under the same register name will overwrite it. However, you can quickly clear any named register by recording an empty macro. For example, if you run `qaq`, Vim will record an empty macro in the register a.

Another alternative is to run the command `:call setreg('a', 'hello register a')` where a is the register a and "hello register a" is the text that you want to store.

One more way to clear register is to set the content of "a register to an empty string with the expression `:let @a = ''`.

## Putting The Content Of A Register
## Putting the Content of a Register

You can use the `:put` command to paste the content of any one register. For example, if you run `:put a`, Vim will print the content of register a below the current line. This behaves much like `"ap`, with the difference that the normal mode command `p` prints the register content after the cursor and the command `:put` prints the register content at newline.

Since `:put` is a command-line command, you can pass it an address. `:10put a` will paste text from register a to below line 10.

One cool trick to pass `:put` with the black hole register (`"_`). Since the black hole register does not store any text, `:put _` will insert a blank line instead. You can combine this with the global command to insert multiple blank lines. For example, to insert blank lines below all lines that contain the text "end", run `:g/end/put _`. You will learn about the global command later.

## Learning Registers The Smart Way
## Learning Registers the Smart Way

You made it to the end. Congratulations! If you are feeling overwhelmed by the sheer information, you are not alone. When I first started learning about Vim registers, there were way too much information to take at once.

Expand Down
Loading

0 comments on commit f5712e6

Please sign in to comment.