Created
May 21, 2012 14:43
-
-
Save znake/2762707 to your computer and use it in GitHub Desktop.
some VIMRC tricks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" disable VIM welcome screen | |
set shortmess+=I | |
" Softwrap for VIM | |
set wrap linebreak textwidth=0 | |
set showbreak=> | |
" For usual moving behaviour in wrapped lines | |
map j gj | |
map k gk | |
"Open last/alternate buffer | |
noremap <Leader><Leader> <C-^> | |
" Reselect visual block after indent/outdent | |
vnoremap < <gv | |
vnoremap > >gv | |
" delete Text and go switch to insert mode between HTML-Tags (yes you can do this with ci< too) | |
map <Leader>< F>lct< | |
" Use fj or jf as <Esc> alternative | |
inoremap fj <esc> | |
inoremap jf <esc> | |
"Resize splits when the window is resized | |
au VimResized * exe "normal! \<c-w>=" | |
" make it easy to resize windows | |
map + <C-W>4+ | |
map - <C-W>4- | |
" use tab to switch buffers | |
noremap <tab> <C-w>w | |
" close buffer | |
map <C-c> <c-w>c | |
" force saving files that require root permission | |
cmap w!! %!sudo tee > /dev/null % | |
" indent whole file jump back to current position | |
map <Leader>id mmgg=G'm | |
" center current cursor line | |
map M zz | |
" insert new line | |
nmap t o<ESC>k | |
nmap T O<ESC>j | |
" make :W to :w -> no annoying error Message when typend wrong | |
cnoreabbrev W w | |
" faster use of the surround plugin | |
" operates on a normal word w | |
map <Leader>s csw | |
" operates on a big word W | |
map <Leader>S csW | |
" operates on a line | |
map <Leader>sl yss | |
" Use system clipboard for copy and paste | |
set clipboard=unnamed | |
" Filetype mappings | |
map <Leader>fh :set ft=html<cr> | |
map <Leader>fj :set ft=javascript<cr> | |
map <Leader>fr :set ft=ruby<cr> | |
map <Leader>fl :set ft=tex<cr> | |
map <Leader>fp :set ft=php<cr> | |
map <Leader>fs :set ft=sql<cr> | |
" quick commit the current file with the fugitive plugin | |
map <Leader>gh :w<cr>:Gwrite<cr>:Gcommit<cr>i | |
" Buffers | |
map <Leader>bd :bd<cr> | |
map <Leader>bn :bn<cr> | |
map <Leader>bp :bp<cr> | |
map <Leader>bo :only<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment