From: R. Steve McKown Date: Mon, 8 Jun 2015 21:04:04 +0000 (-0600) Subject: No need to link ~/.vimrc X-Git-Url: https://oss.titaniummirror.com/gitweb?p=smckown%2Fdotfiles.git;a=commitdiff_plain;h=b4b5b5dcc5cff6d35255cf9230426ba1a07c2b8e No need to link ~/.vimrc Because VIM 7.4 (and maybe earlier) looks for the .vimrc file in $HOME/.vimrc and $HOME/vim/.vimrc on Linux, there is no need to make a separate link for .vimrc if vimrc is in vim/. --- diff --git a/install.sh b/install.sh index d2331cd..e2365a5 100755 --- a/install.sh +++ b/install.sh @@ -27,7 +27,6 @@ cd ~ # to run different commands depending upon the host OS. dolink .dotfiles/vim .vim -dolink .dotfiles/vimrc .vimrc # ranger rewrites its bookmarks file and undoes the symlink on each run... #dolink ~/.dotfiles/ranger/bookmarks .config/ranger/bookmarks dolink ~/.dotfiles/ranger/rc.conf .config/ranger/rc.conf diff --git a/vim/vimrc b/vim/vimrc new file mode 100644 index 0000000..68d687e --- /dev/null +++ b/vim/vimrc @@ -0,0 +1,378 @@ +" smckown .vimrc file + +" Tricky to get a nice terminal color scheme that works well in both vim and +" gvim. Step 1 is to ensure that vi knows the underlying device is 256 color +" capable. The solution of setting xterm: +" TERM=xterm-256color in .bashrc: +" if [[ $TERM == xterm && $COLORTERM == gnome* ]]; then +" export TERM=xterm-256color +" fi +" ... works for vi, but seems to cause problems with the terminal pager. +" Setting t_Co at the very top of vimrc so all the plugins see the setting +" seems to be working the best. +set t_Co=256 + +" All addons managed via pathogen +filetype off +runtime bundle/vim-pathogen/autoload/pathogen.vim +call pathogen#infect() +call pathogen#helptags() + +" This .vimrc depends upon the sensible plugin for proper operation. +" Load the sensible plugin immediately so its Y remap can be undone. +runtime! plugin/sensible.vim +nnoremap Y Y + +" Set the correct font for gvim +if has("gui_running") + if has("gui_gtk2") + set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 9 + elseif has("gui_macvim") + set guifont=Menlo\ Regular:h14 + elseif has("gui_win32") + set guifont=Consolas:h11:cANSI + endif +endif + +colors lucius + +" Local listchars def if utf-8 terminal. Otherwise sensible defaults are OK. +if &termencoding ==# 'utf-8' || &encoding ==# 'utf-8' + "let &listchars = tab:»·,trail:· + let &listchars = "tab:»·,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u26ad" +endif + +" Disable certain keys that aren't very helpful +nnoremap +inoremap +vnoremap +nnoremap +nnoremap +nnoremap +nnoremap +inoremap +inoremap +inoremap +inoremap +vnoremap +vnoremap +vnoremap +vnoremap + +" Try out as +map + +" Make tabs and trailing spaces visible. Show them and special chars in gray. +highlight NonText ctermfg=gray guifg=gray +highlight SpecialKey ctermfg=gray guifg=gray +set list + +" Set default indent policy. smarttab, roundshift enabled by sensible +set softtabstop=2 shiftwidth=2 expandtab + +" File type specific settings. +if has("autocmd") + autocmd filetype make setlocal sts=0 sw=8 noexpandtab tw=80 fo-=t fo+=j + autocmd filetype sh,ld setlocal sts=4 sw=4 tw=80 fo-=t fo+=j + autocmd filetype python setlocal sts=4 sw=4 tw=79 fo-=t fo+=j + autocmd filetype html,xml setlocal listchars-=tab:>. tw=80 fo-=t fo+=j + autocmd filetype text,markdown,mkd,md setlocal tw=80 fo-=t fo+=j + autocmd filetype c,cpp,java setlocal tw=80 fo-=t fo+=j + autocmd filetype nesc setlocal syntax=c.doxygen tw=80 fo-=t fo+=j + + " Whitelist for auto-stripping trailing whitespace on buffer write + autocmd BufWritePre *.c,*.h,*.nesc,*.py,*.java,*.sh,make :call StripTrailingWhitespace() + + " Accept .plt and .gnuplot extensions + autocmd BufNewFile,BufRead *.plt,*.gnnuplot setf gnuplot +endif + +" Setup swap/backup/undo +" Note that as of vim 7.4, backupdir // will not expand backup files to a full +" path as is the case with directory and undodir. +let s:dir = expand(has('win32') ? '~/Application Data/Vim' : has('mac') ? + \ '~/Library/Vim' : '~/.local/share/vim') +execute 'set directory^=' . s:dir . '/swap//' +if !isdirectory(s:dir . '/') + call mkdir(s:dir) +endif +if !isdirectory(s:dir . '/swap/') + call mkdir(s:dir . '/swap') +endif +if !isdirectory(s:dir . '/backup/') + call mkdir(s:dir . '/backup') +endif +if !isdirectory(s:dir . '/undo/') + call mkdir(s:dir . '/undo') +endif +if isdirectory(s:dir . '/backup/') + execute 'set backupdir=' . s:dir . '/backup//' + set backup +else + set nobackup +endif +if has('persistent_undo') && isdirectory(s:dir . '/undo/') + execute 'set undodir=' . s:dir . '/undo//' + set undofile +else + set noundofile +endif + +" Local netrw hide list. Sensible default shows .o files, etc. +let g:netrw_list_hide = '\~$,^tags$,\.swp$,\.o$,\.pyc$,\.class$' + +" Preferred local settings +"set visualbell noerrorbells " Bells set to visual only +set novisualbell noerrorbells " Bells set to visual only +set number " Use con to toggle numbers +set relativenumber " Use cor to toggle relative numbers +"set mouse=a " Enable mouse (thinkpad scroll) +set scrolloff=5 " Cursor offset from screen top/bottom +set hidden " Don't warn when hiding a changed buffer +set modeline " Best not to allow per-file override +if exists('+cursorline') + " unimpaired.vim adds change option: coc toggles cursorline + "hi CursorLine cterm=NONE,underline " Underline makes '_' and ' ' alike + "set cursorline " Highlight current line + "nnoremap c :set cursorline! +endif + +" Search options +" unimpaired.vim adds change option: coh toggles hlsearch +set ignorecase smartcase nohlsearch + +" Ignore files +set wildignore=*.swp,*.bak,*.o,*.pyc,*.class,*.a,*.so + +" Mapping for paste toggle +nnoremap :set invpaste paste? +set pastetoggle= + +" Use Q for formatting the current paragraph (or selection) +vmap Q gq +nmap Q gqap + +" Intuitive window navigation +map h +map j +map k +map l + +" Window resizing +nnoremap :vertical resize -1 +nnoremap :vertical resize +1 +nnoremap :resize +1 +nnoremap :resize -1 + +" w!! to write file with sudo +cmap w!! w!sudo tee % >/dev/null + +" Stuff for supporting ctags. Need a better way to select the right ctags +" set tags=/usr/include/tags,./tags,./../tags,./../**/tags +set tags=tags;/ + +" %% on an ex command line expands to the dir path of the current buffer +cnoremap %% getcmdtype() == ':' ? expand('%:h').'/' : '%%' + +" Create some edit maps for opening new files +map ew :e %% +map es :sp %% +map ev :vsp %% +map et :tabe %% + +" Make and g] work like g, which uses :tjump +nnoremap g] g +nnoremap g + +" Spell check +" unimpaired.vim adds change option: cos toggles spell +"nmap s :set spell! :set spell? +set spelllang=en + +" Toggle numbers on and off +" unimpaired.vim adds change option: con toggles numbers +"nmap n :set number! + +" Toggle word wrap +" unimpaired.vim adds change option: cow toggles wrap +"nmap w :set wrap! :set wrap? + +" Custom statusline +set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P + +if has("autocmd") + " Auto-close fugitive buffers + autocmd BufReadPost fugitive://* set bufhidden=delete + + " Navigate up one level from fugitive trees and blobs + autocmd User fugitive + \ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' | + \ nnoremap .. :edit %:h | + \ endif +endif + +" EasyGrep +" To ignore tags file, use system grep. +let g:EasyGrepCommand=1 +let g:EasyGrepFilesToExclude='tags' + +" Gitv settings +set lazyredraw +let g:Gitv_OpenHorizontal = 1 +let g:Gitv_DoNotMapCtrlKey = 1 +let g:Gitv_OpenPreviewOnLaunch = 1 +nmap gv :Gitv --all +nmap gV :Gitv! --all +vmap gV :Gitv! --all + +" Reduce EasyMotion functionality; use single Leader to activate +" map (easymotion-prefix) +let g:EasyMotion_do_mapping = 0 +" Map multi input search to s. Not wise to map to / because the +" performance of easymotion-sn on large files is very slow. +nmap s (easymotion-sn) +xmap s (easymotion-sn) +omap s (easymotion-sn) +" These are the uni-directional mappings. They are faster. +"nmap f (easymotion-f) +"nmap F (easymotion-F) +"nmap w (easymotion-w) +"nmap b (easymotion-b) +"nmap W (easymotion-W) +"nmap B (easymotion-B) +"nmap e (easymotion-e) +"nmap E (easymotion-E) +"nmap ge (easymotion-ge) +"nmap gE (easymotion-gE) +"nmap j (easymotion-j) +"nmap k (easymotion-k) +"nmap n (easymotion-n) +"nmap N (easymotion-N) +" These are the bi-directional mappings. They are more flexible but slower. +nmap f (easymotion-bd-f) +nmap F (easymotion-bd-f) +nmap w (easymotion-bd-w) +nmap b (easymotion-bd-w) +nmap W (easymotion-bd-W) +nmap B (easymotion-bd-W) +nmap e (easymotion-bd-e) +nmap E (easymotion-bd-E) +nmap ge (easymotion-bd-e) +nmap gE (easymotion-bd-E) +nmap j (easymotion-bd-jk) +nmap k (easymotion-bd-jk) +nmap n (easymotion-bd-n) +nmap N (easymotion-bd-n) + +" Airline configuration +" Single character mode, since showmode is set +let g:airline_powerline_fonts = 1 +let g:airline_mode_map = { + \ '__' : '-', + \ 'n' : 'N', + \ 'i' : 'I', + \ 'R' : 'R', + \ 'c' : 'C', + \ 'v' : 'V', + \ 'V' : 'V', + \ '' : 'V', + \ 's' : 'S', + \ 'S' : 'S', + \ '' : 'S', + \ } +" Customize sections +let g:airline_section_x = airline#section#create(['filetype']) +let g:airline_section_y = airline#section#create(['ffenc']) +let g:airline_section_z = airline#section#create(['linenr', ':%3c ']) +let g:airline#extensions#whitespace#checks = [ 'trailing' ] +" Minimize hunks summary under version control +let g:airline#extensions#hunks#non_zero_only = 1 +" tabline shows buffers +let g:airline#extensions#tabline#enabled = 1 +let g:airline#extensions#tabline#buffer_min_count = 2 +let g:airline#extensions#tabline#buffer_idx_mode = 1 +nmap 1 AirlineSelectTab1 +nmap 2 AirlineSelectTab2 +nmap 3 AirlineSelectTab3 +nmap 4 AirlineSelectTab4 +nmap 5 AirlineSelectTab5 +nmap 6 AirlineSelectTab6 +nmap 7 AirlineSelectTab7 +nmap 8 AirlineSelectTab8 +nmap 9 AirlineSelectTab9 + +" Highlight only long lines +" This solution has two problems: +" 1. On first file edit, the status bar does not render until a key is pressed +" 2. When creating new lines the last column isn't known until it's arrived +"augroup collumnLimit +" autocmd! +" autocmd BufEnter,WinEnter,FileType scala,java,c,nesc,make +" \ highlight CollumnLimit ctermbg=LightGrey guibg=LightGrey +" let collumnLimit = 79 +" let pattern = +" \ '\%<' . (collumnLimit+1) . 'v.\%>' . collumnLimit . 'v' +" autocmd BufEnter,WinEnter,FileType scala,java,c,nesc,make +" \ let w:m1=matchadd('CollumnLimit', pattern, -1) +"augroup END + +" The simpler solution to the above, which generates a column +if exists('+colorcolumn') + if v:version >= 703 + " Set color column relative to defined textwidth. + " Highlights the column immediately after the last valid. + set colorcolumn=+1 + else + set colorcolumn=80 + endif +else + au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1) +endif + +" delimitMate +let g:delimitMate_matchpairs = "{:},[:],(:)" +let g:delimitMate_autoclose = 1 +let g:delimitMate_expand_cr = 1 +let g:delimitMate_expand_space = 1 +nnoremap coa :DelimitMateSwitch + +" Rainbow Parenthesis -- off by default but set toggle +nnoremap cop :RainbowParenthesesToggle + +" Turn on doxygen syntax highlighting for C, C++, C# and IDL files. +let g:load_doxygen_syntax=1 + +" Use / to gain omnicomplete html tag completion +imap / + +nnoremap W :call StripTrailingWhitespace() +function! StripTrailingWhitespace() + " Save last search, and cursor position. + let _s=@/ + let l = line(".") + let c = col(".") + " Perform the substitution. + %s/\s\+$//e + " Restore last search and cursor position. + let @/=_s + call cursor(l, c) +endfunction + +" Implement 'cot' -- Toggle formatoption 't' -- wrap texts to textwidth +nnoremap cot :call ToggleFormatOptionT() +function! ToggleFormatOptionT() + let tmp = substitute(&formatoptions, 't', '', '') + if &formatoptions == tmp + set fo+=t + :echo "Enable text wrap" + else + set fo-=t + :echo "Disable text wrap" + endif +endfunction + +" Insert date and time in insert mode. Have to use the native , not +" its re-mapped version +imap d =strftime("%Y%m%d") +imap D =strftime("%Y-%m-%d") +imap t =strftime("%H:%M:%S") diff --git a/vimrc b/vimrc deleted file mode 100644 index 68d687e..0000000 --- a/vimrc +++ /dev/null @@ -1,378 +0,0 @@ -" smckown .vimrc file - -" Tricky to get a nice terminal color scheme that works well in both vim and -" gvim. Step 1 is to ensure that vi knows the underlying device is 256 color -" capable. The solution of setting xterm: -" TERM=xterm-256color in .bashrc: -" if [[ $TERM == xterm && $COLORTERM == gnome* ]]; then -" export TERM=xterm-256color -" fi -" ... works for vi, but seems to cause problems with the terminal pager. -" Setting t_Co at the very top of vimrc so all the plugins see the setting -" seems to be working the best. -set t_Co=256 - -" All addons managed via pathogen -filetype off -runtime bundle/vim-pathogen/autoload/pathogen.vim -call pathogen#infect() -call pathogen#helptags() - -" This .vimrc depends upon the sensible plugin for proper operation. -" Load the sensible plugin immediately so its Y remap can be undone. -runtime! plugin/sensible.vim -nnoremap Y Y - -" Set the correct font for gvim -if has("gui_running") - if has("gui_gtk2") - set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 9 - elseif has("gui_macvim") - set guifont=Menlo\ Regular:h14 - elseif has("gui_win32") - set guifont=Consolas:h11:cANSI - endif -endif - -colors lucius - -" Local listchars def if utf-8 terminal. Otherwise sensible defaults are OK. -if &termencoding ==# 'utf-8' || &encoding ==# 'utf-8' - "let &listchars = tab:»·,trail:· - let &listchars = "tab:»·,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u26ad" -endif - -" Disable certain keys that aren't very helpful -nnoremap -inoremap -vnoremap -nnoremap -nnoremap -nnoremap -nnoremap -inoremap -inoremap -inoremap -inoremap -vnoremap -vnoremap -vnoremap -vnoremap - -" Try out as -map - -" Make tabs and trailing spaces visible. Show them and special chars in gray. -highlight NonText ctermfg=gray guifg=gray -highlight SpecialKey ctermfg=gray guifg=gray -set list - -" Set default indent policy. smarttab, roundshift enabled by sensible -set softtabstop=2 shiftwidth=2 expandtab - -" File type specific settings. -if has("autocmd") - autocmd filetype make setlocal sts=0 sw=8 noexpandtab tw=80 fo-=t fo+=j - autocmd filetype sh,ld setlocal sts=4 sw=4 tw=80 fo-=t fo+=j - autocmd filetype python setlocal sts=4 sw=4 tw=79 fo-=t fo+=j - autocmd filetype html,xml setlocal listchars-=tab:>. tw=80 fo-=t fo+=j - autocmd filetype text,markdown,mkd,md setlocal tw=80 fo-=t fo+=j - autocmd filetype c,cpp,java setlocal tw=80 fo-=t fo+=j - autocmd filetype nesc setlocal syntax=c.doxygen tw=80 fo-=t fo+=j - - " Whitelist for auto-stripping trailing whitespace on buffer write - autocmd BufWritePre *.c,*.h,*.nesc,*.py,*.java,*.sh,make :call StripTrailingWhitespace() - - " Accept .plt and .gnuplot extensions - autocmd BufNewFile,BufRead *.plt,*.gnnuplot setf gnuplot -endif - -" Setup swap/backup/undo -" Note that as of vim 7.4, backupdir // will not expand backup files to a full -" path as is the case with directory and undodir. -let s:dir = expand(has('win32') ? '~/Application Data/Vim' : has('mac') ? - \ '~/Library/Vim' : '~/.local/share/vim') -execute 'set directory^=' . s:dir . '/swap//' -if !isdirectory(s:dir . '/') - call mkdir(s:dir) -endif -if !isdirectory(s:dir . '/swap/') - call mkdir(s:dir . '/swap') -endif -if !isdirectory(s:dir . '/backup/') - call mkdir(s:dir . '/backup') -endif -if !isdirectory(s:dir . '/undo/') - call mkdir(s:dir . '/undo') -endif -if isdirectory(s:dir . '/backup/') - execute 'set backupdir=' . s:dir . '/backup//' - set backup -else - set nobackup -endif -if has('persistent_undo') && isdirectory(s:dir . '/undo/') - execute 'set undodir=' . s:dir . '/undo//' - set undofile -else - set noundofile -endif - -" Local netrw hide list. Sensible default shows .o files, etc. -let g:netrw_list_hide = '\~$,^tags$,\.swp$,\.o$,\.pyc$,\.class$' - -" Preferred local settings -"set visualbell noerrorbells " Bells set to visual only -set novisualbell noerrorbells " Bells set to visual only -set number " Use con to toggle numbers -set relativenumber " Use cor to toggle relative numbers -"set mouse=a " Enable mouse (thinkpad scroll) -set scrolloff=5 " Cursor offset from screen top/bottom -set hidden " Don't warn when hiding a changed buffer -set modeline " Best not to allow per-file override -if exists('+cursorline') - " unimpaired.vim adds change option: coc toggles cursorline - "hi CursorLine cterm=NONE,underline " Underline makes '_' and ' ' alike - "set cursorline " Highlight current line - "nnoremap c :set cursorline! -endif - -" Search options -" unimpaired.vim adds change option: coh toggles hlsearch -set ignorecase smartcase nohlsearch - -" Ignore files -set wildignore=*.swp,*.bak,*.o,*.pyc,*.class,*.a,*.so - -" Mapping for paste toggle -nnoremap :set invpaste paste? -set pastetoggle= - -" Use Q for formatting the current paragraph (or selection) -vmap Q gq -nmap Q gqap - -" Intuitive window navigation -map h -map j -map k -map l - -" Window resizing -nnoremap :vertical resize -1 -nnoremap :vertical resize +1 -nnoremap :resize +1 -nnoremap :resize -1 - -" w!! to write file with sudo -cmap w!! w!sudo tee % >/dev/null - -" Stuff for supporting ctags. Need a better way to select the right ctags -" set tags=/usr/include/tags,./tags,./../tags,./../**/tags -set tags=tags;/ - -" %% on an ex command line expands to the dir path of the current buffer -cnoremap %% getcmdtype() == ':' ? expand('%:h').'/' : '%%' - -" Create some edit maps for opening new files -map ew :e %% -map es :sp %% -map ev :vsp %% -map et :tabe %% - -" Make and g] work like g, which uses :tjump -nnoremap g] g -nnoremap g - -" Spell check -" unimpaired.vim adds change option: cos toggles spell -"nmap s :set spell! :set spell? -set spelllang=en - -" Toggle numbers on and off -" unimpaired.vim adds change option: con toggles numbers -"nmap n :set number! - -" Toggle word wrap -" unimpaired.vim adds change option: cow toggles wrap -"nmap w :set wrap! :set wrap? - -" Custom statusline -set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P - -if has("autocmd") - " Auto-close fugitive buffers - autocmd BufReadPost fugitive://* set bufhidden=delete - - " Navigate up one level from fugitive trees and blobs - autocmd User fugitive - \ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' | - \ nnoremap .. :edit %:h | - \ endif -endif - -" EasyGrep -" To ignore tags file, use system grep. -let g:EasyGrepCommand=1 -let g:EasyGrepFilesToExclude='tags' - -" Gitv settings -set lazyredraw -let g:Gitv_OpenHorizontal = 1 -let g:Gitv_DoNotMapCtrlKey = 1 -let g:Gitv_OpenPreviewOnLaunch = 1 -nmap gv :Gitv --all -nmap gV :Gitv! --all -vmap gV :Gitv! --all - -" Reduce EasyMotion functionality; use single Leader to activate -" map (easymotion-prefix) -let g:EasyMotion_do_mapping = 0 -" Map multi input search to s. Not wise to map to / because the -" performance of easymotion-sn on large files is very slow. -nmap s (easymotion-sn) -xmap s (easymotion-sn) -omap s (easymotion-sn) -" These are the uni-directional mappings. They are faster. -"nmap f (easymotion-f) -"nmap F (easymotion-F) -"nmap w (easymotion-w) -"nmap b (easymotion-b) -"nmap W (easymotion-W) -"nmap B (easymotion-B) -"nmap e (easymotion-e) -"nmap E (easymotion-E) -"nmap ge (easymotion-ge) -"nmap gE (easymotion-gE) -"nmap j (easymotion-j) -"nmap k (easymotion-k) -"nmap n (easymotion-n) -"nmap N (easymotion-N) -" These are the bi-directional mappings. They are more flexible but slower. -nmap f (easymotion-bd-f) -nmap F (easymotion-bd-f) -nmap w (easymotion-bd-w) -nmap b (easymotion-bd-w) -nmap W (easymotion-bd-W) -nmap B (easymotion-bd-W) -nmap e (easymotion-bd-e) -nmap E (easymotion-bd-E) -nmap ge (easymotion-bd-e) -nmap gE (easymotion-bd-E) -nmap j (easymotion-bd-jk) -nmap k (easymotion-bd-jk) -nmap n (easymotion-bd-n) -nmap N (easymotion-bd-n) - -" Airline configuration -" Single character mode, since showmode is set -let g:airline_powerline_fonts = 1 -let g:airline_mode_map = { - \ '__' : '-', - \ 'n' : 'N', - \ 'i' : 'I', - \ 'R' : 'R', - \ 'c' : 'C', - \ 'v' : 'V', - \ 'V' : 'V', - \ '' : 'V', - \ 's' : 'S', - \ 'S' : 'S', - \ '' : 'S', - \ } -" Customize sections -let g:airline_section_x = airline#section#create(['filetype']) -let g:airline_section_y = airline#section#create(['ffenc']) -let g:airline_section_z = airline#section#create(['linenr', ':%3c ']) -let g:airline#extensions#whitespace#checks = [ 'trailing' ] -" Minimize hunks summary under version control -let g:airline#extensions#hunks#non_zero_only = 1 -" tabline shows buffers -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tabline#buffer_min_count = 2 -let g:airline#extensions#tabline#buffer_idx_mode = 1 -nmap 1 AirlineSelectTab1 -nmap 2 AirlineSelectTab2 -nmap 3 AirlineSelectTab3 -nmap 4 AirlineSelectTab4 -nmap 5 AirlineSelectTab5 -nmap 6 AirlineSelectTab6 -nmap 7 AirlineSelectTab7 -nmap 8 AirlineSelectTab8 -nmap 9 AirlineSelectTab9 - -" Highlight only long lines -" This solution has two problems: -" 1. On first file edit, the status bar does not render until a key is pressed -" 2. When creating new lines the last column isn't known until it's arrived -"augroup collumnLimit -" autocmd! -" autocmd BufEnter,WinEnter,FileType scala,java,c,nesc,make -" \ highlight CollumnLimit ctermbg=LightGrey guibg=LightGrey -" let collumnLimit = 79 -" let pattern = -" \ '\%<' . (collumnLimit+1) . 'v.\%>' . collumnLimit . 'v' -" autocmd BufEnter,WinEnter,FileType scala,java,c,nesc,make -" \ let w:m1=matchadd('CollumnLimit', pattern, -1) -"augroup END - -" The simpler solution to the above, which generates a column -if exists('+colorcolumn') - if v:version >= 703 - " Set color column relative to defined textwidth. - " Highlights the column immediately after the last valid. - set colorcolumn=+1 - else - set colorcolumn=80 - endif -else - au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1) -endif - -" delimitMate -let g:delimitMate_matchpairs = "{:},[:],(:)" -let g:delimitMate_autoclose = 1 -let g:delimitMate_expand_cr = 1 -let g:delimitMate_expand_space = 1 -nnoremap coa :DelimitMateSwitch - -" Rainbow Parenthesis -- off by default but set toggle -nnoremap cop :RainbowParenthesesToggle - -" Turn on doxygen syntax highlighting for C, C++, C# and IDL files. -let g:load_doxygen_syntax=1 - -" Use / to gain omnicomplete html tag completion -imap / - -nnoremap W :call StripTrailingWhitespace() -function! StripTrailingWhitespace() - " Save last search, and cursor position. - let _s=@/ - let l = line(".") - let c = col(".") - " Perform the substitution. - %s/\s\+$//e - " Restore last search and cursor position. - let @/=_s - call cursor(l, c) -endfunction - -" Implement 'cot' -- Toggle formatoption 't' -- wrap texts to textwidth -nnoremap cot :call ToggleFormatOptionT() -function! ToggleFormatOptionT() - let tmp = substitute(&formatoptions, 't', '', '') - if &formatoptions == tmp - set fo+=t - :echo "Enable text wrap" - else - set fo-=t - :echo "Disable text wrap" - endif -endfunction - -" Insert date and time in insert mode. Have to use the native , not -" its re-mapped version -imap d =strftime("%Y%m%d") -imap D =strftime("%Y-%m-%d") -imap t =strftime("%H:%M:%S")