Skip to main content

VIM FAQ

TBD ASAP!

VIM in shorts:
swap two character: xp
join two strings: J (normal) or :join cmd
redo: Ctrl-R or 4Ctrl-R etc
delete in quotes: di"
delete with quotes: da"
copy visual to clipboard: V + "+y
paste clipboard: :put +
run current file: :!%
insert CLIPBOARD: :put +
paste mode (special): set paste

Run current file (not possible to set by modeline, use a lot while script debugging):

:set makeprg=bash\ %
:set autowrite
:make

PS: .vimrc (grep -v ^\" .vimrc | awk 'NF')

set nocompatible
filetype on
filetype plugin on
filetype indent on
syntax on
set number
set cursorline
set cursorcolumn
set shiftwidth=4
set tabstop=4
set expandtab
set nobackup
set scrolloff=10
set nowrap
set incsearch
set ignorecase
set smartcase
set showcmd
set showmode
set showmatch
set hlsearch
set history=1000
set wildmenu
set wildmode=list:longest
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
set statusline=
set statusline+=\ %F\ %M\ %Y\ %R
set statusline+=%=
set statusline+=\ ascii:\ %b\ hex:\ 0x%B\ row:\ %l\ col:\ %c\ percent:\ %p%%
set laststatus=2
:colorscheme evening
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
set langmap=йцукенгшщзхъфывапролджэячсмитьбю;qwertyuiop[]asdfghjkl\\;'zxcvbnm\\,.,ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ;QWERTYUIOP{}ASDFGHJKL:\\"ZXCVBNM<>
set mouse=a
set spell spelllang=ru_ru
set wrap linebreak
au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown
function! AppendModeline()
  let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :",
        \ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no')
  let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
  call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>