How to use Vim in Termux/Linux



Whether you are just a beginner or a professional, Vim can boost your productivity 10X from now, and if you can master vim that 10X can be increased to 50X, 60X and even 100X,


So In this article we will see Some basic but very powerful usage of Vim.



So to use vim first we have to install vim,


pkg install vim


Now to start using vim execute 


vim





To start wrinting, press 


i

 key on you keyboard and now you will be in insert mode where you can write the stuff,


To get out of insert mode use 


Esc 


key


To save the file use 


:w


And if didn't gave name to your file, so use 


:w <your file name>


Note to use this : commands, you should be in normal mode, if you not sure about its better use Esc key before using :.


To exit use 


:q!


To save and exit use 


:wq!


To open a file with vim, use 


vim <file>


if you are working on project, then use 


vim <project directory>


now you can easily navigate between different files or folder in your project directry directly from vim only.



You can use hjkl as arrow keys, 


h - for left

j - for bottom

k - for top

l- for right


To go at the top of the file, use 


gg


And Captial 



to go at the bottom of the file


To delete letters after the cursor use

 

x


or use 


dd 


to delete the entire line


If you did it by mistake, just use 



to undo,


If undo was mistake, use 


ctrl r 


to redo.


Suppose you want go to this word, just use


 /<Your word>


If you searching for a word, and you can't find it use

 :/<word you are searching for>


To search and replace the word use


:s/< word you are searching for >/<and the replace word>/



To do same for all the same word use g at end.


:s/< word you are searching for >/<and the replace word>/g


To copy a line use 


yy



To paste something from your clipboard, use


 p 


You can even split tabs in vim,

 

Ctrl - wv to split vertically

Ctrl - ws to split horizontally

Ctrl ww - To switch between those tabs



If you want to know the number of lines use

 

:set number 


To turn on syntax highlighting use


:syntax on


Want to use this everytime, put them in vimrc file


First open it


vim ~/.vimrc 


then put you configuration here,


We will do 2 which we did earlier


set number

syntax on


And now if you open any file, syntax highlighting and the number of lines will be on.


if you are new to vim, execute 


vimtutor


or just use 


:help


 in vim





Post a Comment (0)
Previous Post Next Post