Skip to content

Instantly share code, notes, and snippets.

@DovgaNik
Last active August 15, 2022 09:23
Show Gist options
  • Save DovgaNik/53bd0da71bf809fb259effeb8903c62c to your computer and use it in GitHub Desktop.
Save DovgaNik/53bd0da71bf809fb259effeb8903c62c to your computer and use it in GitHub Desktop.

My Vim handbook

Standart functions

  1. Working with files:
    • :edit - will open file or refresh current file
    • :w - will write save the file
    • :q - will close the file
  2. Multiple windows:
    • :split - split window horinzontally
    • :vplit - split window vertically
    • Ctrl-w - move to another window
    • :only - keep only current section
  3. Buffers:
    • :new - will split window horizontally
    • :vnew - will split window horizontally
    • :edit - will open file and create new buffer for it
    • :ls - will open list of buffers
    • :bd - will close buffer
  4. Working with make files:
    • :make - compiles code
    • :copen - opens mini window with errors
    • :cclose - closes mini window with errors
    • :cw - toggles mini window with errors
  5. Register:
    • :reg - opens window with all saved information in register
    • "5p - pastes the fifth element

Installed plugins

  1. Nerd Tree
  2. Gruvbox(theme)
  3. vim multiple cursors:
    • Ctrl-n - start multicursor:
      • Ctrl-n - next
      • Ctrl-x - skip
      • Ctrl-p - remove
    • Alt-n - all matches
  4. vim surround
    • :cs"'
    • :ds"
  5. emmet vim:
    • Ctrl-y, - emmet
  6. lightline
  7. vim fugitive
    • :Gstatus
    • :Gdelete
    • :Git
  8. tabular
    • :Tab/

Mappings

  • Ctrl-f :NERDTreeToggle
  • Ctrl-r :source .vimrc :PlugInstall
  • Ctrl-t :tabnew
  • Ctrl-Up :tabp
  • Ctrl-Down :tabn
  • Ctrl-a :Gstatus
  • Ctrl-h :tabp
  • Ctrl-l :tabn
"Plugins
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree'
Plug 'morhetz/gruvbox'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-surround'
Plug 'mattn/emmet-vim'
Plug 'itchyny/lightline.vim'
Plug 'tpope/vim-fugitive', { 'on': 'Gstatus' }
call plug#end()
"Search
set hlsearch
set incsearch
set title "Winddow title shows the filename
"Swap and backup folder
set undodir=~/.vim/undo
set backupdir=~/.vim/backup
set directory=~/.vim/swap
"Theme an syntax highlight
set background=dark
colorscheme gruvbox
syntax on
set number
set autoread "Auto reading of the file (if edited in anothe editor)
"Encoding
set encoding=utf-8
set fileencoding=utf-8
"Status bar
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
set laststatus=2
"Mapping
map <C-f> :NERDTreeToggle <CR>
map <C-r> :source .vimrc <CR> :PlugInstall <CR>
map <C-t> :tabnew <CR>
map <C-t> :Gstatus <CR>
map <C-Left> :tabp <CR>
map <C-Right> :tabn <CR>
map <C-h> :tabp <CR>
map <C-l> :tabn <CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment