Linux : Vi/Vim Editor, Lecture notes of Linux skills

Cheat sheet and important points regarding Vi/Vim Editor

Typology: Lecture notes

2023/2024

Available from 01/04/2024

merlin-m-reji
merlin-m-reji 🇮🇳

2 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
vi <file_name.sh> (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 <..> DOC- command multiple lines
# = command single 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 <file_name.sh>
MANUAL - vimtutor
COMMANDS
set nu (give numbering to the lines)
set hls (to hightlight lines) incsearch >> to highlight >> Esc + /<word>
set mouse=a (to move using mouse)
a - work in all mode
To make permanent changes >> cd ~ (reach root directory) >> vi .vimrc >> <type in
commands for changes here>
wc <option><file_name.sh>
to get total word count in a file : wc -w <file_name.sh>
to get total line count in a file : wc -l <file_name.sh>
to get total byte/character count in a file : wc -c/m <file_name.sh>
take word byte and line count from terminal
wc >> ENTER >> <typein> >> Ctrl+D
DISPLAY FILE CONTENTS IN TERMINAL
cat <file_name>
head <file_name> : prints first 10 lines
head -3 <file_name> : prints first 3 lines
head -c3 <file_name> display first 3 characters
pf2

Partial preview of the text

Download Linux : Vi/Vim Editor and more Lecture notes Linux skills in PDF only on Docsity!

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

= command single 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)