Correct words

This commit is contained in:
Shohei YOSHIDA 2020-08-27 23:04:09 +09:00
parent 2458c6c1e4
commit 5e108cc287
7 changed files with 11 additions and 11 deletions

View file

@ -1,7 +1,7 @@
# Search and Substitute
This chapter covers two separate but related concepts: search and substitute. Many times, the texts that you are searching for are not straightforward and you must search for a common pattern. By learning how to use meaningful patterns in search and substitute instead of literal strings, you will be able to target any text quickly.
As a side note, in this chapter, I will mainly use `/` when talking about search. Eveything you can do with `/` can also be done with `?`.
As a side note, in this chapter, I will mainly use `/` when talking about search. Everything you can do with `/` can also be done with `?`.
# Smart Case Sensitivity
@ -274,7 +274,7 @@ three let = "3";
four let = "4";
five let = "5";
```
You neeed to swap all the "let" with the variable names. To do that, run:
You need to swap all the "let" with the variable names. To do that, run:
```
:%s/\(\w\+\) \(\w\+\)/\2 \1/
@ -389,7 +389,7 @@ If you need to replace a URL with a long path:
https://mysite.com/a/b/c/d/e
```
To suibstitute it with the word "hello", run:
To substitute it with the word "hello", run:
```
:s/https:\/\/mysite.com\/a\/b\/c\/d\/e/hello/
```

View file

@ -111,7 +111,7 @@ Ctrl-W o Makes the current window the only one on screen and closes other win
And here is a list of useful window Ex commands:
```
:vsplit filename Split window vertically
:split filename Split window horiontally
:split filename Split window horizontally
:new filename Create new window
```
@ -163,11 +163,11 @@ Moving between windows is like traveling two-dimensionally along X-Y axis in a C
![cartesian movement in x and y axis](./img/cartesian-xy.png)
Moving between buffers is like travelling across the Z axis in a Cartesian coordinate. Imagine your buffer files are lined 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`.
Moving between buffers is like traveling across the Z axis in a Cartesian coordinate. Imagine your buffer files are lined 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`.
![cartesian movement in z axis](./img/cartesian-z.png)
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 foward and backward (Z navigations) with buffer movements.
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.
![cartesian movement in x, y, and z axis](./img/cartesian-xyz.png)

View file

@ -127,7 +127,7 @@ For example, to look for all occurrences of "foo" string inside all ruby files (
:vim /foo/ app/controllers/**/*.rb
```
After running that command, you will be redirected to the first result. Vim's `vim` search command uses `quickfix` operation. To see all search results, run `:copen`. This opens a `quickfix` window. Here are some useful quickfix commands to get you productive immmediately:
After running that command, you will be redirected to the first result. Vim's `vim` search command uses `quickfix` operation. To see all search results, run `:copen`. This opens a `quickfix` window. Here are some useful quickfix commands to get you productive immediately:
```
:copen Open the quickfix window

View file

@ -6,7 +6,7 @@ This is the most important chapter in the entire book. Once you understand Vim c
# 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. I had to do three things to build up linguistic profiency:
I am not a native English speaker. I learned English when I was 13 when I moved to the US. I had to do three things to build up linguistic proficiency:
1. Learn grammar rules
2. Increase my vocabulary

View file

@ -32,7 +32,7 @@ To my surprise, it only took a few days to get used to using `hjkl`.
*By the way, if you wonder why Vim uses `hjkl` to move, this is because Lear-Siegler ADM-3A terminal where Bill Joy wrote Vi, didn't have arrow keys and used `hjkl` as left/down/up/right.*
If I want to go somewhere close by, like moving from one part of a word to another part of the same word, I would use `h` or `l`. If I want to go up or down a few lines within displayed window, I would use `j` or `k`. If I want to go somewhere farther, I would use a diffferent motion.
If I want to go somewhere close by, like moving from one part of a word to another part of the same word, I would use `h` or `l`. If I want to go up or down a few lines within displayed window, I would use `j` or `k`. If I want to go somewhere farther, I would use a different motion.
# Relative Numbering

View file

@ -101,7 +101,7 @@ When you are editing, always be on the lookout for a motion that can do several
# 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 exchangeto use the dot command for one-keyed-operations like `x`. If your last change requires a complex operation like `cgnconst<esc>`, the dot command reduces nine keypresses into one, a very good trade-off.
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 one-keyed-operations like `x`. If your last change requires a complex operation like `cgnconst<esc>`, the dot command reduces nine keypresses into one, a very good trade-off.
When editing, ask if the action you are about to do is repeatable. For example, if I need to remove the next three words, is it more economical to use `d3w` or to do `dw` then `.` two times? Will you be deleting a word again? If so, then it makes sense to use `dw` and repeat it several times instead of `d3w` because `dw` is more reusable than `d3w`. Keep a "change-driven" mindset while editing.

View file

@ -253,7 +253,7 @@ Running `99@a`, only executes the macro three times. It does not execute the mac
Recall from earlier section that macros can be executed using the command line command `:normal` (ex: `:3,5 normal @a` to execute macro "a" on lines 3-5). If you run `:1,$ normal @a`, you will see that the macro is being executed on all lines except the "foo" line. It works!
Although internally Vim does not actually run the macros in parallel, outwardly, it behaves like such. Vim executes `@a` *independently* on each line from the first line to the last line (`1,$`). Since Vim executes these macros indpendently, each line does not know that one of the macro executions had failed on the "foo" line.
Although internally Vim does not actually run the macros in parallel, outwardly, it behaves like such. Vim executes `@a` *independently* on each line from the first line to the last line (`1,$`). Since Vim executes these macros independently, each line does not know that one of the macro executions had failed on the "foo" line.
# Learn Macros the Smart Way