From 037f9763a1d4a6e82fb78e4a29ddc722d2bd0f92 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 25 Sep 2011 23:34:31 +0200 Subject: [PATCH 01/16] vimrc: Fix and improve perl syntax settings. Setting it in an FileType autocmd doesn't work as it seems the variable gets updated too late. --- vimrc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vimrc b/vimrc index 717105d..83996b3 100644 --- a/vimrc +++ b/vimrc @@ -360,6 +360,15 @@ if has('syntax') if v:version > 701 || (v:version == 701 && has('patch42')) call matchadd('Todo', '\(TODO\|FIXME\|CHANGED\|XXX\)') endif + +" Settings for specific filetypes. + + " Perl. + let g:perl_fold = 1 + let g:perl_fold_blocks = 1 + let g:perl_nofold_packages = 1 + let g:perl_include_pod = 1 " syntax coloring for PODs + endif @@ -439,9 +448,6 @@ if has('autocmd') " the recommendation for git commit messages (http://tpope.net/node/106). autocmd FileType gitcommit let g:secure_modelines_allowed_items = [] | \ setlocal textwidth=72 -" Allow folding in perl. - autocmd FileType perl let perl_fold = 1 | - \ let perl_fold_blocks = 1 " Use the same comment string as for Vim files in Vimperator files. autocmd FileType vimperator setlocal commentstring=\"%s -- 2.44.2 From 51bdb20b6c613f6b29b1e59d6077743b0ce2da6d Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 26 Sep 2011 00:07:49 +0200 Subject: [PATCH 02/16] vimrc: Fix compatibility for older Vim versions. Works fine with Vim 6.4. --- vimrc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vimrc b/vimrc index 83996b3..3fa27cb 100644 --- a/vimrc +++ b/vimrc @@ -345,7 +345,9 @@ if has('syntax') " Don't highlight more than 500 columns as I normally don't have that long " lines and they slow down syntax coloring. Thanks to Derek Wyatt " (http://www.derekwyatt.org/vim/the-vimrc-file/). - set synmaxcol=500 + if exists('+synmaxcol') + set synmaxcol=500 + endif " Highlight lines longer than 78 characters. Thanks to Tony Mechelynck " from the Vim mailing list. It can easily be @@ -377,8 +379,8 @@ endif " Use pathogen which allows one 'runtimepath' entry per plugin. This makes " installing/removing/updating plugins simple. (Used for plugins with more " than one file.) -if has('eval') - call pathogen#runtime_append_all_bundles() +if has('eval') && v:version >= 700 + execute 'call pathogen#runtime_append_all_bundles()' endif " Settings for the NERD commenter. @@ -431,7 +433,9 @@ if has('autocmd') " Automatically disable 'paste' mode when leaving insert mode. Thanks to " Raimondi in #vim on Freenode (2010-08-14 23:01 CEST). Very useful as I only " want to paste once and then 'paste' gets automatically unset. - autocmd InsertLeave * set nopaste + if exists('#InsertLeave') + autocmd InsertLeave * set nopaste + endif " AFTER/FTPLUGIN AUTO COMMANDS -- 2.44.2 From 92c63c90edb631e3144ab488c8356fda26fbfd7e Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 26 Sep 2011 00:08:30 +0200 Subject: [PATCH 03/16] vimrc: Use exists() instead of checking the version. --- vimrc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vimrc b/vimrc index 3fa27cb..a58741d 100644 --- a/vimrc +++ b/vimrc @@ -53,7 +53,7 @@ set history=1000 set undolevels=1000 " Use strong encryption if possible, also used for swap/undo files. -if v:version >= 703 +if exists('+cryptmethod') set cryptmethod=blowfish endif @@ -120,7 +120,7 @@ set smartcase " Activate spell checking, use English as default. Don't use spell checking " when diffing. -if v:version >= 700 && has('syntax') && !&diff +if exists('+spell') && has('syntax') && !&diff set spell set spelllang=en_us endif @@ -140,7 +140,7 @@ set background=dark set number " But use as little space as necessary for the numbers column. Thanks to James " Vega (http://git.jamessan.com/?p=etc/vim.git;a=summary). -if v:version >= 700 +if exists('+numberwidth') set numberwidth=1 endif " Display the ruler with current line/file position. If 'statusline' is used @@ -154,7 +154,7 @@ set showcmd set lazyredraw " Visualize the line the cursor is currently in. -if v:version >= 700 +if exists('+cursorline') set cursorline endif @@ -257,7 +257,7 @@ nnoremap O po " Maps to change spell language between English and German and disable spell " checking. -if v:version >= 700 +if exists('+spell') noremap sn :set nospell noremap se :set spell spelllang=en_us noremap sd :set spell spelllang=de_de @@ -352,14 +352,14 @@ 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 v:version >= 700 + if exists(':2match') 2match Todo /\%>78v./ else match Todo /\%>78v./ endif " Highlight TODO, FIXME, CHANGED and XXX in all documents. - if v:version > 701 || (v:version == 701 && has('patch42')) + if exists('*matchadd') call matchadd('Todo', '\(TODO\|FIXME\|CHANGED\|XXX\)') endif -- 2.44.2 From d64d99e10cfeb62386e5e92620147e7817c01642 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 26 Sep 2011 00:34:24 +0200 Subject: [PATCH 04/16] vimrc: Call matchadd() multiple times. Instead of using \( ... \| ... \) in the match. I guess this is faster and it's easier extensible. --- vimrc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vimrc b/vimrc index a58741d..d0e67e8 100644 --- a/vimrc +++ b/vimrc @@ -358,9 +358,11 @@ if has('syntax') match Todo /\%>78v./ endif -" Highlight TODO, FIXME, CHANGED and XXX in all documents. if exists('*matchadd') - call matchadd('Todo', '\(TODO\|FIXME\|CHANGED\|XXX\)') +" Highlight TODO, FIXME, CHANGED and XXX in all documents. + for x in ['TODO', 'FIXME', 'CHANGED', 'XXX'] + call matchadd('Todo', x) + endfor endif " Settings for specific filetypes. -- 2.44.2 From 3a5fe52f6940f7e57f99ce80b5098903ec9e0837 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 26 Sep 2011 00:36:32 +0200 Subject: [PATCH 05/16] vimrc: Also highlight REMOVED and DELETED. --- vimrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vimrc b/vimrc index d0e67e8..4b4e03c 100644 --- a/vimrc +++ b/vimrc @@ -359,8 +359,8 @@ if has('syntax') endif if exists('*matchadd') -" Highlight TODO, FIXME, CHANGED and XXX in all documents. - for x in ['TODO', 'FIXME', 'CHANGED', 'XXX'] +" Highlight some important keywords in all documents. + for x in ['TODO', 'XXX', 'FIXME', 'CHANGED', 'REMOVED', 'DELETED'] call matchadd('Todo', x) endfor endif -- 2.44.2 From 85f5b4d24533e0375798351005a22b0fea6880c4 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 26 Sep 2011 00:37:38 +0200 Subject: [PATCH 06/16] vimrc: Mark non 0x20 unicode whitespace as error. Unicode whitespace is not normally used in most documents and may cause problems for some programs. --- vimrc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vimrc b/vimrc index 4b4e03c..5aa3e20 100644 --- a/vimrc +++ b/vimrc @@ -363,6 +363,14 @@ if has('syntax') for x in ['TODO', 'XXX', 'FIXME', 'CHANGED', 'REMOVED', 'DELETED'] call matchadd('Todo', x) endfor + +" Highlight unicode whitespace which is no normal whitespace (0x20). + for x in ['00a0', '1680', '180e', '2000', '2001', '2002', '2003', + \ '2004', '2005', '2006', '2007', '2008', '2009', '200a', + \ '200b', '200c', '200d', '202f', '205f', '2060', '3000', + \ 'feff'] + call matchadd('Error', '\%u' . x) + endfor endif " Settings for specific filetypes. -- 2.44.2 From 95ff8daef8ecc077751a92b87ba2c37a71e9887c Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Thu, 6 Oct 2011 05:57:53 +0200 Subject: [PATCH 07/16] vimrc: Minor documentation update. --- vimrc | 1 + 1 file changed, 1 insertion(+) diff --git a/vimrc b/vimrc index 5aa3e20..6048d8e 100644 --- a/vimrc +++ b/vimrc @@ -419,6 +419,7 @@ endif " twice. if has('autocmd') augroup vimrc +" Remove all autocmds from the current group. autocmd! " Go to last position of opened files. Taken from :help last-position-jump. -- 2.44.2 From 97795ba58c0428e329d2df3b82f82f307cfe4735 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 31 Oct 2011 21:28:41 +0100 Subject: [PATCH 08/16] gvimrc: Don't display menu and toolbars. --- gvimrc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gvimrc b/gvimrc index 3d60616..bbf75f4 100644 --- a/gvimrc +++ b/gvimrc @@ -4,8 +4,15 @@ " Stop the cursor from blinking. set guicursor+=a:blinkon0 +" Don't display the menu. +set guioptions-=m " Don't display the toolbar. set guioptions-=T +" Don't display any scrollbars, they just waste space. +set guioptions-=r +set guioptions-=R +set guioptions-=l +set guioptions-=L " Increase window size to 110x25. set columns=110 -- 2.44.2 From 4e3363c35b35433bb7135841cfe27e57c72ad6bd Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 30 Oct 2011 14:32:49 +0100 Subject: [PATCH 09/16] vimrc: Fix exists() check for InsertLeave. Broken in 51bdb20b6c613f6b29b1e59d6077743b0ce2da6d. --- vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vimrc b/vimrc index 6048d8e..d950d07 100644 --- a/vimrc +++ b/vimrc @@ -444,7 +444,7 @@ if has('autocmd') " Automatically disable 'paste' mode when leaving insert mode. Thanks to " Raimondi in #vim on Freenode (2010-08-14 23:01 CEST). Very useful as I only " want to paste once and then 'paste' gets automatically unset. - if exists('#InsertLeave') + if exists('##InsertLeave') autocmd InsertLeave * set nopaste endif -- 2.44.2 From ef2016e2c667d1a6e48b93e0eae4cacf8998fb79 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 19 Nov 2011 11:49:19 +0100 Subject: [PATCH 10/16] vimrc: Save changes when running :mak[e]. --- vimrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vimrc b/vimrc index d950d07..dd6ba12 100644 --- a/vimrc +++ b/vimrc @@ -448,6 +448,9 @@ if has('autocmd') autocmd InsertLeave * set nopaste endif +" Save changes when running :mak[e] before 'makeprg' is called. + autocmd QuickFixCmdPre * write + " AFTER/FTPLUGIN AUTO COMMANDS " Disable spell checking for files which don't need it. -- 2.44.2 From 6ec52f7a8f36cf8ea2cfdf3b50640f37099d2294 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 19 Nov 2011 11:49:53 +0100 Subject: [PATCH 11/16] vimrc: Use tex compiler for (La)TeX files. --- vimrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vimrc b/vimrc index dd6ba12..e48c219 100644 --- a/vimrc +++ b/vimrc @@ -468,6 +468,8 @@ 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. + autocmd FileType tex compiler tex " FTDETECT AUTO COMMANDS -- 2.44.2 From 1c420fe0d57fd9e8bfbe59ab3fccca48f2f9ae2b Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 19 Nov 2011 12:01:43 +0100 Subject: [PATCH 12/16] vimrc: Add new text-objects ii ai for indented text. --- vimrc | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/vimrc b/vimrc index e48c219..e209796 100644 --- a/vimrc +++ b/vimrc @@ -489,3 +489,52 @@ if has('autocmd') augroup END endif + + +" CUSTOM FUNCTIONS + +if has('eval') + " New text-objects ii and ai to work on text with the same indentation. + " Thanks to + " http://vim.wikia.com/index.php?title=Indent_text_object&oldid=27126 + " (visited on 2011-11-19). + onoremap ai :call IndTxtObj(0) + onoremap ii :call IndTxtObj(1) + vnoremap ai :call IndTxtObj(0)gv + vnoremap ii :call IndTxtObj(1)gv + + function! IndTxtObj(inner) + let curline = line(".") + let lastline = line("$") + let i = indent(line(".")) - &shiftwidth * (v:count1 - 1) + let i = i < 0 ? 0 : i + if getline(".") !~ "^\\s*$" + let p = line(".") - 1 + let nextblank = getline(p) =~ "^\\s*$" + while p > 0 + \ && ((i == 0 && !nextblank) + \ || (i > 0 && ((indent(p) >= i + \ && !(nextblank && a:inner)) + \ || (nextblank && !a:inner)))) + - + let p = line(".") - 1 + let nextblank = getline(p) =~ "^\\s*$" + endwhile + normal! 0V + call cursor(curline, 0) + let p = line(".") + 1 + let nextblank = getline(p) =~ "^\\s*$" + while p <= lastline + \ && ((i == 0 && !nextblank) + \ || (i > 0 && ((indent(p) >= i + \ && !(nextblank && a:inner)) + \ || (nextblank && !a:inner)))) + + + let p = line(".") + 1 + let nextblank = getline(p) =~ "^\\s*$" + endwhile + normal! $ + endif + endfunction + +endif -- 2.44.2 From f80a6198b2256b0fcd0e7aa3f3b79fad15d91655 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 19 Nov 2011 12:36:03 +0100 Subject: [PATCH 13/16] vimrc: Make IndTxtObj script local. --- vimrc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vimrc b/vimrc index e209796..04cae91 100644 --- a/vimrc +++ b/vimrc @@ -498,12 +498,12 @@ if has('eval') " Thanks to " http://vim.wikia.com/index.php?title=Indent_text_object&oldid=27126 " (visited on 2011-11-19). - onoremap ai :call IndTxtObj(0) - onoremap ii :call IndTxtObj(1) - vnoremap ai :call IndTxtObj(0)gv - vnoremap ii :call IndTxtObj(1)gv + onoremap ai :call IndTxtObj(0) + onoremap ii :call IndTxtObj(1) + vnoremap ai :call IndTxtObj(0)gv + vnoremap ii :call IndTxtObj(1)gv - function! IndTxtObj(inner) + function! s:IndTxtObj(inner) let curline = line(".") let lastline = line("$") let i = indent(line(".")) - &shiftwidth * (v:count1 - 1) -- 2.44.2 From 3fb48422ab22ba6c60c7db059c1f3cbb77b94142 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 21 Nov 2011 07:51:52 +0100 Subject: [PATCH 14/16] vimrc: Minor cleanup for variables. --- vimrc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vimrc b/vimrc index 04cae91..9294692 100644 --- a/vimrc +++ b/vimrc @@ -22,6 +22,7 @@ set all& " And restore it after all other options were reset. if has('eval') let &runtimepath = s:save_runtimepath + unlet s:save_runtimepath endif " Make sure Vim (and not Vi) settings are used. @@ -321,7 +322,7 @@ endif " Disable Apple style movements in MacVim. if has('gui_macvim') && has('eval') - let macvim_skip_cmd_opt_movement = 1 + let g:macvim_skip_cmd_opt_movement = 1 endif " In case 'hlsearch' is used disable it with . Thanks to frogonwheels and @@ -396,7 +397,7 @@ endif " Settings for the NERD commenter. " Don't create any mappings I don't want to use. if has('eval') - let NERDCreateDefaultMappings = 0 + let g:NERDCreateDefaultMappings = 0 endif " Map toggle comment. map NERDCommenterToggle -- 2.44.2 From 5e135f34e3bcd6414cbf71e42482da6d396c77ce Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 21 Nov 2011 07:52:44 +0100 Subject: [PATCH 15/16] vimrc: Add Haskell syntax settings. --- vimrc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vimrc b/vimrc index 9294692..9e937bc 100644 --- a/vimrc +++ b/vimrc @@ -376,12 +376,16 @@ if has('syntax') " Settings for specific filetypes. + " Haskell. + let g:hs_highlight_boolean = 1 + let g:hs_highlight_types = 1 + let g:hs_highlight_more_types = 1 + " Perl. let g:perl_fold = 1 let g:perl_fold_blocks = 1 let g:perl_nofold_packages = 1 let g:perl_include_pod = 1 " syntax coloring for PODs - endif -- 2.44.2 From 2e2a974decac89fa274c68f0e1d781553e4ee4c1 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 21 Nov 2011 07:58:10 +0100 Subject: [PATCH 16/16] vimrc: Remove unnecessary has('eval'). --- vimrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vimrc b/vimrc index 9e937bc..e645706 100644 --- a/vimrc +++ b/vimrc @@ -321,7 +321,7 @@ if has('mac') || filereadable('/Users/.localized') endif " Disable Apple style movements in MacVim. -if has('gui_macvim') && has('eval') +if has('gui_macvim') let g:macvim_skip_cmd_opt_movement = 1 endif @@ -394,7 +394,7 @@ endif " Use pathogen which allows one 'runtimepath' entry per plugin. This makes " installing/removing/updating plugins simple. (Used for plugins with more " than one file.) -if has('eval') && v:version >= 700 +if v:version >= 700 execute 'call pathogen#runtime_append_all_bundles()' endif -- 2.44.2