X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=vimrc;h=81c8f1b8132ac7e7711b7e05e208956c47106a36;hb=2020e853579397d5379da962b82bb85c64d39856;hp=1c64c8efd2b1fe429786a58d42592eab804e0422;hpb=1c0839eb69ff09c6af460191a85d534a71ec4e7b;p=config%2Fdotfiles.git diff --git a/vimrc b/vimrc index 1c64c8e..81c8f1b 100644 --- a/vimrc +++ b/vimrc @@ -69,8 +69,8 @@ set history=1000 " Increase number of possible undos. set undolevels=1000 +" Remember marks (including the last cursor position) for more files. if has('viminfo') - " Remember marks (including the last cursor position) for more files. set viminfo^='1000 endif @@ -88,6 +88,23 @@ if has('autocmd') endif +" HELPER FUNCTIONS + +" Check if the given syntax group is available. Thanks to bairui in #vim on +" Freenode (2012-02-19 01:15 CET) for the try/catch silent highlight idea. +if has('eval') + function! s:HasSyntaxGroup(group) + try + execute 'silent highlight ' . a:group + " \a = [A-Za-z] + catch /^Vim\%((\a\+)\)\=:E411/ " 'highlight group not found' + return 0 + endtry + return 1 + endfunction +endif + + " EDIT SETTINGS " Enable automatic file detection, plugin and indention support. @@ -148,7 +165,7 @@ if has('folding') " folding which is not what I want endif -" Only check for case if the searched word contains a capital character. +" Only check case if the searched word contains a capital character. set ignorecase set smartcase @@ -162,7 +179,8 @@ if exists('+spell') && has('syntax') endif " Allow buffers with changes to be hidden. Very important for effective -" editing with multiple buffers. +" editing with multiple buffers. Prevents the "E37: No write since last change +" (add ! to override)" warning. set hidden @@ -172,9 +190,14 @@ set hidden " colors for a dark terminal. set background=dark +" Use my color scheme if 256 colors are available. +if &t_Co == 256 + colorscheme simon +endif + " Display line numbers. set number -" But use as little space as necessary for the numbers column. Thanks to James +" But use as little space as possible for the numbers column. Thanks to James " Vega (http://git.jamessan.com/?p=etc/vim.git;a=summary). if exists('+numberwidth') set numberwidth=1 @@ -198,14 +221,28 @@ endif " remove the highlighting until the next search. set hlsearch -" Display tabs, trailing space, non breakable spaces and long lines (when -" wrapping is disabled). +" Display some special characters. set list -set listchars=trail:-,extends:> +set listchars= +" Display tabs as ">--------". +set listchars+=tab:>- +" Display trailing whitespace as "-". +set listchars+=trail:- +" Display markers for long lines when wrapping is disabled. +set listchars+=extends:>,precedes:< +" Display non-breakable space as "!". if v:version >= 700 set listchars+=nbsp:! endif +" Don't draw the vertical split separator by using space as character. Thanks +" to scp1 in #vim on Freenode (2012-06-16 16:12 CEST) for the idea to use a +" non-breakable space. But a simple space works as well, as long as the +" current color scheme is not reset. +if has('windows') && has('folding') + set fillchars+=vert:\ " comment to prevent trailing whitespace +endif + if has('statusline') " Always display the status line even if there is only one window. set laststatus=2 @@ -321,6 +358,7 @@ endif " Write before suspending, thanks to deryni in #vim on Freenode (2011-05-09 " 20:02 CEST). To suspend without saving either unmap this or use :stop. +" Only the current buffer is written. nnoremap :update:stop " 2 gives more verbose information, use it by default. Thanks to NCS_One @@ -335,7 +373,7 @@ nmap - " Go to next and previous buffer. Thanks to elik in #vim on Freenode " (2010-05-16 18:38 CEST) for this idea. nnoremap gb :bnext -nnoremap gB :bprev +nnoremap gB :bprevious " Fast access to buffers. nnoremap 1 :1buffer @@ -472,9 +510,11 @@ endif " ABBREVIATIONS -" Fix some of my spelling mistakes. -iabbrev relle reelle -iabbrev reele reelle +" Fix some of my spelling mistakes (German). +inoreabbrev relle reelle +inoreabbrev reele reelle +" Fix some of my spelling mistakes (English). +inoreabbrev completly completely " SYNTAX SETTINGS @@ -513,9 +553,15 @@ if has('syntax') " Highlight lines longer than 78 characters. Thanks to Tony Mechelynck " from the Vim mailing list. It can easily be " disabled when necessary with :2match (in Vim >= 700). - if exists(':2match') - 2match Todo /\%>78v./ - else + if !&diff && exists(':2match') + " Use ColorColumn for overlong lines if available and my color + " scheme is used. + if &t_Co == 256 && HasSyntaxGroup('ColorColumn') + 2match ColorColumn /\%>78v./ + else + 2match Todo /\%>78v./ + endif + elseif !&diff match Todo /\%>78v./ endif @@ -539,6 +585,12 @@ if has('syntax') execute ' for l:x in l:spaces' \ '| call matchadd("Error", "\\%u" . l:x)' \ '| endfor' + +" Special highlight for tabs to reduce their visibility in contrast to other +" SpecialKey characters (e.g. ^L). + if &t_Co == 256 && HasSyntaxGroup('specialKeyTab') + call matchadd('specialKeyTab', '\t') + endif endif endfunction " Enable highlights for the current and all new windows. Thanks to bairui in @@ -552,6 +604,8 @@ if has('syntax') " Settings for specific filetypes. + " C + let g:c_no_if0_fold = 1 " fix weird double fold in #if0 in recent versions " Haskell. let g:hs_highlight_delimiters = 1 let g:hs_highlight_boolean = 1 @@ -586,11 +640,17 @@ if has('eval') silent! execute 'call pathogen#runtime_append_all_bundles()' endif +" Settings for securemodelines. + " Only allow items I need (also includes spl which is not enabled by + " default). + let g:secure_modelines_allowed_items = ['ft', 'spl', 'fdm', + \ 'sw', 'sts', 'noet'] + " Settings for the NERD commenter. " Don't create any mappings I don't want to use. let g:NERDCreateDefaultMappings = 0 " Map toggle comment. - map NERDCommenterToggle + nmap NERDCommenterToggle " XPTemplate settings. " Try to maintain snippet rendering even after editing outside of a @@ -669,7 +729,7 @@ if has('autocmd') \ setlocal textwidth=72 " Use the same comment string as for Vim files in Vimperator files. autocmd FileType vimperator setlocal commentstring=\"%s -" Use tex compiler for (La)TeX files. +" Use TeX compiler for (La)TeX files. autocmd FileType tex compiler tex " FTDETECT AUTO COMMANDS