1
1
---
2
2
slug : vim-tips
3
3
title : vim tips and tricks
4
- authors :
5
- name : Tomasz Kubacki
6
- title : Random dev
7
- url : https://github.com/tomaszkubacki
8
- image_url : https://avatars.githubusercontent.com/u/348532?s=400&v=4
4
+ authors : tkub
9
5
tags : [linux, vim]
10
6
---
11
7
12
8
# VIM tips list
13
9
14
- ## How to use this guide
10
+ This post is a list of vim tips and tricks i found useful during my never ending jurney of learing vim
15
11
16
- ### Learn vim basic
17
- You need to know what is normal and insert mode in vim.
18
- Whenever I write
19
- ```
20
- :something
12
+ <!-- truncate -->
13
+
14
+ ## Learn vim basic
15
+ You need to know some vim basics to use those tips. Nothing really deep just how to start, leave or change vim mode.
16
+ If you have Vim installed, you probably have vimtutor command installed as well.
17
+ Just enter your command line and type
18
+ ``` shell
19
+ vimtutor
21
20
```
22
- I mean invoking * something * command in so called normal mode (pressing ctrl+c then typing : something )
21
+ to check it out.
23
22
24
- #### Use ctrl+c to switch to normal mode
23
+ ## Modes and leaving Vim
24
+
25
+ ### Use ctrl+c to switch to normal mode
25
26
There are two ways to switch to normal mode one is to use escape key, but often more convenienient is to use ctrl+c shortcut
26
27
27
28
Famous leave vim jokes arouse, because users can't enter the normal mode after editing.
28
29
29
- To quit the editor you need to do in normal mode
30
+ ### Leave Vim with multiple files and tabs opened
31
+
32
+ As you know to quit the editor you need to type
30
33
31
34
```
32
35
:q
33
36
```
34
- or if multiple windows are opened close them all
37
+ in normal mode.
38
+
39
+ To leave Vim with multiple windows and tabs opened use
35
40
36
41
```
37
42
:qa
38
43
```
39
44
40
- ### Navigatig
45
+ ## Navigatig
41
46
42
47
Beyond normal vim movements like scrolling with
43
48
```
@@ -59,13 +64,10 @@ ctl+o
59
64
60
65
and forward to last position with
61
66
62
-
63
67
```
64
68
ctl+i
65
69
```
66
70
67
-
68
-
69
71
### Split windows and navigate between them
70
72
71
73
The magic command to split vertically is : vsplit command
@@ -96,7 +98,7 @@ ctrl+w [arrow key]
96
98
```
97
99
command.
98
100
99
- #### Resizing
101
+ ### Resizing
100
102
101
103
increase size
102
104
```
@@ -118,21 +120,23 @@ Maximize current window
118
120
ctrl+w _
119
121
```
120
122
123
+ ## Plugins
124
+
121
125
### Use decent plugin manager
122
126
123
127
One modern and easy to use vim plugin manager is [ vim-plug] ( https://github.com/junegunn/vim-plug )
124
128
125
- ## Use file tree plugin
129
+ ### Use NERDTree plugin
126
130
127
- Use NERDTree file tree display in vim - https://github.com/preservim/nerdtree
131
+ NERDTree helps file tree display in vim - https://github.com/preservim/nerdtree
128
132
129
133
after install just open it with
130
134
```
131
135
:NERDTree
132
136
```
133
137
in normal mode
134
138
135
- ## Run Terminal inside vim
139
+ ### Run Terminal inside vim
136
140
137
141
Vim has build in terminal plugin. You can open it with
138
142
```
@@ -145,10 +149,9 @@ If you want terminal below current window use
145
149
:bel term
146
150
```
147
151
152
+ ## Copy between editor and terminal
148
153
149
- ### Copy between editor and terminal
150
-
151
- #### Copy from the editor to the terminal
154
+ ### Copy from the editor to the terminal
152
155
153
156
Assume you did copy some text into default register (e.g. by using yy coping line), then you can paste it into terminal by using
154
157
```
@@ -158,7 +161,7 @@ ctrl+w ""
158
161
> note: it is possible to copy from other registers as well. To list registers use the : register command
159
162
160
163
161
- #### Copy from the terminal to the editor
164
+ ### Copy from the terminal to the editor
162
165
163
166
It's possible to switch terminal into normal read-only editor by pressing
164
167
@@ -173,6 +176,3 @@ To go back to the terminal mode just press *i* (like insert)
173
176
174
177
175
178
176
-
177
-
178
-
0 commit comments