mirror of
https://github.com/iggredible/Learn-Vim
synced 2024-11-14 18:12:49 +00:00
commit
56874078e7
@ -45,7 +45,7 @@ This is a practical guide. To become good in Vim you need to develop your muscle
|
|||||||
|
|
||||||
You don't learn how to ride a bike by reading a guide about how to ride a bike. You need to actually ride a bike.
|
You don't learn how to ride a bike by reading a guide about how to ride a bike. You need to actually ride a bike.
|
||||||
|
|
||||||
You need to type along every commands referred in this guide. Not only that, but you need to repeat them several times and try different combinations. Look up what other features the command you just learned has. The `:help` command and Google are your best friends. Your goal is not to know everything about a command, but to be able to execute that command naturally and instinctively.
|
You need to type along every commands referred in this guide. Not only that, but you need to repeat them several times and try different combinations. Look up what other features the command you just learned has. The `:help` command and search engines are your best friends. Your goal is not to know everything about a command, but to be able to execute that command naturally and instinctively.
|
||||||
|
|
||||||
As much as I try to fashion this guide to be linear, some concepts in this guide have to be presented out-of-order. For example in chapter 1, I mention the substitute command (`:s`), even though it won't be covered until chapter 12. To remedy this, whenever a new concept that has not been covered yet is mentioned early, I will provide a quick how-to guide without a detailed explanation. So please bear with me :).
|
As much as I try to fashion this guide to be linear, some concepts in this guide have to be presented out-of-order. For example in chapter 1, I mention the substitute command (`:s`), even though it won't be covered until chapter 12. To remedy this, whenever a new concept that has not been covered yet is mentioned early, I will provide a quick how-to guide without a detailed explanation. So please bear with me :).
|
||||||
|
|
||||||
|
@ -366,5 +366,3 @@ By default, Vim saves the fold information when running `mkview` inside `~/.vim/
|
|||||||
When I first started Vim, I neglected ot learn fold because I didn't think it was useful. However, the longer I code, the more useful I find folding is. Strategically placed folds can give you a better overview of the text structure, like a book's table of content.
|
When I first started Vim, I neglected ot learn fold because I didn't think it was useful. However, the longer I code, the more useful I find folding is. Strategically placed folds can give you a better overview of the text structure, like a book's table of content.
|
||||||
|
|
||||||
When you learn fold, start with the manual fold because that can be used on-the-go. Then gradually learn different tricks to do indent and marker folds. Finally, learn how to do syntax and expression folds. You can even use the latter two to write your own Vim plugins.
|
When you learn fold, start with the manual fold because that can be used on-the-go. Then gradually learn different tricks to do indent and marker folds. Finally, learn how to do syntax and expression folds. You can even use the latter two to write your own Vim plugins.
|
||||||
|
|
||||||
Next, let's version control with git.
|
|
||||||
|
10
ch18_git.md
10
ch18_git.md
@ -57,7 +57,7 @@ vim -d file1.txt file2.txt
|
|||||||
Suppose you want to make the second buffer to have apples, not oranges. To transfer the content from your current position (you're currently on `file1.txt`) to `file2.txt`, first go to the next diff with `]c` (to jump to the previous diff window, use `[c`). The cursor should be on apples now. Run `:diffput`. Both files should now have apples.
|
Suppose you want to make the second buffer to have apples, not oranges. To transfer the content from your current position (you're currently on `file1.txt`) to `file2.txt`, first go to the next diff with `]c` (to jump to the previous diff window, use `[c`). The cursor should be on apples now. Run `:diffput`. Both files should now have apples.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="Finding files in FZF" width="900" height="auto" src="images/diffing-apples.png">
|
<img alt="Diffing Apples" width="900" height="auto" src="images/diffing-apples.png">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
If you need to transfer the text from the other buffer (orange juice, `file2.txt`) to replace the text on the current buffer (apple juice, `file1.txt`), with your cursor still on `file1.txt` window, first go to the next diff with `]c`. Your cursor now should be on apple juice. Run `:diffget` to get the orange juice from another buffer to replace apple juice in our buffer.
|
If you need to transfer the text from the other buffer (orange juice, `file2.txt`) to replace the text on the current buffer (apple juice, `file1.txt`), with your cursor still on `file1.txt` window, first go to the next diff with `]c`. Your cursor now should be on apple juice. Run `:diffget` to get the orange juice from another buffer to replace apple juice in our buffer.
|
||||||
@ -277,7 +277,7 @@ When you run the `:Git` command without any parameters, vim-fugitive displays a
|
|||||||
- `>` / `<` to display or hide an inline diff of the file name under the cursor.
|
- `>` / `<` to display or hide an inline diff of the file name under the cursor.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="Finding files in FZF" width="900" height="auto" src="images/fugitive-git.png">
|
<img alt="Fugitive Git" width="900" height="auto" src="images/fugitive-git.png">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
For more, check out `:h fugitive-staging-maps`.
|
For more, check out `:h fugitive-staging-maps`.
|
||||||
@ -295,7 +295,7 @@ Some things you can do while in this `"git blame"` mode:
|
|||||||
For more, check out `:h :Git_blame`.
|
For more, check out `:h :Git_blame`.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="Finding files in FZF" width="900" height="auto" src="images/fugitive-git-blame.png">
|
<img alt="Fugitive Git Blame" width="900" height="auto" src="images/fugitive-git-blame.png">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Gdiffsplit
|
## Gdiffsplit
|
||||||
@ -303,7 +303,7 @@ For more, check out `:h :Git_blame`.
|
|||||||
When you run the `:Gdiffsplit` command, vim-fugitive runs a `vimdiff` of the current file's latest changes against the index or work tree. If you run `:Gdiffsplit <commit>`, vim-fugitive runs a `vimdiff` against that file inside `<commit>`.
|
When you run the `:Gdiffsplit` command, vim-fugitive runs a `vimdiff` of the current file's latest changes against the index or work tree. If you run `:Gdiffsplit <commit>`, vim-fugitive runs a `vimdiff` against that file inside `<commit>`.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="Finding files in FZF" width="900" height="auto" src="images/fugitive-gdiffsplit.png">
|
<img alt="Fugitive Gdiffsplit" width="900" height="auto" src="images/fugitive-gdiffsplit.png">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Because you are in a `vimdiff` mode, you can *get* or *put* the diff with `:diffput` and `:diffget`.
|
Because you are in a `vimdiff` mode, you can *get* or *put* the diff with `:diffput` and `:diffget`.
|
||||||
@ -319,7 +319,7 @@ When you run the `:Gread` command in a file after you make changes, vim-fugitive
|
|||||||
When you run the `:Gclog` command, vim-fugitive displays the commit history. It is like running the `git log` command. Vim-fugitive uses Vim's quickfix to accomplish this, so you can use `:cnext` and `:cprevious` to traverse to the next or previous log information. You can open and close the log list with `:copen` and `:cclose`.
|
When you run the `:Gclog` command, vim-fugitive displays the commit history. It is like running the `git log` command. Vim-fugitive uses Vim's quickfix to accomplish this, so you can use `:cnext` and `:cprevious` to traverse to the next or previous log information. You can open and close the log list with `:copen` and `:cclose`.
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="Finding files in FZF" width="900" height="auto" src="images/fugitive-git-log.png">
|
<img alt="Fugitive Git Log" width="900" height="auto" src="images/fugitive-git-log.png">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
While in this `"git log"` mode, you can do two things:
|
While in this `"git log"` mode, you can do two things:
|
||||||
|
Loading…
Reference in New Issue
Block a user