Vim Tutorial for beginners | Vim Cheat sheet



Vim Tutorial for beginners Vi tutorial

How to run WordPress in a VPS using Nginx LEMP stack : https://youtu.be/yWZew2OkPcY

VI Tutorial for beginners / Vim Cheat sheet Post: https://bizanosa.com/vim-tutorial-for-beginners/
VIM Tutorial
VI VS VIM

Timeline :
1 Bye Bye Nano : 00:04
2 Open up Ubuntu on WSL : 00:18
3 Vi VS VIM : 00:38
4 Close VIM fast w/o saving : 1:35
5 Some VIM Modes- Normal Mode : 2:20
6 Some VIM Modes- Insert Mode : 2:45
7 Some VIM Modes- CLI Mode : 3:11
8 No edits close :q : 3:34
9 Save and close : 3:55
10 Save and Close also : 5:47
11 Paste content to Terminal not specifically Vim : 7:15
12 Scroll in Vim : 7:42
13 Edit a file – insert : 8:19
14 Half time Vim Tutorial recap : 9:06
15 Go to top : 11:09
16 Delete a line : 11:44
17 Undo : 11:56
18 Redo : 12:11
19 Repeat Commands a number of times : 12:23
20 Yank or copy : 13:44
21 Paste: 14:01
22 Delete Characters: 15:13
23 Set and unset Line numbers: 15:46
24 How to search : 18:04
25 Navigate the search and edit: 18:28
26 To search and replace : 21:33
27 Various ways to navigate through the file : 23:54
gg: 24:03
G: 24:15
0: 24:31
$: 25:01
w: 25:34
b: 25:54
e: 26:21
ctrl f, Ctrl b : 26:40
28 : New tabs in vim : 27:24

Vim Tutorial for beginners – Vim Cheat sheet
Learn how to use the Vim/Vi editor. At the end of this post you will be confident enough to move from the Nano editor. This is a tutorial with the basic Vim commands that will help you navigate the editor on a daily basis.

Vi vs Vim
Vi is the standard editor available in Linux and Unix systems since the 70s. Vim is an improved version of the Vi editor (available since the 90s).

Vim is usually included in modern Linux and Unix as Vi.

Some Vim Modes
It is important to know the vim modes. Here are 3 important modes you should be aware of.

Normal/Command mode : You will normally enter vim in this mode. Also called the command mode. If you are in any other mode, press escape key (Esc) to get to normal mode. In the normal mode you cannot enter text into your file. This brings us to the second mode.

Insert Mode : If you need to edit your file, this is the mode you need to be in. To get to insert mode, click i . In the insert mode you can edit your file.

Command Line Mode : In the CLI mode, you enter commands into Vim. While in the normal mode, start entering commands such as : or / . Watch the video above if you feel lost.

Insert mode / Editing a file in Vim
Once you open a file in vim, to edit it, you must enter insert mode:

i – insert text. Or

A – to insert text at the end of the line.

How To Run WordPress on a VPS using Nginx and PHP-FPM.

Quitting and Saving a file
Before entering these commands, ensure your press Esc to go to Normal mode.

:q! – Force quit without saving the changes .

:wq – Save and quit .

:w – save changes made to file.

:w filenam1 – save to a file named filename1.

Shift zq : Force quit Vim without saving.

Shift zz : Save and quit.

Editing a File in Vi/Vim
While in the terminal, either of the following will open Vim.

vi filename1
vim filename1
If you want to open a new and empty Vim window, just type vi or vim .

To edit a file remember to get into insert mode using i or A .

More editing options in Vim:
First go to normal mode/command mode.

dd – Deletes a line while in normal mode.

u – Undo the last action.

Ctrl r – Redo .

x – delete a single character.

yy – Yank / Copy a line.

p – (Small p) Paste below the current line. Paste a line after you do yy or dd.

P – (Capital P) Paste above the current line.

Ndd – delete N lines eg . 4dd deletes the next 4 lines

Nu – Undo the last N actions eg 5u will undo the last 5 actions

Remember to get into normal mode while running the above commands.

Add line numbers
:set number or :set nu – show line numbers.

:set nonumber or :set nonu – Hide line numbers

:set nu! – Toggles online numbers off or on.

Search in Vim
/string – Search for string. Then press enter and use n and N to navigate up and down. Press i to edit.

Find and Replace
:%s/string1/string2/gc – Find string1 replace with string2 . The gc at the end means that you must confirm each instance of the replace action.

:%s/string1/string2/g – Replace without confirming.

:%s/string1/string2/ – Also replaces without asking for confirmation.

Vim Navigation within a file
gg – Jump to first line in the file.

G – Jump to last line in the file.

Ctrl f – Navigate page down.

Ctrl b – page up.

That is a quick Vim tutorial for beginners. If you have any problems following this guide, watch the Vim Tutorial for beginners on YouTube.

Tags:
VI Tutorial for beginners,VIM Tutorial,VI VS VIM
.

If this video was helpful to you, please consider supporting my channel : https://paypal.me/rwahowa
.
GET SOCIAL WITH ME:
FACEBOOK: https://www.facebook.com/rwahowa/
INSTAGRAM: https://www.instagram.com/rwahowa/
TWITTER: https://twitter.com/rwahowa/
VIMEO: https://vimeo.com/bizanosa/
WEBSITE : http://rwahowa.com

source

Leave a Comment

Item added to cart.
0 items - KSh0.00