@ -58,6 +58,7 @@ if has("unix") || has("mac")
Plugin 'tikhomirov/vim-glsl'
Plugin 'tikhomirov/vim-glsl'
Plugin 'jamessan/vim-gnupg'
Plugin 'jamessan/vim-gnupg'
Plugin 'romainl/vim-cool'
Plugin 'machakann/vim-highlightedyank'
Plugin 'machakann/vim-highlightedyank'
let g :highlightedyank_highlight_duration = 200
let g :highlightedyank_highlight_duration = 200
"[Needed only with old vim versions]"
"[Needed only with old vim versions]"
@ -77,9 +78,10 @@ set number
set relativenumber
set relativenumber
"[Hide/show the white-space and more invisible symbols]"
"[Hide/show the white-space and more invisible symbols]"
set list
set list
set listchars = nbsp :¬, trail :-
set listchars = tab :▸\ , nbsp :¬, trail :-
"set listchars+=tab:│\ ,
" | | + Trailing spaces
set listchars + = tab :▸\ ,
" | + Non breakable spaces
" + Tabulations: `tab xy`, x: first char, y: following chars
set nojoinspaces
set nojoinspaces
"[Indent & Tab/mode-line settings]"
"[Indent & Tab/mode-line settings]"
set breakindent
set breakindent
@ -106,7 +108,6 @@ set textwidth=0
set modeline
set modeline
set modelines = 1
set modelines = 1
set history = 200 " keep 200 lines of command line history
set ruler " show the cursor position all the time
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set showcmd " display incomplete commands
set laststatus = 2
set laststatus = 2
@ -115,6 +116,8 @@ set noshowmode
"[Command mode autocompletion]"
"[Command mode autocompletion]"
set wildmenu
set wildmenu
set wildmode = longest :full , full
set wildmode = longest :full , full
" `------------|---- First complete till longest common string, open wildmenu
" `---- Then, complete next full match
set ttimeout " time out for key codes
set ttimeout " time out for key codes
set ttimeoutlen = 100 " wait up to 100ms after Esc for special key
set ttimeoutlen = 100 " wait up to 100ms after Esc for special key
@ -126,6 +129,20 @@ set history=1000
set nowritebackup
set nowritebackup
set undolevels = 5000
set undolevels = 5000
"[Setup history file]"
set viminfo = %, < 0 , '10 , /16 , :16 , h , f0
" | | | | | | + file marks 0-9,A-Z 0=NOT stored
" | | | | | + disable 'hlsearch' loading viminfo
" | | | | + command-line history saved
" | | | + search history saved
" | | + files marks saved
" | + lines saved each register (old name for <, vi6.2): NOT STORED
" + save/restore buffer list
if ! has ( 'nvim' )
"[Declutter $HOME]"
set viminfo + = n ~ /.vim/ cache /.viminfo
endif
" Show @@@ in the last line if it is truncated.
" Show @@@ in the last line if it is truncated.
set display = truncate
set display = truncate
"[Splitting rules]"
"[Splitting rules]"
@ -202,8 +219,6 @@ nnoremap <leader>o o<Esc>
nnoremap < leader > O O < Esc >
nnoremap < leader > O O < Esc >
"[Clear search highlights]"
"[Clear search highlights]"
nnoremap // :nohlsearch < CR >
nnoremap // :nohlsearch < CR >
" Don't use Ex mode, use Q for formatting.
map Q gq
"[Reflow current paragraph]"
"[Reflow current paragraph]"
"[http://stevelosh.com/blog/2010/09/coming-home-to-vim/]"
"[http://stevelosh.com/blog/2010/09/coming-home-to-vim/]"
nnoremap < silent > < leader > q :call ReflowParagraph ( ) < CR >
nnoremap < silent > < leader > q :call ReflowParagraph ( ) < CR >
@ -242,14 +257,15 @@ endif
"[Reflow current paragraph]"
"[Reflow current paragraph]"
function ! ReflowParagraph ( )
function ! ReflowParagraph ( )
let l :view = winsaveview ( )
let l :view = winsaveview ( )
normal gq ip
normal gw ip
call winrestview ( l :view )
call winrestview ( l :view )
endfunction
endfunction
"[Remove tabs and spaces at the end of lines]"
"[Remove tabs and spaces at the end of lines]"
function ! DeleteTrailingTWS ( )
function ! DeleteTrailingTWS ( )
if &ft = ~ 'diff'
"[Do not clean up trailing spaces in binary mode or in diff files]"
if &binary | | &ft = ~ 'diff'
return
return
end
endif
let l :view = winsaveview ( )
let l :view = winsaveview ( )
silent %s /[ \t]*$/ /g
silent %s /[ \t]*$/ /g
silent %s /\s\+$/ /ge
silent %s /\s\+$/ /ge
@ -268,8 +284,12 @@ endfunction
function ! SwapExtension ( )
function ! SwapExtension ( )
let [rest , ext ] = [expand ( '%:r' ) , expand ( '%:e' ) ]
let [rest , ext ] = [expand ( '%:r' ) , expand ( '%:e' ) ]
if ext = = ? 'h'
if ext = = ? 'h'
let ext = 'cpp'
if filereadable ( rest . '.c' )
elseif ext = = ? 'cpp'
let ext = 'c'
elseif filereadable ( rest . '.cpp' )
let ext = 'cpp'
endif
elseif ext = = ? 'cpp' | | ext = = ? 'c'
let ext = 'h'
let ext = 'h'
"swap between vertex and fragment shader"
"swap between vertex and fragment shader"
elseif ext = = ? 'vsh'
elseif ext = = ? 'vsh'
@ -283,10 +303,9 @@ endfunction
" Only do this part when compiled with support for autocommands.
" Only do this part when compiled with support for autocommands.
if has ( "autocmd" )
if has ( "autocmd" )
" Enable file type detection.
" Enable file type detection. Use the default filetype settings, so that
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" mail gets 'tw' set to 72, 'cindent' is on in C files, etc. Also load
" 'cindent' is on in C files, etc.
" indent files, to automatically do language-dependent indenting.
" Also load indent files, to automatically do language-dependent indenting.
" Revert with ":filetype off".
" Revert with ":filetype off".
filetype plugin indent on
filetype plugin indent on
@ -300,16 +319,20 @@ if has("autocmd")
" (happens when dropping a file on gvim) and for a commit message (it's
" (happens when dropping a file on gvim) and for a commit message (it's
" likely a different one than last time).
" likely a different one than last time).
autocmd BufReadPost *
autocmd BufReadPost *
\ if line ( "'\"" ) > = 1 && line ( "'\"" ) < = line ( "$" ) && &ft ! ~ # 'commit'
\ if line ( "'\"" ) > = 1 && line ( "'\"" ) < = line ( "$" ) && &ft ! ~ # 'commit' |
\ | exe "normal! g`\""
\ exe "normal! g`\"" |
\ | endif
\ endif
augroup END
augroup END
"
"[Do not clean up trailing spaces in binary mode]"
"[Try not to pollute the undo tree (https://vi.stackexchange.com/a/13401)]"
if ! &binary
autocmd BufWritePre *
autocmd BufWritePre * call DeleteTrailingTWS ( )
\ try |
endif
\ undojoin |
\ catch /^Vim\%((\a\+)\)\=:E790/ |
\ finally |
\ call DeleteTrailingTWS ( ) |
\ endtry
if has ( "unix" ) | | has ( "mac" )
if has ( "unix" ) | | has ( "mac" )
autocmd BufWritePost * call ChangeScriptMode ( )
autocmd BufWritePost * call ChangeScriptMode ( )