diff --git a/vim/plugin/cf5-compile.vim b/vim/plugin/cf5-compile.vim index 1c84d0a..cca8e4c 100755 --- a/vim/plugin/cf5-compile.vim +++ b/vim/plugin/cf5-compile.vim @@ -128,7 +128,7 @@ function! s:CompileMSVC(run) "{{{2 endif endfunction -" +" " GCC " function! s:CompileGCC(run) "{{{2 @@ -138,7 +138,7 @@ function! s:CompileGCC(run) "{{{2 let ccline="g++ ".g:cppflags." ".g:lcppflags." ".g:ldflags." ".srcname." -o".exename call s:appendOutput(ccline) let cout = system( ccline ) - if v:shell_error + if v:shell_error call s:appendOutput(cout) return endif @@ -228,7 +228,7 @@ function! s:getOutputWindow() if (winnr < 0) execute "below 10new ".obuff setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap - " setlocal nomodifiable + " setlocal nomodifiable let winnr = bufwinnr('^'.obuff.'$') endif @@ -241,10 +241,10 @@ function! s:appendOutput( text ) if exists("g:cf5output") && (g:cf5output==1) let cwinnr = winnr() let owinnr = s:getOutputWindow() -" setlocal modifiable +" setlocal modifiable execute owinnr . 'wincmd w' execute 'normal! Go'.a:text -" setlocal nomodifiable +" setlocal nomodifiable execute cwinnr.'wincmd w' else echo a:text @@ -257,13 +257,18 @@ function! s:clearOutputWindow() if exists("g:cf5output") && (g:cf5output==1) let cwinnr = winnr() let owinnr = s:getOutputWindow() -" setlocal modifiable +" setlocal modifiable execute owinnr . 'wincmd w' execute 'normal ggdG' -" setlocal nomodifiable +" setlocal nomodifiable execute cwinnr . 'wincmd w' endif endfunction + +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Public interface. +"" + " " Load compile instructions and call window or linux compiler. {{{1 " @@ -292,4 +297,16 @@ function! CF5Compile(run) " call s:Compile(a:run) endfunction +" +" Load compile instructions and call window or linux compiler. +" +function! CF5CompileAndRun() + call CF5Compile(1) +endfunction +" +" Load compile instructions and call window or linux compiler. +" +function! CF5CompileOnly() + call CF5Compile(0) +endfunction diff --git a/vim/vimrc b/vim/vimrc index fe9414c..7cccd08 100755 --- a/vim/vimrc +++ b/vim/vimrc @@ -18,7 +18,7 @@ set fileformat=unix set nobackup "set backupdir="~/tmp,." git commit doesn't work. " Try to set up UTF-8 encoding. -if has("multi_byte") +if has('multi_byte') if &termencoding == "" let &termencoding = &encoding endif @@ -85,11 +85,20 @@ set cino+=(0 " enable omni completion set omnifunc=syntaxcomplete#Complete +" If modlines available then turn it on so each file could set its settings. +" ex. # vim: set expandtab: +if exists('+modeline') + set modeline + set modelines=5 +endif +" read/write a .viminfo file, don't store more +if exists('+viminfo') + set viminfo='20,\"50 +endif -set viminfo='20,\"50 " read/write a .viminfo file, don't store more " than 50 lines of registers let g:netrw_preview = 1 " netrw open window to the right let g:netrw_browse_split = 3 " open in a tab @@ -102,8 +111,6 @@ set ttyfast "tf "smooths redraw by using more bandwidth " Set timeout for detecting command key sequence set timeoutlen=400 -"set autoread "update file modified outside of vim - " Quickly time out on keycodes, but never time out on mappings set notimeout ttimeout ttimeoutlen=200 " Use to toggle between 'paste' and 'nopaste' @@ -125,7 +132,7 @@ endif " " Configure color theme, fonts and other graphics. " -if has("gui_running") +if has('gui_running') " set color scheme colorscheme darkblue "set guioptions-=m @@ -147,7 +154,7 @@ endif " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. -if &t_Co > 2 || has("gui_running") +if &t_Co > 2 || has('gui_running') syntax on set hlsearch endif @@ -168,16 +175,16 @@ set cmdheight=2 set laststatus=2 " Display the cursor position on the last line of the screen or in the status " line of a window -if exists('&ruler') +if exists('+ruler') set ruler endif " Instead of failing a command because of unsaved changes, raise a dialogue " asking if you wish to save changed files. -if exists('&confirm') +if exists('+confirm') set confirm endif " Use visual bell instead of beeping when doing something wrong -if exists('&visualbell') +if exists('+visualbell') set visualbell " And reset the terminal code for the visual bell. If visualbell is set, and " this line is also included, vim will neither flash nor beep. If visualbell @@ -185,17 +192,17 @@ if exists('&visualbell') set t_vb= endif " Display line numbers on the left -if exists('&number') +if exists('+number') set number endif " Turn on spell check. -if exists("+spell") && &diff=="nodiff" +if exists('+spell') && !&diff set spell highlight clear SpellBad highlight SpellBad cterm=underline ctermfg=red endif " Show 80th column. -if exists("+colorcolumn") +if exists('+colorcolumn') set colorcolumn=+1 " color textwidth+1-th line endif @@ -227,14 +234,12 @@ endif - - """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " vimdiff " " Turn on spell check. -if &diff=="diff" +if &diff "turn off spelling set nospell @@ -245,6 +250,9 @@ if &diff=="diff" endif +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" TODO: review +" @@ -267,12 +275,6 @@ if exists('&hidden') set hidden endif -" Modelined are used to configure files. -if exists('&modeline') - set modeline - set modelines=10 -endif - " Set fold method if supported if has('folding') set nofoldenable @@ -290,7 +292,7 @@ if has('folding') endif " Only do this part when compiled with support for autocommands. -if has("autocmd") +if has('autocmd') " Enable file type detection. " Use the default filetype settings, so that mail gets 'tw' set to 72, @@ -332,7 +334,7 @@ endif " has("autocmd") " " -if has("gui_running") +if has('gui_running') ":tab drop {file} " Hide show menu and toolbar. @@ -354,9 +356,24 @@ map :tab split:exec("tag ".expand("")) "map :tabnew " -" F4 grep the word under cursor. +" Grep the word under cursor. " -map :execute "grep " . expand("") . " -r --include \*.h --include \*.cpp --include \*.c --include \*.f ." cw +" Grep options affect GNU grep. The intend is that greps not supporting the +" options will continue working without options. +" +let $GREP_OPTIONS.=' --exclude-dir=.git --exclude-dir=.svn' +let $GREP_OPTIONS.=' --exclude=tags --exclude=*.o --exclude=*.log' +let $GREP_OPTIONS.=' --exclude=*.swp' +let $GREP_OPTIONS.=' --exclude-dir=llcalc* --exclude-dir=00*' +"let $GREP_OPTIONS.=' --include *.sh' +"let $GREP_OPTIONS.=' --include *.php' +"let $GREP_OPTIONS.=' --include *.h --include *.cpp --include *.c' +"let $GREP_OPTIONS.=' --include *.py' +"let $GREP_OPTIONS.=' --include *.java' +"let $GREP_OPTIONS.=' --include *.f' +"let $GREP_OPTIONS.=' --include *.xsd --include *.xml' +"let $GREP_OPTIONS.=' --include Makefile' +map af :execute "grep! ".expand("")." -r ." cw " " Loads CF5Compile @@ -365,8 +382,8 @@ map :execute "grep " . expand("") . " -r --include \*.h --include if !exists('*CF5Compile') runtime plugin/cf5-compiler.vim endif -map :call CF5Compile(1) -map :call CF5Compile(0) +map a4 :call CF5CompileOnly() +map a5 :call CF5CompileAndRun() " " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, " so that you can undo CTRL-U after inserting a line break. @@ -377,8 +394,8 @@ inoremap u " noremap gk noremap gj -imap gk -imap gj +"imap gk +"imap gj " " Working with tabs especially if using console version. " @@ -389,6 +406,14 @@ nnoremap tl :tablast nnoremap tm :tabm nnoremap td :tabclose +" +" Locate and load .vimrc.local from curent directory. +" +if !exists('*LocalVimrcLoad') + runtime plugin/local-vimrc.vim +endif +call LocalVimrcLoad( getcwd() ) + """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Plugins " @@ -396,7 +421,7 @@ nnoremap td :tabclose " " Vundle experimental stuff here. " -if filereadable(expand("~/.vim/bundle/Vundle.vim/README.md")) +if filereadable(expand('~/.vim/bundle/Vundle.vim/README.md')) filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() @@ -416,8 +441,8 @@ if filereadable(expand("~/.vim/bundle/Vundle.vim/README.md")) Plugin 'vim-scripts/Buffergator' let g:buffergator_suppress_keymaps = 1 let g:buffergator_viewport_split_policy = "L" - map :BuffergatorToggle - map :BuffergatorTabsToggle + map ab :BuffergatorToggle + "map at :BuffergatorTabsToggle " " @@ -439,9 +464,11 @@ if filereadable(expand("~/.vim/bundle/Vundle.vim/README.md")) Plugin 'scrooloose/nerdtree' let g:NERDTreeQuitOnOpen = 1 let g:NERDTreeDirArrows = 1 + let g:NERDTreeDirArrowExpandable = '+' + let g:NERDTreeDirArrowCollapsible = '-' let g:NERDTreeIgnore = ['\.o$', '\.so$', '\.tsk$'] - map :NERDTreeToggle - map :NERDTreeFind + map at :NERDTreeToggle + "map am :NERDTreeFind " " :A switches to the header file (or vise versa) @@ -463,7 +490,7 @@ if filereadable(expand("~/.vim/bundle/Vundle.vim/README.md")) let g:alternateExtensions_h = "cpp,c" let g:alternateExtensions_cpp = "h" let g:alternateExtensions_c = "h" - + map ah :A " " Comment code.