Professional Documents
Culture Documents
SEM-5-CSE - Operating Systems Lab (PCC-CS592) Vim
SEM-5-CSE - Operating Systems Lab (PCC-CS592) Vim
/
SEM-5-CSE
Code Issues Pull requests Discussions Actions Projects Wiki Security Insights
..
readme.md
Learn Vim
https://www.tutorialspoint.com/vim/index.htm
https://drive.google.com/file/d/10xnekN1o_JFprBa10NXjTteDAqgcbcZf/view?usp=drivesdk
A simple .vimrc
set number
set autoindent
set smartindent
set smarttab
set history=1000
set mouse=a
set ttymouse=xterm2
set t_Co=256
set path+=**
set wildmenu
set showtabline=2
set laststatus=2
set cursorline
set cursorlineopt=number
colorscheme torte
hi CursorLineNr cterm=NONE ctermbg=235 ctermfg=DarkRed
hi LineNr ctermbg=235 ctermfg=LightGrey
Add any external colorscheme
https://github.com/arkapg211002/SEM-5-CSE/blob/main/Operating%20Systems%20Lab%20(PCC-
CS592)/Vim/sublimemonokai.vim
Additions in .vimrc
Commands Definition
:w ( : refers to
5 command line mode in To save the file
vim)
vim -R filename.txt
8 To open the file in read only mode
(write in terminal)
Commands Definition
vim filename.txt
9 To open file in normal mode
(write in terminal)
13 :help topic name To open help for particular topic if the topic name is known
18 s Substitute -> Delete the current character under the cursor and enter insert mode
19 cc Similar to substitute. Deletes the entire line and enters the insert mode
20 r Replace the character under the cursor , doesnt enter into insert mode
22 J To join two text lines. Place the cursor after line 1 of the 2 lines and type J
25 k To move cursor up
copy entire line. To copy multiple lines place the cursor from where you want to
copy and then press nyy where n is the number of lines you want to copy. To copy
41 yy
in a range go to command line mode and type :a,by where a is the starting line
number and b is the ending line number
Commands Definition
47 u undo
48 :red redo
place the cursor under a word and type * . All the occurences of the word gets
52 *
highlighted
:vimgrep expression
53 finds all the occurrences of the expression in all the files
*.txt
To switch files that are in the buffer. N represnts the Nth file in the buffer. The first
57 :bN file that you open using vim filename or :edit filename is assigned number 1
in the buffer
62 :tabnew file name Open new tab in the existing vim session
67 :new filename open file in new window in the same vim sessoin
Useful when there are multiple long functions. :set foldenable and :set
Folding functions in
68 foldmethod=indent to enable folding in the current file. zo to open folding. zc
programs
to close folding. zR to open all foldings
vim -d file1.txt
69 to show the difference between two files (terminal command)
file2.txt
(vim command line) to show horizontally the differnce of file1 (already open)
70 :diffsplit file2.txt
with file 2
Commands Definition
:vert diffsplit
71 (vim command line) to show differences vertically
file2.txt
to open terminal in vim (default version of vim that is installed along with ubuntu
72 :term
has unscrollable terminal)
74 :below vertical terminal to open terminal on the right side of the window
:hi CursorLine
76 To set current cursor line as grey highlight
ctermbg=Grey
78 :hardcopy filename.ps Convert whole file in current vim window to postscript file
91 :Rexplore To go back to file tree structure from the file that was opened from the tree
To change the tree top to the directory under the cursor. Go to the .. at the top
94 :Ntree directory name
and press enter to change the current directory to the parent
Within vim
Go to command line mode :a,by where a and b are the starting and ending line numbers p to paste
Gedit opens copy and paste outside vim where you want
In terminal