.vimrc review

This commit is contained in:
Vahagn Khachatryan
2016-04-08 14:06:50 -04:00
parent 2e69a93b14
commit 8d90b9f83f
2 changed files with 86 additions and 42 deletions

View File

@@ -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

View File

@@ -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 <F11> 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 <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
"map <silent> <C-F3> :tabnew<CR>
"
" F4 grep the word under cursor.
" Grep the word under cursor.
"
map <C-F3> :execute "grep " . expand("<cword>") . " -r --include \*.h --include \*.cpp --include \*.c --include \*.f ." <Bar> cw<CR>
" 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("<cword>")." -r ." <Bar> cw<CR>
"
" Loads CF5Compile
@@ -365,8 +382,8 @@ map <C-F3> :execute "grep " . expand("<cword>") . " -r --include \*.h --include
if !exists('*CF5Compile')
runtime plugin/cf5-compiler.vim
endif
map <silent> <C-F5> :call CF5Compile(1)<CR>
map <silent> <F5> :call CF5Compile(0)<CR>
map <silent> a4 :call CF5CompileOnly()<CR>
map <silent> a5 :call CF5CompileAndRun()<CR>
"
" 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 <C-U> <C-G>u<C-U>
"
noremap <Up> gk
noremap <Down> gj
imap <Up> <C-O>gk
imap <Down> <C-O>gj
"imap <Up> <C-O>gk
"imap <Down> <C-O>gj
"
" Working with tabs especially if using console version.
"
@@ -389,6 +406,14 @@ nnoremap tl :tablast<CR>
nnoremap tm :tabm<Space>
nnoremap td :tabclose<CR>
"
" 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<CR>
"
" 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 <C-b> :BuffergatorToggle<CR>
map <C-B> :BuffergatorTabsToggle<CR>
map ab :BuffergatorToggle<CR>
"map at :BuffergatorTabsToggle<CR>
"
"
@@ -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 <C-n> :NERDTreeToggle<CR>
map <C-m> :NERDTreeFind<CR>
map at :NERDTreeToggle<CR>
"map am :NERDTreeFind<CR>
"
" :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<CR>
"
" Comment code.