

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Cheat sheet and important points regarding Vi/Vim Editor
Typology: Lecture notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


vi (enter file) ESC MODE : esc EDIT MODE replace : r or double insert insert : i or insert VISUAL MODE : v use shebang/header line at begining >> #!/bin/bash < DOC- command multiple lines
BASIC FILE OPERATIONS save - Esc + :w quit - Esc + :q! save and quit - Esc + :wq SHORTCUTS TO BE DONE IN ESC/COMMAND MODE copy : yy copy multiple lines : 'n'yy (top to bottom) paste : p delete : dd or 'n'dd (multiple) delete one line : dw delete starting cursor position to end : d$ delete before cursor position : d^ undo : u redo : ctrl + r go to first line : gg go to last line : G go to a particular line nG or ngg create new line after cursor position : o " before cursor position : O Replace a specific world without entering the replace mode - :%s/wor/new word TO COPY FROM ONE FILE TO ANOTHER : ESC MODE >> :r MANUAL - vimtutor COMMANDS set nu (give numbering to the lines) set hls (to hightlight lines) incsearch >> to highlight >> Esc + / set mouse=a (to move using mouse) a - work in all mode To make permanent changes >> cd ~ (reach root directory) >> vi .vimrc >> wc tail : prints last 10 lines tail -3 : least 3 lines will be printed tail -c3 : last 3 characters will be displayed more (to display file greator than window size) (view contents page by page >> press enter) less (opens in another file)(:n to access next file, :p to access previous file)