From 534d9217cb05867bd76d4723af45413497af2944 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Fri, 27 Feb 2015 16:38:02 +0100 Subject: [PATCH] [vim]indent in .vimrc is now all 8spaces --- .vimrc | 176 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 89 insertions(+), 87 deletions(-) diff --git a/.vimrc b/.vimrc index 08d96ce..7f8fa33 100644 --- a/.vimrc +++ b/.vimrc @@ -2,7 +2,8 @@ " SHORTCUTS " """"""""""""" " F1 help -" F2 open file +" F2 open file in a new tab +" S-F2 Split and open file " F3 autotags Update " S-F3 autotags Add " F4 open include file @@ -43,10 +44,10 @@ set nobackup set autowrite " jump to last known position when reopening a file if has("autocmd") - autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ execute "normal! g`\"" | - \ endif + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ execute "normal! g`\"" | + \ endif endif " command line history set history=50 @@ -122,17 +123,17 @@ set shiftwidth=8 " set noexpandtab if has("autocmd") - " python - " autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab - autocmd BufRead,BufNewFile *.py syntax on - autocmd BufRead,BufNewFile *.py set ai - autocmd BufRead,BufNewFile *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class - autocmd BufRead,BufNewFile *.py set tabstop=4 - autocmd BufRead,BufNewFile *.py set expandtab - autocmd BufRead,BufNewFile *.py set shiftwidth=4 - autocmd BufRead,BufNewFile *.py set softtabstop=4 - autocmd BufRead,BufNewFile *.py set modeline - autocmd BufRead,BufNewFile *.py set ft=python + " python + " autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab + autocmd BufRead,BufNewFile *.py syntax on + autocmd BufRead,BufNewFile *.py set ai + autocmd BufRead,BufNewFile *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class + autocmd BufRead,BufNewFile *.py set tabstop=4 + autocmd BufRead,BufNewFile *.py set expandtab + autocmd BufRead,BufNewFile *.py set shiftwidth=4 + autocmd BufRead,BufNewFile *.py set softtabstop=4 + autocmd BufRead,BufNewFile *.py set modeline + autocmd BufRead,BufNewFile *.py set ft=python endif if has("autocmd") @@ -141,32 +142,32 @@ endif " vim -b : edit binary using xxd-format! augroup Binary - au! - au BufReadPre *.bin let &bin=1 - au BufReadPost *.bin if &bin | %!xxd - au BufReadPost *.bin set ft=xxd | endif - au BufWritePre *.bin if &bin | %!xxd -r - au BufWritePre *.bin endif - au BufWritePost *.bin if &bin | %!xxd - au BufWritePost *.bin set nomod | endif + au! + au BufReadPre *.bin let &bin=1 + au BufReadPost *.bin if &bin | %!xxd + au BufReadPost *.bin set ft=xxd | endif + au BufWritePre *.bin if &bin | %!xxd -r + au BufWritePre *.bin endif + au BufWritePost *.bin if &bin | %!xxd + au BufWritePost *.bin set nomod | endif augroup END if has("autocmd") - " enable file type detection and do language-dependent indenting - " filetype plugin indent on - " detect indentation see http://www.freehackers.org/Indent_Finder - if has('python') - autocmd BufReadPost /* execute system ('python2 ~/.vim/indent_finder/indent_finder.py --vim-output "' . expand('%') . '"' ) - endif + " enable file type detection and do language-dependent indenting + " filetype plugin indent on + " detect indentation see http://www.freehackers.org/Indent_Finder + if has('python') + autocmd BufReadPost /* execute system ('python2 ~/.vim/indent_finder/indent_finder.py --vim-output "' . expand('%') . '"' ) + endif else - " auto-indent - set autoindent - " smart-indent - set smartindent - " C-indent - "set cindent - " indent-expr - "set indentexpr "" + " auto-indent + set autoindent + " smart-indent + set smartindent + " C-indent + "set cindent + " indent-expr + "set indentexpr "" endif map :pyf ~/.vim/syntax/clang-format.py @@ -196,16 +197,16 @@ runtime macros/matchit.vim " imap i " try to go to definition or declaration with , and go back with ; function GoToDefinition() - try - execute "cscope find g " . expand("") - catch /:E259:/ - try - execute "tag " . expand("") - catch /:E257:/ - execute "normal! gd" - execute "nohlsearch" - endtry - endtry + try + execute "cscope find g " . expand("") + catch /:E259:/ + try + execute "tag " . expand("") + catch /:E257:/ + execute "normal! gd" + execute "nohlsearch" + endtry + endtry endfunction nmap , :call GoToDefinition() nmap ; @@ -232,18 +233,18 @@ map :TlistToggle " close preview window after a completion if has("autocmd") - autocmd CursorMovedI *.{[hc],cpp} if pumvisible() == 0|pclose|endif - autocmd InsertLeave *.{[hc],cpp} if pumvisible() == 0|pclose|endif + autocmd CursorMovedI *.{[hc],cpp} if pumvisible() == 0|pclose|endif + autocmd InsertLeave *.{[hc],cpp} if pumvisible() == 0|pclose|endif endif function! TagInNewTab() - let word = expand("") - redir => tagsfiles - silent execute 'set tags' - redir END - tabe - execute 'setlocal' . strpart(tagsfiles, 2) - execute 'tag ' . word + let word = expand("") + redir => tagsfiles + silent execute 'set tags' + redir END + tabe + execute 'setlocal' . strpart(tagsfiles, 2) + execute 'tag ' . word endfunction nmap :call TagInNewTab() @@ -269,31 +270,32 @@ set splitbelow set splitright " if multiple windows if bufwinnr(1) - " vertically increase/decrease window size with alt+up/alt+down - map + - map - - imap a - imap a - " horizontally increase/decrease window size with alt+right/alt+left - map > - map < - imap a - imap a - " switch to next/previous tab with ctrl+right/ctrl+left - map gt - map gT - imap a - imap a - " switch to next/previous window with ctrl+down/ctrl+up - map w - map W - imap a - imap a + " vertically increase/decrease window size with alt+up/alt+down + map + + map - + imap a + imap a + " horizontally increase/decrease window size with alt+right/alt+left + map > + map < + imap a + imap a + " switch to next/previous tab with ctrl+right/ctrl+left + map gt + map gT + imap a + imap a + " switch to next/previous window with ctrl+down/ctrl+up + map w + map W + imap a + imap a endif " open automatically quickfix window if has("autocmd") autocmd QuickFixCmdPost * cw endif + " open a file in the same directory as the current file with F2 and split with shift+F2 map :tabe =expand("%:h") . "/" nmap :split =expand("%:h") . "/" @@ -308,15 +310,15 @@ nmap :tabe ~/.vimrcgg imap " show contextual help with F1 function Help() - try - if b:current_syntax == "python" - :call ShowPyDoc(expand(""), 1) - else - execute "Man " . expand("") - endif - catch /:E149:/ - execute "help " . expand("") - endtry + try + if b:current_syntax == "python" + :call ShowPyDoc(expand(""), 1) + else + execute "Man " . expand("") + endif + catch /:E149:/ + execute "help " . expand("") + endtry endfunction nmap :call Help() imap @@ -329,7 +331,7 @@ imap """"""""" " show current changes with F10 command! DiffOrig - \ vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis + \ vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis map :DiffOrig imap a " show git diff when committing