Sunday 9 December 2018

VIM

Useful VIM commands

# J (up) k(down) h (left) l (right)
// Select mode
# ctrl + V 
// Select all lines 
# $
// Insert in the beginning of cursor
# I
// End mode
# ESC
// Insert in the end of cursor
# i
// Insert in the end of line
# a
// Inser begnining of line
# A
// Copy
# y
// Cut
# d
// paste before cursor
# P
// paste end of cursor 
# p

// Write and quite (force)
# :wq!

// quite
# :q!

// Change color scheme of VIM
vim  ~/.vimrc 
colorscheme desert


// Add && remove blank spaces in vim
vim ~/.vimrc
" Ctrl-j/k deletes blank line below/above, and Alt-j/k inserts.
nnoremap  m`:silent +g/\m^\s*$/d``:noh
nnoremap  m`:silent -g/\m^\s*$/d``:noh
nnoremap  :set pastem`o``:set nopaste
nnoremap  :set pastem`O``:set nopaste
//In normal mode, the mappings perform these operations without moving the cursor:

Ctrl-j deletes the line below the current line, if it is blank.
Ctrl-k deletes the line above the current line, if it is blank.
Alt-j inserts a blank line below the current line.
Alt-k inserts a blank line above the current line.

// To add 10 empty lines below the cursor in normal mode,
# 10o 
//or to add them above the cursor type  
# 10O

// Vim search Next
In normal mode you can search forwards by pressing / (or  ) then typing your search pattern. 
Press Esc to cancel or press Enter to perform the search.
 Then press n to search forwards for the next occurrence, or N to searchbackwards. 
Type ggn to jump to the first match, or GN to jump to the last.
 


VIM wiki

No comments:

Post a Comment