From 195a682fb8698db24e00eaeef1ad6165d7a564a8 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Sun, 14 Jun 2015 03:50:51 +0200 Subject: [PATCH] Detect file type for dotfiles & change background autocmd is used to hard code the file type to certain file names, since vim expects them to have the standard names starting with a dot but the files are tracked in the repository without the leading dot. Add a mapping to quickly toggle between the current and previous file. Add a mapping to quickly toggle dark/light background. Cosmetic change: all key codes are lower case. --- vimrc | 57 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/vimrc b/vimrc index 712ee5f..0279d03 100644 --- a/vimrc +++ b/vimrc @@ -79,7 +79,7 @@ let mapleader = "," " }}} " tagbar {{{ - nnoremap t :TagbarToggle + nnoremap t :TagbarToggle " }}} " vim-airline {{{ @@ -92,50 +92,65 @@ let mapleader = "," " }}} " vim-trailing-whitespace {{{ - nnoremap w :FixWhitespace + nnoremap w :FixWhitespace " }}} " }}} -" Autocmds {{{ - autocmd FileType vim setlocal foldmethod=marker - autocmd FileType *.py setlocal foldmethod=indent | setlocal foldnestmax=2 -" }}} +augroup vimrc " {{{ + autocmd! + au BufNewFile,BufRead *.md set ft=markdown + au BufNewFile,BufRead bash_profile,bashrc set ft=sh + au BufNewFile,BufRead gitconfig set ft=gitconfig + au BufNewFile,BufRead rcrc set ft=sh + + au FileType vim setl foldmethod=marker + au FileType python setl foldmethod=indent + au FileType markdown,text setl formatoptions+=t | setl spell + au FileType gitcommit setl formatoptions+=t | setl spell | setl textwidth=72 +augroup END " }}} " Key mappings {{{ " split navigations and resizing - nnoremap - nnoremap - nnoremap - nnoremap - nnoremap :execute "resize " . (winheight(0) * 5/4) - nnoremap :execute "resize " . (winheight(0) * 4/5) - nnoremap :execute "vertical resize " . (winwidth(0) * 5/4) - nnoremap :execute "vertical resize " . (winwidth(0) * 4/5) + nnoremap + nnoremap + nnoremap + nnoremap + nnoremap :execute "resize " . (winheight(0) * 5/4) + nnoremap :execute "resize " . (winheight(0) * 4/5) + nnoremap :execute "vertical resize " . (winwidth(0) * 5/4) + nnoremap :execute "vertical resize " . (winwidth(0) * 4/5) " fast navigation of matchpairs ({[]}) - nnoremap % - vnoremap % + nnoremap % + vnoremap % " retain selection when indenting/unindenting in visual mode - vnoremap > >gv - vnoremap < <gv + vnoremap > >gv + vnoremap < <gv " case insensitive searching nnoremap // /\c nnoremap ?? ?\c " quickly exit insert mode - inoremap jk + inoremap jk " better navigation for wrapped lines noremap j gj noremap k gk " space opens/closes folds - nnoremap za + nnoremap za " turn off search highlight - nnoremap :nohlsearch + nnoremap :nohlsearch + + " switch between last two files + nnoremap + + " quickly change background + nnoremap bd :set background=dark + nnoremap bl :set background=light " }}} if filereadable(expand("~/.vimrc.local"))