Difference between revisions of "Vim/.vimrc"

From ArchWiki
< Vim
Jump to: navigation, search
m (Colorscheme: - updated)
(updated vimrc)
Line 100: Line 100:
 
</nowiki>}}
 
</nowiki>}}
  
{{hc|~/.vimrc or /etc/vimrc|<nowiki>
+
The next example should be used in combination with the askapachecode colorscheme below.
" Updated: Wed Feb 22 13:25:23 2012 by galileo@galileo
+
 
 +
{{hc|~/.vimrc or /etc/vimrc|<nowiki>" Updated: Tue Sep  3 14:23:14 2013
 +
" Revision: 188
 +
" Author: galileo@davinci
 +
 
 +
" http://www.askapache.com/linux/fast-vimrc.html
  
 
" For all key mappings like ', .' to reload vimrc
 
" For all key mappings like ', .' to reload vimrc
 
let maplocalleader=','
 
let maplocalleader=','
 +
 +
 +
  
 
" BACKUPS, SWAPFILES, VIEWDIR, TMPDIR  "{{{1
 
" BACKUPS, SWAPFILES, VIEWDIR, TMPDIR  "{{{1
" ================================================================================================================================================================
+
" ====================================================================================
  
" SET RUNTIMEPATH {{{3
+
" SET RUNTIMEPATH {{{4
 
if isdirectory(expand("$HOME/.vim"))
 
if isdirectory(expand("$HOME/.vim"))
let $VIMRUNTIME=expand("$HOME/.vim")
+
  if isdirectory(expand("$HOME/.vim/colors"))
set runtimepath=$VIMRUNTIME
+
          if filereadable(expand("$HOME/colors/askapachecode.vim"))
 +
                let $VIMRUNTIME=expand("$HOME/.vim")
 +
                set runtimepath=$VIMRUNTIME
 +
          endif
 +
  endif
 
endif
 
endif
  
" IF BKDIR IS NOT SET OR EMPTY, SET {{{3
+
"echomsg &runtimepath
 +
"echomsg expand("$VIMRUNTIME")
 +
 
 +
 
 +
" IF BKDIR IS NOT SET OR EMPTY, SET {{{4
 
if $BKDIR == ""
 
if $BKDIR == ""
let $BKDIR=expand("$HOME/.bk")
+
  let $BKDIR=expand("$HOME/.bk")
if !isdirectory(expand("$BKDIR"))
+
  if !isdirectory(expand("$BKDIR"))
call mkdir(expand("$BKDIR"), "p", 0700)
+
          call mkdir(expand("$BKDIR"), "p", 700)
endif
+
  endif
 
endif
 
endif
  
" MAKE DIRS IF mkdir exists {{{3
+
 
 +
" MAKE DIRS IF mkdir exists {{{4
 
if exists("*mkdir")
 
if exists("*mkdir")
if !isdirectory(expand("$BKDIR/.vim/viewdir"))|call mkdir(expand("$BKDIR/.vim/viewdir"), "p", 0700)|endif
+
  let &viewdir=expand("$BKDIR") . "/.vim/viewdir"
if !isdirectory(expand("$BKDIR/.vim/tmp"))|call mkdir(expand("$BKDIR/.vim/tmp"), "p", 0700)|endif
+
  if !isdirectory(expand(&viewdir))|call mkdir(expand(&viewdir), "p", 700)|endif
if !isdirectory(expand("$BKDIR/.vim/backups"))|call mkdir(expand("$BKDIR/.vim/backups"), "p", 0700)|endif
+
  if !isdirectory(expand("$BKDIR/tmp/.vim"))|call mkdir(expand("$BKDIR/tmp/.vim"), "p", 700)|endif
 +
  if !isdirectory(expand("$BKDIR/.vim/backups"))|call mkdir(expand("$BKDIR/.vim/backups"), "p", 700)|endif
 +
  if !isdirectory(expand("$BKDIR/.vim/undos"))|call mkdir(expand("$BKDIR/.vim/undos"), "p", 700)|endif
 
endif
 
endif
  
" SETTINGS USING NEW DIRS {{{3
+
 
 +
" SETTINGS USING NEW DIRS {{{4
 
let &dir=expand("$BKDIR") . "/.vim"
 
let &dir=expand("$BKDIR") . "/.vim"
let &viewdir=expand("$BKDIR") . "/.vim/viewdir"
 
 
let &backupdir=expand("$BKDIR") . "/.vim/backups"
 
let &backupdir=expand("$BKDIR") . "/.vim/backups"
 +
"let &undodir=expand("$BKDIR") . "/.vim/undos"
 +
"set undofile
 
"let &verbosefile=expand("$BKDIR") . "/.vim/vim-messages.
 
"let &verbosefile=expand("$BKDIR") . "/.vim/vim-messages.
  
" VIMINFO {{{3
+
 
" COMMENTED OUT {{{4
+
" VIMINFO {{{4
 +
" COMMENTED OUT {{{5
 
"  "      Maximum number of lines saved for each register
 
"  "      Maximum number of lines saved for each register
 
"  %      When included, save and restore the buffer lis
 
"  %      When included, save and restore the buffer lis
Line 146: Line 168:
 
"  @      Maximum number of items in the input-line history
 
"  @      Maximum number of items in the input-line history
 
"  h      Disable the effect of 'hlsearch' when loading the viminfo
 
"  h      Disable the effect of 'hlsearch' when loading the viminfo
"  n      Name of the viminfo file.  The name must immediately follow the 'n'. Must be the last oneEnvironment variables are expanded when opening the file, not when setting the option
+
"  n      Name of the viminfo file.  The name must immediately follow the 'n'.  
 
"  r      Removable media.  The argument is a string
 
"  r      Removable media.  The argument is a string
 
"  s      Maximum size of an item in Kbyte
 
"  s      Maximum size of an item in Kbyte
"   }}}4 COMMENTED OUT
+
" }}}5 COMMENTED OUT
let &viminfo="%200,'200,/800,h,<500,:500,s150,r/tmp,r" . expand("$BKDIR") . "/.vim/tmp,n" . expand("$BKDIR") ."/.vim/.vinfo"
+
 
 +
let &viminfo="%203,'200,/800,h,<500,:500,s150,r/tmp,r" . expand("$BKDIR") . "/tmp/.vim,n" . expand("$BKDIR") ."/.vim/.vinfo"
 +
" }}}4 ENDOF VIMINFO
 +
 
 +
" --------------------------------------------------- }}}1 ENDOF BACKUPS, SWAPFILES, VIEWDIR, TMPDIR
 +
 
 +
" DYNAMIC SETTINGS / COLORS / TERMINAL {{{1
 +
" ====================================================================================
 +
"echomsg &t_Co
 +
"echomsg &term
 +
 
 +
if &t_Co > 2
 +
 
 +
  if &term =~ "256"
 +
 
 +
          set bg=dark t_Co=256 vb
 +
          let &t_vb="\<Esc>[?5h\<Esc>[?5l"      " flash screen for visual bell
 +
 
 +
          if filereadable(expand("$VIMRUNTIME/colors/askapachecode.vim"))
 +
                colorscheme askapachecode
 +
          elseif filereadable(expand("$HOME/.vim/colors/askapachecode.vim"))
 +
                colorscheme askapachecode
 +
          else
 +
                colorscheme default
 +
          endif
 +
 
 +
  else
 +
          " things like cfdisk, crontab -e, visudo, vless, etc.
 +
          set term=screen-16color
 +
          set t_Co=16
 +
 
 +
  endif
 +
 
 +
  filetype indent plugin on
 +
  syntax on
 +
 
 +
endif
 +
" -------------------------------------------------------------- }}}1 ENDOF DYNAMIC SETTINGS / COLORS / TERMINAL
 +
 
 +
 
 +
 
 +
 
  
 
" CUSTOM FUNCTIONS "{{{1
 
" CUSTOM FUNCTIONS "{{{1
" ================================================================================================================================================================
+
" ====================================================================================
 
if !exists("AskApacheLoaded")
 
if !exists("AskApacheLoaded")
let AskApacheLoaded=1
+
  let AskApacheLoaded=1
  
 +
  " http://dotfiles.org/~samba/.vimrc
 +
  " www.gregsexton.org/2011/03/improving-the-text-displayed-in-a-fold/
  
" FUNCTION - LastMod {{{3
+
  " DECLARATIONS {{{2
" Warning, this is controlled by an autocmd triggered when closing the file that updates the file (in a great way)
+
  " ================================================================================
" Updated: Wed Feb 22 13:25:23 2012 by galileo@galileo
+
  " FUNCTION - ManualLastMod {{{4
function! LastMod()
+
  function! ManualLastMod()
exe "silent! 1,20s/Updated: .*/" . printf('Updated: %s by %s@%s', strftime("%c"), expand("$LOGNAME"), hostname()) . "/e"
+
          "echomsg 'LastMod RUNNING'
endfunction
+
  
 +
          for [l,v,d] in [[2,'Updated'," "], [3,'Revision',1], [4,'Author'," "],[5,'','']]
 +
                call setline(l, printf('%s%s: %s', printf(&commentstring, ' '), v,d))
 +
          endfor
  
" FUNCTION - LastModNow {{{3
 
" An even better version than LastMod()
 
function! LastModNow()
 
call setline(line('.'), printf('%sUpdated: %s by %s@%s', printf(&commentstring, ' '), strftime("%c"), expand("$LOGNAME"), hostname()))
 
"printf('%sUpdated: %s by %s@%s', printf(&commentstring, ' '), strftime("%c"), expand("$LOGNAME"), hostname())\|dd\|j\|dd<CR><ESC>
 
"printf('Updated: %s by %s %s', strftime("%c"), expand("$LOGNAME@$HOSTNAME")) ."/e"
 
endfunction
 
  
 +
          call LastMod()
 +
  endfunction
  
" FUNCTION - AppendModeline {{{3
 
" Append modeline after last line in buffer.  Use substitute() instead of printf() to handle '%%s' modeline
 
function! AppendModeline()
 
let l:modeline = printf(" vim: set ft=%s ts=%d sw=%d tw=%d foldmethod=%s :", &filetype, &tabstop, &shiftwidth, &textwidth, &foldmethod)
 
let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
 
call append(line("$"), l:modeline)
 
endfunction
 
  
 +
  " FUNCTION - LastMod {{{4
 +
  " Warning, this is controlled by an autocmd triggered when closing the file that updates the file (in a great way)
 +
  function! LastMod()
 +
          "echomsg 'LastMod RUNNING'
 +
          if line("$") > 20|let l = 20|else|let l = line("$")|endif
 +
          exe "silent! 1,".l."g/ Revision:[ \\d]\\+/s/\\d\\+/\\=submatch(0) + 1/e 1"
 +
          exe "silent! 1,".l."g/ Author:/s/Author:.*/" . printf('Author: %s@%s', expand("$LOGNAME"), hostname()) . "/e 1"
 +
          exe "silent! 1,".l."g/ Updated:/s/Updated:.*/" . printf('Updated: %s', strftime("%c")) . "/e 1"
 +
  endfunction
  
" FUNCTION - LastModAAZZZ {{{3
 
" AA_UPDATED='01/24/12-00:56:00'
 
function! LastModAAZZZ()
 
exe "1,50s/AA_UPDATED=.*/AA_UPDATED='" . strftime("%c") . "'"
 
endfunction
 
  
  
" FUNCTION - StripTrailingWhitespace {{{3
+
  " FUNCTION - LastModAAZZZ {{{4
" automatically remove trailing whitespace before write
+
  " AA_UPDATED='2/24/12-00:56:00'
function! StripTrailingWhitespace()
+
  function! LastModAAZZZ()
normal mZ
+
          exe "silent! 1,60 /^AA_VERSION=/s/\\d\\+$/\\=submatch(0) + 1/e 1"
%s/\s\+$//e
+
          exe "silent! 1,60 /^AA_UPDATED=/s/AA_UPDATED=.*/AA_UPDATED='" . strftime("%c") . "'/e 1"
if line("'Z") != line(".")|echo "Stripped whitespace\n"|endif
+
normal `Z
+
endfunction
+
  
 +
          exe "silent! 1,60 /^ISC_S_VERSION=/s/\\d\\+$/\\=submatch(0) + 1/e 1"
 +
          exe "silent! 1,60 /^ISC_S_UPDATED=/s/ISC_S_UPDATED=.*/ISC_S_UPDATED='" . strftime("%c") . "'/e 1"
 +
          "echomsg 'LastModAAZZZ RUNNING'
 +
  endfunction
  
" FUNCTION - MyTabL {{{3
 
function! MyTabL()
 
let s = ''|let t = tabpagenr()|let i = 1
 
while i <= tabpagenr('$')
 
let bl = tabpagebuflist(i)|let wn = tabpagewinnr(i)
 
let s .= '%' . i . 'T'. (i == t ? '%1*' : '%2*') . '%*' . (i == t ? ' %#TabLineSel# ' : '%#TabLine#')
 
let file = (i == t ? fnamemodify(bufname(bl[wn - 1]), ':p') : fnamemodify(bufname(bl[wn - 1]), ':t') )|if file == ''|let file = '[No Name]'|endif
 
let s .= i.' '. file .(i == t ? ' ' : '')|let i += 1
 
endwhile
 
let s .= '%T%#TabLineFill#%=' . (tabpagenr('$') > 1 ? '%999XX' : 'X')
 
return s
 
endfunction
 
  
 +
  " FUNCTION - AppendModeline {{{4
 +
  " Append modeline after last line in buffer.  Use substitute() instead of printf() to handle '%%s' modeline
 +
  function! AppendModeline()
 +
          let l:modeline = printf(" vim: set ft=%s ts=%d sw=%d tw=%d :", &filetype, &tabstop, &shiftwidth, &textwidth)
 +
          let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
 +
          call append(line("$"), l:modeline)
 +
  endfunction
  
" FUNCTION - DiffWithSaved {{{3
 
" Diff with saved version of the file
 
function! s:DiffWithSaved()
 
let filetype=&ft
 
diffthis
 
vnew | r # | normal! 1Gdd
 
diffthis
 
exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
 
endfunction
 
com! DiffSaved call s:DiffWithSaved()
 
  
 +
  " FUNCTION - StripTrailingWhitespace {{{4
 +
  " automatically remove trailing whitespace before write
 +
  function! StripTrailingWhitespace()
 +
          normal mZ
 +
          %s/\s\+$//e
 +
          if line("'Z") != line(".")|echo "Stripped whitespace\n"|endif
 +
          normal `Z
 +
  endfunction
  
" FUNCTION - ShowWhitespace() {{{3
 
function! ShowWhitespace(flags)
 
let bad = ''
 
let pat = []
 
for c in split(a:flags, '\zs')
 
if c == 'e'
 
call add(pat, '\s\+$')
 
elseif c == 'i'
 
call add(pat, '^\t*\zs \+')
 
elseif c == 's'
 
call add(pat, ' \+\ze\t')
 
elseif c == 't'
 
call add(pat, '[^\t]\zs\t\+')
 
else
 
let bad .= c
 
endif
 
endfor
 
  
if len(pat) > 0
+
  " FUNCTION - MyTabL {{{3
let s = join(pat, '\|')
+
  function! MyTabL()
exec 'syntax match ExtraWhitespace "'.s.'" containedin=ALL'
+
          let s = ''|let t = tabpagenr()|let i = 2
else
+
          while i <= tabpagenr('$')
syntax clear ExtraWhitespace
+
                let bl = tabpagebuflist(i)|let wn = tabpagewinnr(i)
endif
+
                let s .= '%' . i . 'T'. (i == t ? '%2*' : '%2*') . '%*' . (i == t ? ' %#TabLineSel# ' : '%#TabLine#')
 +
                let file = (i == t ? fnamemodify(bufname(bl[wn - 2]), ':p') : fnamemodify(bufname(bl[wn - 1]), ':t') )
 +
                if file == ''
 +
                        let file = '[No Name]'
 +
                endif
 +
                let s .= i.' '. file .(i == t ? ' ' : '')|let i += 2
 +
          endwhile
 +
          let s .= '%T%#TabLineFill#%=' . (tabpagenr('$') > 2 ? '%999XX' : 'X')
 +
          return s
 +
  endfunction
  
if len(bad) > 0|echo 'ShowWhitespace ignored: '.bad|endif
 
endfunction
 
  
 +
  " FUNCTION - DiffWithSaved {{{3
 +
  " Diff with saved version of the file
 +
  function! s:DiffWithSaved()
 +
          let filetype=&ft
 +
          diffthis
 +
          vnew | r # | normal! 2Gdd
 +
          diffthis
 +
          exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
 +
  endfunction
 +
  com! DiffSaved call s:DiffWithSaved()
  
  
" FUNCTION - ToggleShowWhitespace {{{3
+
  " FUNCTION - ShowWhitespace() {{{3
" I use this all the time, it's mapped to , ts
+
  function! ShowWhitespace(flags)
function! ToggleShowWhitespace()
+
          let bad = ''
if !exists('b:ws_show')|let b:ws_show = 0|endif
+
          let pat = []
if !exists('b:ws_flags')|let b:ws_flags = 'est'|endif
+
          for c in split(a:flags, '\zs')
let b:ws_show = !b:ws_show
+
                if c == 'e'
if b:ws_show|call ShowWhitespace(b:ws_flags)|else|call ShowWhitespace('')|endif
+
                        call add(pat, '\s\+$')
endfunction
+
                elseif c == 'i'
 +
                        call add(pat, '^\t*\zs \+')
 +
                elseif c == 's'
 +
                        call add(pat, ' \+\ze\t')
 +
                elseif c == 't'
 +
                        call add(pat, '[^\t]\zs\t\+')
 +
                else
 +
                        let bad .= c
 +
                endif
 +
          endfor
 +
 
 +
          if len(pat) > 1
 +
                let s = join(pat, '\|')
 +
                exec 'syntax match ExtraWhitespace "'.s.'" containedin=ALL'
 +
          else
 +
                syntax clear ExtraWhitespace
 +
          endif
 +
 
 +
          if len(bad) > 1|echo 'ShowWhitespace ignored: '.bad|endif
 +
  endfunction
 +
 
 +
 
 +
 
 +
  " FUNCTION - ToggleShowWhitespace {{{3
 +
  " I use this all the time, it's mapped to , ts
 +
  function! ToggleShowWhitespace()
 +
          if !exists('b:ws_show')|let b:ws_show = 1|endif
 +
          if !exists('b:ws_flags')|let b:ws_flags = 'est'|endif
 +
          let b:ws_show = !b:ws_show
 +
          if b:ws_show|call ShowWhitespace(b:ws_flags)|else|call ShowWhitespace('')|endif
 +
  endfunction
 +
 
 +
 
 +
  " FUNCTION - ValidVimCheck {{{3
 +
  function! ValidVimCheck()
 +
          if has('quickfix') && &buftype =~ 'nofile'
 +
                "echoerr "Buffer is marked as not a file"
 +
                return 0
 +
          endif
 +
 
 +
          if empty(glob(expand('%:p')))
 +
                "echoerr "File does not exist on disk"
 +
                return 0
 +
          endif
 +
 
 +
          if len($TMP) && expand('%:p:h') == $TMP
 +
                "echoerr "Also in temp dir"
 +
                return 0
 +
          endif
 +
          return 1
 +
  endfunction
 +
 
 +
 
 +
  " ------------------------------------------------------------- }}}2 ENDOF DECLARATIONS
  
 
endif
 
endif
  
" DYNAMIC SETTINGS / COLORS / TERMINAL {{{1
+
" ------------------------------------------------------------------------------------ }}}1 ENDOF CUSTOM FUNCTIONS
" ================================================================================================================================================================
+
  
 +
 +
 +
 +
" OPTIONS "{{{1
 +
" ====================================================================================
 +
 +
 +
" DYNAMIC OPTIONS {{{2
 +
" ================================================================================
 
" DISABLE MOUSE NO GOOEYS {{{3
 
" DISABLE MOUSE NO GOOEYS {{{3
 
if has('mouse')|set mouse=|endif
 
if has('mouse')|set mouse=|endif
Line 285: Line 399:
 
let no_plugin_maps=1
 
let no_plugin_maps=1
  
 +
"}}}2 DYNAMIC OPTIONS
  
"}}}1 DYNAMIC SETTINGS / COLORS / TERMINAL
 
  
" OPTIONS "{{{1
 
" ===========================================================================================================================================================================
 
  
 
" BACKUP, FILE OPTIONS {{{2
 
" BACKUP, FILE OPTIONS {{{2
 
" ================================================================================
 
" ================================================================================
set backup   " Make a backup before overwriting a file.  Leave it around after the file has been successfully written.
+
set backup                       " Make a backup before overwriting a file.  
set backupcopy=auto " When writing a file and a backup is made, this option tells how it's doneThis is a comma separated list of words. - value: yes,no,auto - no:rename the file and write a new one
+
set backupcopy=auto " When writing a file and a backup is made.  comma separated list of words. - value: yes,no,auto
  
 
set swapfile
 
set swapfile
Line 300: Line 412:
  
 
"}}}2 BACKUP, FILE OPTIONS
 
"}}}2 BACKUP, FILE OPTIONS
 
  
 
" BASIC SETTINGS "{{{2
 
" BASIC SETTINGS "{{{2
 
" ================================================================================
 
" ================================================================================
set nocompatible " vim, not vi.. must be first, because it changes other options as a side effect
+
set nocompatible               " vim, not vi.. must be first, because it changes other options as a side effect
 
set modeline
 
set modeline
  
Line 310: Line 421:
 
set title titlelen=150 titlestring=%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ %{v:servername}
 
set title titlelen=150 titlestring=%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ %{v:servername}
  
"set tags=tags;/ " search recursively up for tags
+
"set tags=tags;/                       " search recursively up for tags
  
set ttyfast " we have a fast terminal
+
set ttyfast                             " we have a fast terminal
set scrolljump=5   " when scrolling up down, show at least 5 lines
+
set scrolljump=5         " when scrolling up down, show at least 5 lines
"set ttyscroll=999   " make vim redraw screen instead of scrolling when there are more than 3 lines to be scrolled
+
"set ttyscroll=999       " make vim redraw screen instead of scrolling when there are more than 3 lines to be scrolled
  
"set tw=500 " default textwidth is a max of 5
+
"set tw=500                             " default textwidth is a max of 5
  
set undolevels=10 " 50 undos - saved in memory
+
set undolevels=1000            " 50 undos - saved in undodir
set updatecount=250 " switch every 250 chars, save swap
+
set updatecount=250             " switch every 250 chars, save swap
  
set whichwrap+=b,s,<,>,h,l,[,] " backspaces and cursor keys wrap to
+
set whichwrap+=b,s,<,>,h,l,[,]                 " backspaces and cursor keys wrap to
"set wildignore+=*.o,*~,.lo,*.exe,*.bak " ignore object files
+
"set wildignore+=*.o,*~,.lo,*.exe,*.bak " ignore object files
"set wildmenu " menu has tab completion
+
"set wildmenu                                                   " menu has tab completion
"set wildmode=longest:full " *wild* mode
+
"set wildmode=longest:full                             " *wild* mode
 
set nowrap
 
set nowrap
  
set autoindent smartindent " auto/smart indent
+
set autoindent smartindent             " auto/smart indent
  
set autoread " watch for file changes
+
set autoread                                   " watch for file changes
  
set backspace=indent,eol,start " backspace over all kinds of things
+
set backspace=indent,eol,start " backspace over all kinds of things
  
set cmdheight=1 " command line two lines high
+
set cmdheight=1                                 " command line two lines high
set complete=.,w,b,u,U,t,i,d " do lots of scanning on tab completion
+
set complete=.,w,b,u,U,t,i,d   " do lots of scanning on tab completion
set cursorline " show the cursor line
+
set cursorline                                 " show the cursor line
"set enc=utf-8 fenc=utf-8 " utf-8
+
"set enc=utf-8 fenc=utf-8               " utf-8
  
set history=3000 " keep 3000 lines of command line history
+
set history=3000                               " keep 3000 lines of command line history
  
 
set keywordprg=TERM=mostlike\ man\ -s\ -Pless
 
set keywordprg=TERM=mostlike\ man\ -s\ -Pless
Line 344: Line 455:
 
set laststatus=2
 
set laststatus=2
  
"set lazyredraw " don't redraw when don't have to
+
"set lazyredraw                                 " don't redraw when don't have to
set linebreak " wrap at 'breakat' instead of last char
+
set linebreak                                   " wrap at 'breakat' instead of last char
set magic " Enable the "magic"
+
set magic                                               " Enable the "magic"
  
set maxmem=25123 " 24 MB -  max mem in Kbyte to use for one buffer.  Max is 2000000
+
set maxmem=25123       " 24 MB -  max mem in Kbyte to use for one buffer.  Max is 2000000
  
set noautowrite " don't automagically write on :next
+
set noautowrite                                 " don't automagically write on :next
  
set noexpandtab " no expand tabs to spaces"
+
set noexpandtab                                 " no expand tabs to spaces"
set noruler " show the line number on the bar
+
set noruler                                     " show the line number on the bar
 
set nospell
 
set nospell
set nohidden " close the buffer when I close a tab (I use tabs more than buffers)
+
set nohidden                                   " close the buffer when I close a tab (I use tabs more than buffers)
  
 
set noerrorbells visualbell t_vb= " Disable ALL bells
 
set noerrorbells visualbell t_vb= " Disable ALL bells
  
set number " line numbers
+
set number                                     " line numbers
  
 
set pastetoggle=<F11>
 
set pastetoggle=<F11>
  
set scrolloff=3 " keep at least 3 lines above/below
+
set scrolloff=3                         " keep at least 3 lines above/below
set shiftwidth=3 " shift width
+
set shiftwidth=3                       " shift width
  
set showcmd " Show us the command we're typing
+
set showcmd                                     " Show us the command we're typing
set showfulltag " show full completion tags
+
set showfulltag                         " show full completion tags
set showmode " show the mode all the time
+
set showmode                           " show the mode all the time
  
set sidescroll=2 " if wrap is off, this is fasster for horizontal scrolling
+
set sidescroll=2                       " if wrap is off, this is fasster for horizontal scrolling
set sidescrolloff=2 "keep at least 5 lines left/right
+
set sidescrolloff=2                     "keep at least 5 lines left/right
  
 
set noguipty
 
set noguipty
Line 382: Line 493:
 
"set sessionoptions=word,blank,buffers,curdir,folds,globals,help,localoptions,resize,sesdir,tabpages,winpos,winsize
 
"set sessionoptions=word,blank,buffers,curdir,folds,globals,help,localoptions,resize,sesdir,tabpages,winpos,winsize
 
set winheight=25
 
set winheight=25
set winminheight=1 " minimal value for window height
+
set winminheight=1     " minimal value for window height
"set winheight=30 " set the minimal window height
+
"set winheight=30       " set the minimal window height
set equalalways " all the windows are automatically sized same
+
set equalalways         " all the windows are automatically sized same
set eadirection=both " only equalalways for horizontally split windows
+
set eadirection=both   " only equalalways for horizontally split windows
  
 
set hlsearch
 
set hlsearch
Line 400: Line 511:
  
 
set tabpagemax=55
 
set tabpagemax=55
set showtabline=2 " 2 always, 1 only if multiple tabs
+
set showtabline=2               " 2 always, 1 only if multiple tabs
set smarttab " tab and backspace are smart
+
set smarttab                   " tab and backspace are smart
  
 
set foldmethod=marker
 
set foldmethod=marker
 
set foldenable
 
set foldenable
set foldcolumn=6 " the blank left-most bar left of the numbered lines
+
set foldcolumn=7                                " the blank left-most bar left of the numbered lines
  
  
set incsearch " incremental search
+
set incsearch                                   " incremental search
"set ignorecase " search ignoring case
+
"set ignorecase                                 " search ignoring case
set sc " override 'ignorecase' when pattern has upper case characters
+
set sc                                                 " override 'ignorecase' when pattern has upper case characters
set smartcase " Ignore case when searching lowercase
+
set smartcase                                   " Ignore case when searching lowercase
  
set showmatch " show matching bracket
+
set showmatch                                   " show matching bracket
set diffopt=filler,iwhite " ignore all whitespace and sync"
+
set diffopt=filler,iwhite               " ignore all whitespace and sync"
 
set stal=2
 
set stal=2
  
 +
set viewoptions=folds,localoptions,cursor
 +
 +
" ------------------------------------------------------------------------------------ }}}1 ENDOF OPTIONS
  
"}}}1 OPTIONS
 
  
 
" PLUGIN SETTINGS {{{1
 
" PLUGIN SETTINGS {{{1
" ================================================================================================================================================================
+
" ====================================================================================
 
" Settings for :TOhtml "{{{3
 
" Settings for :TOhtml "{{{3
 
let html_number_lines=1
 
let html_number_lines=1
 
let html_use_css=1
 
let html_use_css=1
 
let use_xhtml=1
 
let use_xhtml=1
"}}}1 PLUGIN SETTINGS
+
" ------------------------------------------------------------------------------------ }}}1 ENDOF PLUGIN SETTINGS
  
" COLORSCHEME IF MORE THAN 2 COLORS lol {{{1
 
" ================================================================================================================================================================
 
if &t_Co > 2
 
  
if &term =~ "256"
+
" AUTOCOMMANDS "{{{1
 +
" ====================================================================================
 +
"{
 +
"if !exists(":DiffOrig") | command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis | endif
  
set bg=dark t_Co=256 vb
+
" auto load extensions for different file types
let &t_vb="\<Esc>[?5h\<Esc>[?5l" " flash screen for visual bell
+
if has('autocmd')
  
if filereadable(expand("$VIMRUNTIME/colors/askapachecode.vim"))
+
  if !exists("autocommands_loaded")
colorscheme askapachecode
+
elseif filereadable(expand("$HOME/.vim/colors/askapachecode.vim"))
+
colorscheme askapachecode
+
else
+
colorscheme default
+
endif
+
  
filetype indent plugin on
+
          let autocommands_loaded = 1
syntax on
+
  
else
 
" things like cfdisk, crontab -e, visudo, vless, etc.
 
set term=linux
 
set t_Co=8
 
syntax off
 
filetype indent plugin off
 
  
endif
 
  
endif
+
          " LASTMOD COMMANDS {{{2
 +
          " ================================================================================
 +
          augroup aazzlastmod
 +
                autocmd!
  
"}}}1
+
                " INSERT CURRENT DATE AND TIME WHEN WRITING IT {{{3
 +
                autocmd BufWritePre,FileWritePre *.sh,.htaccess,*.conf,vimrc,.bash*,.*,*.cron ks|call LastMod()|'s
  
" AUTOCOMMANDS "{{{1
+
                " AA_ZZZ LAST MOD {{{3
" ===========================================================================================================================================================================
+
                autocmd BufWritePre,FileWritePre zzz_askapache-bash.sh,*.sh ks|call LastModAAZZZ()|'s
"if !exists(":DiffOrig") | command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis | endif
+
          augroup END
 +
          " ------------------------------------------------------------- }}}2 ENDOF LASTMOD COMMANDS
  
" auto load extensions for different file types
 
if has('autocmd')
 
  
if !exists("autocommands_loaded")
+
          " AUTOMKVIEW COMMANDS {{{2
let autocommands_loaded = 1
+
          " ================================================================================
 +
                augroup aazzzmakeviewcheck
 +
                        autocmd!
  
" JUMP TO LAST POS {{{3
+
                        autocmd BufWinLeave * if ValidVimCheck() | mkview! |endif
" When editing a file, always jump to the last known cursor position. Don't do it when the position is invalid or when inside an event handler
+
                        autocmd BufWinEnter * if ValidVimCheck() | silent loadview | endif
" (happens when dropping a file on gvim). Also don't do it when the mark is in the first line, that is the default position when opening a file.
+
                augroup END
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
+
          " ------------------------------------------------------------- }}}2 ENDOF AUTOMKVIEW COMMANDS
  
  
" CLEARMATCHES ON BUFWINLEAVE {{{3
 
au BufWinLeave * call clearmatches()
 
  
 +
          " MISC COMMANDS {{{2
 +
          " ================================================================================
  
" STRIP TRAILING WHITESPACE {{{3
+
          " SAVE BACKUPFILE AS BACKUPDIR/FILENAME-06-13-1331 {{{3
autocmd BufWritePre *.cpp,*.hpp,*.i :call StripTrailingWhitespace()
+
          autocmd BufWritePre * let &bex = strftime("-%m-%d-%H%M")
  
  
" AA_ZZZ LAST MOD {{{3
+
          " CLEARMATCHES ON BUFWINLEAVE {{{3
autocmd BufWritePre,FileWritePre,TabLeave zzz_askapache-bash.sh ks|call LastModAAZZZ()|'s
+
          if exists("*clearmatches")
 +
                autocmd BufWinLeave *.* call clearmatches()
 +
          endif
  
 +
          " STRIP TRAILING WHITESPACE {{{3
 +
          if exists("*s:StripTrailingWhitespace")
 +
                autocmd BufWritePre *.cpp,*.hpp,*.i,*.sh,.htaccess,*.conf :call s:StripTrailingWhitespace()
 +
          endif
 +
          " ------------------------------------------------------------- }}}2 ENDOF MISC COMMANDS
  
" SET VIM SETTINGS FOR AA_ZZZ SCRIPTS {{{3
 
autocmd BufRead /etc/ZZZ/*.sh,.bash_profile,.bash_login,.bashrc,.bash_login_user,.bash_logout setlocal ts=4 sw=3 ft=sh foldmethod=marker tw=500 foldcolumn=7
 
  
  
" INSERT CURRENT DATE AND TIME IN A *.SH FILE WHEN WRITING IT {{{3
 
autocmd BufWritePre,FileWritePre *.*  ks|call LastMod()|'s
 
  
  
" IMPROVE LEGIBILITY {{{3
+
          " FILETYPES {{{2
autocmd BufRead quickfix setlocal nobuflisted wrap number
+
          " ================================================================================
 +
          " SET VIM SETTINGS FOR AA_ZZZ SCRIPTS {{{3
 +
          autocmd BufRead .bash_profile,.bashrc,.bash_logout setlocal ts=4 sw=3 ft=sh foldmethod=marker tw=500 foldcolumn=7
  
 +
          " TMUX FILETYPE {{{3
 +
          autocmd BufRead tmux.conf,.tmux.conf,.tmux*,*/tmux-sessions/* setlocal filetype=tmux foldmethod=marker
  
" SAVE BACKUPFILE AS BACKUPDIR/FILENAME-06-13-1331 {{{3
+
          " LOGROTATE FILETYPE {{{3
autocmd BufWritePre * let &bex = strftime("-%m-%d-%H%M")
+
          autocmd BufRead /etc/logrotate.d/*,/etc/logrotate.conf setlocal filetype=logrotate
  
 +
          " FSTAB FILETYPE {{{3
 +
          autocmd BufRead /etc/fstab,fstab setlocal foldmethod=marker
  
" TMUX FILETYPE {{{3
 
autocmd BufRead tmux.conf,.tmux.conf,.tmux*,*/tmux-sessions/* setlocal filetype=tmux foldmethod=marker
 
  
 +
          " APACHE2 FILETYPE {{{3
 +
          autocmd BufRead /etc/httpd/*.conf,httpd.conf setlocal filetype=apache foldmethod=marker foldcolumn=7 foldlevel=2
  
" APACHE2 FILETYPE {{{3
 
autocmd BufRead /opt/a*/conf/*,/etc/httpd/*.conf setlocal filetype=apache
 
  
 +
          " SH FILETYPES {{{3
 +
          autocmd BufRead *.sh,*.cron,*.bash setlocal filetype=sh
  
" SH FILETYPES {{{3
 
autocmd BufRead *.sh,*.cron,*.bash setlocal filetype=sh
 
  
 +
          " SYSLOG-NG FILETYPE {{{3
 +
          autocmd BufRead syslog-ng.conf setlocal filetype=syslog-ng
  
" SYSLOG-NG FILETYPE {{{3
 
autocmd BufRead syslog-ng.conf setlocal filetype=syslog-ng
 
  
 +
          " NET-PROFILES FILETYPE {{{3
 +
          autocmd BufRead /etc/network.d/* setlocal filetype=conf
  
" COMMENTSTRING FOR VIM "{{{3
 
au FileType vim setlocal commentstring="%s
 
  
 +
          " XDEFAULTS "{{{3
 +
          autocmd FileType xdefaults setlocal foldmethod=marker foldlevel=2 commentstring=!%s
  
" COMMENTSTRING FOR XDEFAULTS "{{{3
+
          " ------------------------------------------------------------- }}}2 ENDOF FILETYPES
au FileType xdefaults setlocal foldmethod=marker foldlevel=2 commentstring=!%s
+
  
  
" VIMRC {{{3
+
          " MAN RUNTIME - TODO REPLACE WITH TMUXES CTRL-M BINDING {{{2
augroup vimrc
+
          " Lets you type :Man anymanpage and it will load in vim, color-coded and searchable
au BufReadPre * setlocal foldmethod=indent
+
          " runtime ftplugin/man.vim
au BufWinEnter * if &fdm == 'indent' | set foldmethod=manual | endif
+
 
au BufRead *.vim,vimrc,*.vimrc set filetype=vim ts=3 sw=3 tw=500 foldmethod=marker foldcolumn=6
+
  endif
augroup END
+
endif
 +
 
 +
" ------------------------------------------------------------------------------------ }}}1 ENDOF AUTOCOMMANDS
  
" AUTOMKVIEWS {{{3
 
" Warning - this will save your settings for each file you edit and restore those settings when opened again - can fill up quick
 
au BufWinLeave *.sh,*.conf,*.vim,*.c,*.txt,.htaccess,*.cgi,*.php,*.html,*.conf,vimrc mkview
 
au BufWinEnter *.sh,*.conf,*.vim,*.c,*.txt,.htaccess,*.cgi,*.php,*.html,*.conf,vimrc silent loadview
 
" }}}3
 
  
" MAN RUNTIME - TODO REPLACE WITH TMUXES CTRL-M BINDING {{{3
 
" Lets you type :Man anymanpage and it will load in vim, color-coded and searchable
 
"runtime ftplugin/man.vim
 
  
endif
 
  
endif
 
"}}}1
 
  
 
" MAPS "{{{1
 
" MAPS "{{{1
" ===========================================================================================================================================================================
+
" ====================================================================================
  
 
" FUNCTION MAPS {{{2
 
" FUNCTION MAPS {{{2
Line 558: Line 661:
 
" APPEND MODELINE {{{3
 
" APPEND MODELINE {{{3
 
map <silent> <LocalLeader>ml :call AppendModeline()<CR>
 
map <silent> <LocalLeader>ml :call AppendModeline()<CR>
 +
  
 
" SHOW WHITESPACE {{{3
 
" SHOW WHITESPACE {{{3
 
nnoremap <LocalLeader>ts :call ToggleShowWhitespace()<CR>
 
nnoremap <LocalLeader>ts :call ToggleShowWhitespace()<CR>
 +
  
 
" SUDO A WRITE {{{3
 
" SUDO A WRITE {{{3
Line 566: Line 671:
 
"cmap w!! %!sudo tee > /dev/null %
 
"cmap w!! %!sudo tee > /dev/null %
 
" :w !sudo tee > /dev/null %
 
" :w !sudo tee > /dev/null %
 +
  
 
" SET TABLINE {{{3
 
" SET TABLINE {{{3
 
" My Personal Fav, inserts last-modified manually on current line when you press <F12> key
 
" My Personal Fav, inserts last-modified manually on current line when you press <F12> key
" call setline(1, printf('%sUpdated: %s by %s@%s', printf(&commentstring, ' '), strftime("%c"), expand("$LOGNAME"), hostname()))
+
if exists("*ManualLastMod")
if exists("*s:LastModNow")
+
  map <silent> <F12> :call ManualLastMod()<CR>
map <silent> <F12> :call LastModNow()<CR>
+
 
endif
 
endif
 +
  
 
" RELOAD VIMRC FILES {{{3
 
" RELOAD VIMRC FILES {{{3
map <LocalLeader>. :mkview<CR>:unlet! AskApacheLoaded autocommands_loaded<CR>:mapclear<CR>:source /etc/vimrc<CR>:echoerr 'VIMRC RELOADED'<CR>
+
map <LocalLeader>. :mkview<CR>:unlet! AskApacheLoaded autocommands_loaded<CR>:mapclear<CR>:source /etc/vimrc<CR>:loadview<CR>
 +
 
 +
 
  
 
" SCROLLING MAPS {{{3
 
" SCROLLING MAPS {{{3
Line 587: Line 695:
 
inoremap <silent> <PageDown> <C-\><C-O><C-D><C-\><C-O><C-D>
 
inoremap <silent> <PageDown> <C-\><C-O><C-D><C-\><C-O><C-D>
 
"}}}3
 
"}}}3
 +
 +
 +
 +
  
 
" KEY MAPS {{{2
 
" KEY MAPS {{{2
Line 596: Line 708:
 
imap <ESC>[7~ <Home>
 
imap <ESC>[7~ <Home>
 
map <ESC>[7~ <Home>
 
map <ESC>[7~ <Home>
 +
 +
imap <ESC>OH <Home>
 +
map <ESC>OH <Home>
 +
 +
imap <ESC>OF <End>
 +
map <ESC>OF <End>
 +
  
 
" Basic Maps  {{{2
 
" Basic Maps  {{{2
Line 609: Line 728:
  
 
" Y YANKS FROM CURSOR TO $ {{{3
 
" Y YANKS FROM CURSOR TO $ {{{3
map Y y$
+
map <LocalLeader>y "5y$
 +
map <LocalLeader>r "_d$p
 +
 
 +
 
 +
 
 +
 
 +
map <LocalLeader>dd _d<CR>
  
 
" DON'T USE EX MODE, USE Q FOR FORMATTING {{{3
 
" DON'T USE EX MODE, USE Q FOR FORMATTING {{{3
Line 639: Line 764:
 
nmap <LocalLeader>ww :set wrap!<CR>
 
nmap <LocalLeader>ww :set wrap!<CR>
 
nmap <LocalLeader>wo :set wrap<CR>
 
nmap <LocalLeader>wo :set wrap<CR>
 +
 +
  
 
" TABS "{{{2
 
" TABS "{{{2
Line 658: Line 785:
 
map <LocalLeader>tp :tabprev<CR>
 
map <LocalLeader>tp :tabprev<CR>
  
" FOLDS "{{{2
 
" ---------------------------------
 
" Fold with paren begin/end matching
 
nmap F zf%
 
  
" When I use ,sf - return to syntax folding with a big foldcolumn
 
nmap <LocalLeader>sf :set foldcolumn=6 foldmethod=syntax<cr>
 
"}}}2
 
  
"}}}1
 
  
" HILITE "{{{1
 
" ===========================================================================================================================================================================
 
hi NonText cterm=NONE ctermfg=NONE
 
hi Search cterm=bold ctermbg=99 ctermfg=17
 
"}}}
 
  
" COMMENTED OUT {{{1
 
" comments down at bottom of file so it doesn't slow down vim parsing and loading
 
" ================================================================================================================================================================
 
"Commented Out "{{{4
 
" Whitespace Highlighting
 
"au ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
 
"au InsertLeave * redraw!
 
"highlight ExtraWhitespace ctermbg=red guibg=red
 
"match ExtraWhitespace /\s\+$/
 
"autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
 
"autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
 
"autocmd InsertLeave * match ExtraWhitespace /\s\+$/
 
"autocmd BufWinLeave * call clearmatches()
 
  
" Show leading whitespace that includes spaces, and trailing whitespace.
 
"au BufWinEnter * match ExtraWhitespace /^\s* \s*\|\s\+$/
 
"au BufWinEnter * match ExtraWhitespace /\s\+\%#\@<!$/
 
"au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
 
"au InsertLeave * match ExtraWhitespace /\s\+$/
 
  
" Convenient command to see the difference between the current buffer and the
 
" file it was loaded from, thus the changes you made.  Only define it when not defined already.
 
"if !exists(":DiffOrig") | command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis | endif
 
"au BufRead httpd.conf set filetype=apache " for htaccess files set filetype to apache
 
"}}}4
 
  
" COMMENTED OUT MAPS {{{6
 
"map <C-S-]> gt
 
"map <C-S-[> gT
 
"map <C-1> 1gt
 
"map <C-2> 2gt
 
"map <C-3> 3gt
 
"map <C-4> 4gt
 
"map <C-5> 5gt
 
"map <C-6> 6gt
 
"map <C-7> 7gt
 
"map <C-8> 8gt
 
"map <C-9> 9gt
 
"map <C-0> :tablast<CR>
 
 
" correct type-o's on exit
 
" nmap q: :q
 
 
" save and build
 
" nmap <LocalLeader>wm  :w<cr>:make<cr>
 
" Also map user-defined omnicompletion as Ctrl+k
 
"inoremap <C-k> <C-x><C-u>
 
 
" Y yanks from cursor to $
 
"map Y y$
 
 
" for yankring to work with previous mapping:
 
"function! YRRunAfterMaps()
 
"  nnoremap Y  :<C-U>YRYankCount 'y$'<CR>
 
"endfunction
 
 
" toggle list mode
 
"nmap <LocalLeader>tl :set list!<cr>
 
 
" toggle paste mode
 
"nmap <LocalLeader>pm :set paste!<cr>
 
 
" toggle wrapping
 
"nmap <LocalLeader>ww :set wrap!<cr>
 
 
" change directory to that of current file
 
"nmap <LocalLeader>cd :cd%:p:h<cr>
 
 
" change local directory to that of current file
 
"nmap <LocalLeader>lcd :lcd%:p:h<cr>
 
 
" correct type-o's on exit
 
"nmap q: :q
 
 
" save and build
 
"nmap <LocalLeader>wm  :w<cr>:make<cr>
 
 
" open all folds
 
"nmap <LocalLeader>o  :%foldopen!<cr>
 
 
" close all folds
 
"nmap <LocalLeader>c  :%foldclose!<cr>
 
 
" ,tt will toggle taglist on and off
 
"nmap <LocalLeader>tt :Tlist<cr>
 
 
" ,nn will toggle NERDTree on and off
 
"nmap <LocalLeader>n :NERDTreeToggle<cr>
 
 
" When I'm pretty sure that the first suggestion is correct
 
"map <LocalLeader>st 1z=
 
 
" q: sucks
 
"nmap q: :q
 
 
" Fix the # at the start of the line
 
"inoremap # X<BS>#
 
  
 +
" FOLDS  "{{{2
 +
" ---------------------------------
 
" Fold with paren begin/end matching
 
" Fold with paren begin/end matching
"nmap F zf%
+
nmap F zf%
  
 
" When I use ,sf - return to syntax folding with a big foldcolumn
 
" When I use ,sf - return to syntax folding with a big foldcolumn
"nmap <LocalLeader>sf :set foldcolumn=6 foldmethod=syntax<cr>
+
nmap <LocalLeader>sf :set foldcolumn=6 foldmethod=syntax<cr>
 +
"}}}2
  
"}}}6
+
" ------------------------------------------------------------------------------------ }}}1 ENDOF MAPS
  
" Commented out maps "{{{4
 
" ---------------------------------
 
  
"" fm - (zm)  more folds
+
" HILITE "{{{1
" noremap <LocalLeader>fm zm
+
" ====================================================================================
 +
hi NonText cterm=NONE ctermfg=NONE
 +
hi Search cterm=bold ctermbg=99 ctermfg=17
 +
" ------------------------------------------------------------------------------------ }}}1 ENDOF HILITE
  
" fl  - (zr) less/reduce folds
 
" noremap <LocalLeader>fl zr
 
  
" fc - close all folds (zM)
 
" noremap <LocalLeader>fc zM
 
  
" fo - open all folds (zR)
 
" noremap <LocalLeader>fo zR
 
  
" ff  -  (zf) - create a fold
 
" noremap <LocalLeader>ff zf
 
" fd - (zd) - delete fold at cursor
 
" noremap <LocalLeader>fd zd
 
"}}}4
 
" # REMOVING AUTOCOMMANDS {{{6
 
" :au[tocmd] [group] {event} {pat} [nested] {cmd}
 
" Remove all autocommands associated with {event} and {pat}, and add the command {cmd}.
 
" :au[tocmd]! [group] {event} {pat} [nested] {cmd}
 
  
" Remove all autocommands associated with {event} and {pat}.
 
" :au[tocmd]! [group] {event} {pat}
 
  
" Remove all autocommands associated with {pat} for all events.
 
" :au[tocmd]! [group] * {pat}
 
 
" Remove ALL autocommands for {event}.
 
" :au[tocmd]! [group] {event}
 
 
" Remove ALL autocommands.
 
" :au[tocmd]! [group]  }}}6
 
"}}}1 ENDOF COMMENTED OUT
 
  
 
" VIM TIPS / HELP / TRICKS  {{{1
 
" VIM TIPS / HELP / TRICKS  {{{1
" ================================================================================================================================================================
+
" ====================================================================================
  
 
" BEST TRICKS {{{2
 
" BEST TRICKS {{{2
Line 861: Line 859:
 
" :r file " read text from file and insert below current line
 
" :r file " read text from file and insert below current line
  
" :so $VIMRUNTIME/syntax/hitest.vim   " view highlight options
+
" :so $VIMRUNTIME/syntax/hitest.vim       " view highlight options
  
 
"}}}2
 
"}}}2
 +
  
 
" HELP HELP {{{3
 
" HELP HELP {{{3
 
" ---------------------------------
 
" ---------------------------------
" :helpg pattern   search grep!! ---  JUMP TO OTHER MATCHES WITH: >
+
" :helpg pattern                                         search grep!! ---  JUMP TO OTHER MATCHES WITH: >
 
" :help holy-grail
 
" :help holy-grail
 
" :help all
 
" :help all
Line 879: Line 878:
 
"  :help pattern<Tab>          Find a help tag starting with "pattern".  Repeat <Tab> for others. >
 
"  :help pattern<Tab>          Find a help tag starting with "pattern".  Repeat <Tab> for others. >
 
"  :help pattern<Ctrl-D>      See all possible help tag matches "pattern" at once. >
 
"  :help pattern<Ctrl-D>      See all possible help tag matches "pattern" at once. >
"   :cn                        next match >
+
"                 :cn                        next match >
"   :cprev, :cN                previous match >
+
"                 :cprev, :cN                previous match >
"   :cfirst, :clast            first or last match >
+
"                 :cfirst, :clast            first or last match >
"   :copen,  :cclose            open/close the quickfix window; press <Enter> to jump to the item under the cursor
+
"                 :copen,  :cclose            open/close the quickfix window; press <Enter> to jump to the item under the cursor
 +
 
 +
 
  
 
" SET HELP {{{3
 
" SET HELP {{{3
 
" ---------------------------------
 
" ---------------------------------
 
" :verbose set opt? - show where opt was set
 
" :verbose set opt? - show where opt was set
" set opt! - invert
+
" set opt!             - invert
" set invopt - invert
+
" set invopt           - invert
" set opt& - reset to default
+
" set opt&             - reset to default
" set all& - set all to def
+
" set all&             - set all to def
" :se[t] Show all options that differ from their default value.
+
" :se[t]                       Show all options that differ from their default value.
" :se[t] all Show all but terminal options.
+
" :se[t] all           Show all but terminal options.
" :se[t] termcap Show all terminal options.  Note that in the GUI the
+
" :se[t] termcap               Show all terminal options.  Note that in the GUI the
 +
 
 +
 
  
 
" TAB HELP  {{{3
 
" TAB HELP  {{{3
 
" ---------------------------------
 
" ---------------------------------
" tc - create a new tab
+
" tc   - create a new tab
" td - close a tab
+
" td   - close a tab
" tn - next tab
+
" tn   - next tab
" tp - previous tab
+
" tp   - previous tab
 +
 
 +
 
  
 
" UPPERCASE, LOWERCASE, INDENTS {{{3
 
" UPPERCASE, LOWERCASE, INDENTS {{{3
 
" ---------------------------------
 
" ---------------------------------
" '. - last modification in file!
+
" '.   - last modification in file!
 
" gf  - open file under cursor
 
" gf  - open file under cursor
 
" guu - lowercase line
 
" guu - lowercase line
 
" gUU - uppercase line
 
" gUU - uppercase line
 
" =  - reindent text
 
" =  - reindent text
 +
 +
  
 
" FOLDS {{{3
 
" FOLDS {{{3
 
" ---------------------------------
 
" ---------------------------------
" F - create a fold from matching parenthesis
+
" F     - create a fold from matching parenthesis
" fm - (zm)  more folds
+
" fm   - (zm)  more folds
 
" fl  - (zr) less/reduce folds
 
" fl  - (zr) less/reduce folds
" fo - open all folds (zR)
+
" fo   - open all folds (zR)
" fc - close all folds (zM)
+
" fc   - close all folds (zM)
" ff  -  (zf) - create a fold
+
" ff  -  (zf)   - create a fold
" fd - (zd) - delete fold at cursor
+
" fd   - (zd) - delete fold at cursor
" zF - create a fold N lines
+
" zF   - create a fold N lines
" zi - invert foldenable
+
" zi   - invert foldenable
 +
 
 +
 
  
 
" KEYSEQS HELP {{{3
 
" KEYSEQS HELP {{{3
Line 926: Line 935:
 
" CTRL-I - forward trace of changes
 
" CTRL-I - forward trace of changes
 
" CTRL-O - backward trace of changes!
 
" CTRL-O - backward trace of changes!
" C-W W - Switch to other split window
+
" C-W W  - Switch to other split window
" CTRL-U   - DELETE FROM CURSOR TO START OF LINE
+
" CTRL-U                 - DELETE FROM CURSOR TO START OF LINE
" CTRL-^   - SWITCH BETWEEN FILES
+
" CTRL-^                 - SWITCH BETWEEN FILES
 
" CTRL-W-TAB  - CREATE DUPLICATE WINDOW
 
" CTRL-W-TAB  - CREATE DUPLICATE WINDOW
" CTRL-N   - Find keyword for word in front of cursor
+
" CTRL-N                 - Find keyword for word in front of cursor
" CTRL-P   - Find PREV diddo
+
" CTRL-P                 - Find PREV diddo
  
  
Line 942: Line 951:
 
" :%s/$/\^M/                      modifies abcde    to abcde^M
 
" :%s/$/\^M/                      modifies abcde    to abcde^M
 
" :%s/\w\+/\u\0/g                modifies bla bla  to Bla Bla
 
" :%s/\w\+/\u\0/g                modifies bla bla  to Bla Bla
" :g!/\S/d delete empty lines in file
+
" :g!/\S/d                             delete empty lines in file
  
  
Line 948: Line 957:
 
" ---------------------------------
 
" ---------------------------------
 
" :runtime! plugin/**/*.vim  - load plugins
 
" :runtime! plugin/**/*.vim  - load plugins
" :so $VIMRUNTIME/syntax/hitest.vim   " view highlight options
+
" :so $VIMRUNTIME/syntax/hitest.vim       " view highlight options
 
" :so $VIMRUNTIME/syntax/colortest.vim
 
" :so $VIMRUNTIME/syntax/colortest.vim
  
Line 966: Line 975:
 
" global /^ *$/ delete
 
" global /^ *$/ delete
  
" MISC EXAMPLES {{{3
 
" ---------------------------------
 
"f &term =~ "xterm"| f has("terminfo")set t_Co=8 t_Sf=<Esc>[3%p1%dm t_Sb=<Esc>[4%p1%dm  els  set t_Co=8 t_Sf=<Esc>[3%dm t_Sb=<Esc>[4%dm
 
"set t_AB=<Esc>[%?%p1%{8}%<%t25;%p1%{40}%+%e5;%p1%{32}%+%;%dm t_AF=<Esc>[%?%p1%{8}%<%t22;%p1%{30}%+%e1;%p1%{22}%+%;%dm
 
" }}}3
 
 
"}}}1 ENDOF VIM TIPS / HELP / TRICKS
 
  
 +
" ------------------------------------------------------------------------------------ }}}1 ENDOF VIM TIPS / HELP / TRICKS
 
</nowiki>}}
 
</nowiki>}}
  

Revision as of 11:38, 3 October 2013

Tango-document-new.pngThis article is a stub.Tango-document-new.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Vim/.vimrc#)

An example ~/.vimrc covering common options.

Setup

I install this as /etc/vimrc if possible. Individual users can use a vim config file in their home directories.

~/.vimrc
source /etc/vimrc

To install for a single user just save it in their home dir at /home/username/.vimrc

Portability

For the portability needed to work on many different systems, this doesn't rely on any plugins other than those built into the default installation of vim 7.0. It works well on all types of consoles, and depending on the TERM environment variable (and whether it has the right term capabilities) it will load 256 color support or not. Usually on a new system I just scp this right over and it works without any modifications. But an ongoing Work in progress.

Vimrc

Some example vimrc files are provided below:

~/.vimrc
" .vimrc
" See: http://vimdoc.sourceforge.net/htmldoc/options.html for details

" For multi-byte character support (CJK support, for example):
"set fileencodings=ucs-bom,utf-8,cp936,big5,euc-jp,euc-kr,gb18030,latin1
       
set tabstop=4       " Number of spaces that a <Tab> in the file counts for.
 
set shiftwidth=4    " Number of spaces to use for each step of (auto)indent.
 
set expandtab       " Use the appropriate number of spaces to insert a <Tab>.
                    " Spaces are used in indents with the '>' and '<' commands
                    " and when 'autoindent' is on. To insert a real tab when
                    " 'expandtab' is on, use CTRL-V <Tab>.
 
set smarttab        " When on, a <Tab> in front of a line inserts blanks
                    " according to 'shiftwidth'. 'tabstop' is used in other
                    " places. A <BS> will delete a 'shiftwidth' worth of space
                    " at the start of the line.
 
set showcmd         " Show (partial) command in status line.

set number          " Show line numbers.

set showmatch       " When a bracket is inserted, briefly jump to the matching
                    " one. The jump is only done if the match can be seen on the
                    " screen. The time to show the match can be set with
                    " 'matchtime'.
 
set hlsearch        " When there is a previous search pattern, highlight all
                    " its matches.
 
set incsearch       " While typing a search command, show immediately where the
                    " so far typed pattern matches.
 
set ignorecase      " Ignore case in search patterns.
 
set smartcase       " Override the 'ignorecase' option if the search pattern
                    " contains upper case characters.
 
set backspace=2     " Influences the working of <BS>, <Del>, CTRL-W
                    " and CTRL-U in Insert mode. This is a list of items,
                    " separated by commas. Each item allows a way to backspace
                    " over something.
 
set autoindent      " Copy indent from current line when starting a new line
                    " (typing <CR> in Insert mode or when using the "o" or "O"
                    " command).
 
set textwidth=79    " Maximum width of text that is being inserted. A longer
                    " line will be broken after white space to get this width.
 
set formatoptions=c,q,r,t " This is a sequence of letters which describes how
                    " automatic formatting is to be done.
                    "
                    " letter    meaning when present in 'formatoptions'
                    " ------    ---------------------------------------
                    " c         Auto-wrap comments using textwidth, inserting
                    "           the current comment leader automatically.
                    " q         Allow formatting of comments with "gq".
                    " r         Automatically insert the current comment leader
                    "           after hitting <Enter> in Insert mode. 
                    " t         Auto-wrap text using textwidth (does not apply
                    "           to comments)
 
set ruler           " Show the line and column number of the cursor position,
                    " separated by a comma.
 
set background=dark " When set to "dark", Vim will try to use colors that look
                    " good on a dark background. When set to "light", Vim will
                    " try to use colors that look good on a light background.
                    " Any other value is illegal.
 
set mouse=a         " Enable the use of the mouse.
 
filetype plugin indent on
syntax on

The next example should be used in combination with the askapachecode colorscheme below.

~/.vimrc or /etc/vimrc
" Updated: Tue Sep  3 14:23:14 2013
" Revision: 188
" Author: galileo@davinci

" http://www.askapache.com/linux/fast-vimrc.html

" For all key mappings like ', .' to reload vimrc
let maplocalleader=','




" BACKUPS, SWAPFILES, VIEWDIR, TMPDIR  "{{{1
" ====================================================================================

" SET RUNTIMEPATH {{{4
if isdirectory(expand("$HOME/.vim"))
   if isdirectory(expand("$HOME/.vim/colors"))
          if filereadable(expand("$HOME/colors/askapachecode.vim"))
                 let $VIMRUNTIME=expand("$HOME/.vim")
                 set runtimepath=$VIMRUNTIME
          endif
   endif
endif

"echomsg &runtimepath
"echomsg expand("$VIMRUNTIME")


" IF BKDIR IS NOT SET OR EMPTY, SET {{{4
if $BKDIR == ""
   let $BKDIR=expand("$HOME/.bk")
   if !isdirectory(expand("$BKDIR"))
          call mkdir(expand("$BKDIR"), "p", 700)
   endif
endif


" MAKE DIRS IF mkdir exists {{{4
if exists("*mkdir")
   let &viewdir=expand("$BKDIR") . "/.vim/viewdir"
   if !isdirectory(expand(&viewdir))|call mkdir(expand(&viewdir), "p", 700)|endif
   if !isdirectory(expand("$BKDIR/tmp/.vim"))|call mkdir(expand("$BKDIR/tmp/.vim"), "p", 700)|endif
   if !isdirectory(expand("$BKDIR/.vim/backups"))|call mkdir(expand("$BKDIR/.vim/backups"), "p", 700)|endif
   if !isdirectory(expand("$BKDIR/.vim/undos"))|call mkdir(expand("$BKDIR/.vim/undos"), "p", 700)|endif
endif


" SETTINGS USING NEW DIRS {{{4
let &dir=expand("$BKDIR") . "/.vim"
let &backupdir=expand("$BKDIR") . "/.vim/backups"
"let &undodir=expand("$BKDIR") . "/.vim/undos"
"set undofile
"let &verbosefile=expand("$BKDIR") . "/.vim/vim-messages.


" VIMINFO {{{4
" COMMENTED OUT {{{5
"  "       Maximum number of lines saved for each register
"  %       When included, save and restore the buffer lis
"  '       Maximum number of previously edited files for which the marks are remembere
"  /       Maximum number of items in the search pattern history to be saved
"  :        Maximum number of items in the command-line history
"  <       Maximum number of lines saved for each register.
"   @       Maximum number of items in the input-line history
"  h       Disable the effect of 'hlsearch' when loading the viminfo
"  n       Name of the viminfo file.  The name must immediately follow the 'n'. 
"  r       Removable media.  The argument is a string
"  s       Maximum size of an item in Kbyte
" }}}5 COMMENTED OUT

let &viminfo="%203,'200,/800,h,<500,:500,s150,r/tmp,r" . expand("$BKDIR") . "/tmp/.vim,n" . expand("$BKDIR") ."/.vim/.vinfo"
" }}}4 ENDOF VIMINFO

" --------------------------------------------------- }}}1 ENDOF BACKUPS, SWAPFILES, VIEWDIR, TMPDIR

" DYNAMIC SETTINGS / COLORS / TERMINAL {{{1
" ====================================================================================
"echomsg &t_Co
"echomsg &term

if &t_Co > 2

   if &term =~ "256"

          set bg=dark t_Co=256 vb
          let &t_vb="\<Esc>[?5h\<Esc>[?5l"      " flash screen for visual bell

          if filereadable(expand("$VIMRUNTIME/colors/askapachecode.vim"))
                 colorscheme askapachecode
          elseif filereadable(expand("$HOME/.vim/colors/askapachecode.vim"))
                 colorscheme askapachecode
          else
                 colorscheme default
          endif

   else
          " things like cfdisk, crontab -e, visudo, vless, etc.
          set term=screen-16color
          set t_Co=16

   endif

   filetype indent plugin on
   syntax on

endif
" -------------------------------------------------------------- }}}1 ENDOF DYNAMIC SETTINGS / COLORS / TERMINAL





" CUSTOM FUNCTIONS "{{{1
" ====================================================================================
if !exists("AskApacheLoaded")
   let AskApacheLoaded=1

   " http://dotfiles.org/~samba/.vimrc
   " www.gregsexton.org/2011/03/improving-the-text-displayed-in-a-fold/

   " DECLARATIONS {{{2
   " ================================================================================
   " FUNCTION - ManualLastMod {{{4
   function! ManualLastMod()
          "echomsg 'LastMod RUNNING'

          for [l,v,d] in [[2,'Updated'," "], [3,'Revision',1], [4,'Author'," "],[5,'','']]
                 call setline(l, printf('%s%s: %s', printf(&commentstring, ' '), v,d))
          endfor


          call LastMod()
   endfunction


   " FUNCTION - LastMod {{{4
   " Warning, this is controlled by an autocmd triggered when closing the file that updates the file (in a great way)
   function! LastMod()
          "echomsg 'LastMod RUNNING'
          if line("$") > 20|let l = 20|else|let l = line("$")|endif
          exe "silent! 1,".l."g/ Revision:[ \\d]\\+/s/\\d\\+/\\=submatch(0) + 1/e 1"
          exe "silent! 1,".l."g/ Author:/s/Author:.*/" . printf('Author: %s@%s', expand("$LOGNAME"), hostname()) . "/e 1"
          exe "silent! 1,".l."g/ Updated:/s/Updated:.*/" . printf('Updated: %s', strftime("%c")) . "/e 1"
   endfunction



   " FUNCTION - LastModAAZZZ {{{4
   " AA_UPDATED='2/24/12-00:56:00'
   function! LastModAAZZZ()
          exe "silent! 1,60 /^AA_VERSION=/s/\\d\\+$/\\=submatch(0) + 1/e 1"
          exe "silent! 1,60 /^AA_UPDATED=/s/AA_UPDATED=.*/AA_UPDATED='" . strftime("%c") . "'/e 1"

          exe "silent! 1,60 /^ISC_S_VERSION=/s/\\d\\+$/\\=submatch(0) + 1/e 1"
          exe "silent! 1,60 /^ISC_S_UPDATED=/s/ISC_S_UPDATED=.*/ISC_S_UPDATED='" . strftime("%c") . "'/e 1"
          "echomsg 'LastModAAZZZ RUNNING'
   endfunction


   " FUNCTION - AppendModeline {{{4
   " Append modeline after last line in buffer.  Use substitute() instead of printf() to handle '%%s' modeline
   function! AppendModeline()
          let l:modeline = printf(" vim: set ft=%s ts=%d sw=%d tw=%d :", &filetype, &tabstop, &shiftwidth, &textwidth)
          let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
          call append(line("$"), l:modeline)
   endfunction


   " FUNCTION - StripTrailingWhitespace {{{4
   " automatically remove trailing whitespace before write
   function! StripTrailingWhitespace()
          normal mZ
          %s/\s\+$//e
          if line("'Z") != line(".")|echo "Stripped whitespace\n"|endif
          normal `Z
   endfunction


   " FUNCTION - MyTabL {{{3
   function! MyTabL()
          let s = ''|let t = tabpagenr()|let i = 2
          while i <= tabpagenr('$')
                 let bl = tabpagebuflist(i)|let wn = tabpagewinnr(i)
                 let s .= '%' . i . 'T'. (i == t ? '%2*' : '%2*') . '%*' . (i == t ? ' %#TabLineSel# ' : '%#TabLine#')
                 let file = (i == t ? fnamemodify(bufname(bl[wn - 2]), ':p') : fnamemodify(bufname(bl[wn - 1]), ':t') )
                 if file == ''
                        let file = '[No Name]'
                 endif
                 let s .= i.' '. file .(i == t ? ' ' : '')|let i += 2
          endwhile
          let s .= '%T%#TabLineFill#%=' . (tabpagenr('$') > 2 ? '%999XX' : 'X')
          return s
   endfunction


   " FUNCTION - DiffWithSaved {{{3
   " Diff with saved version of the file
   function! s:DiffWithSaved()
          let filetype=&ft
          diffthis
          vnew | r # | normal! 2Gdd
          diffthis
          exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
   endfunction
   com! DiffSaved call s:DiffWithSaved()


   " FUNCTION - ShowWhitespace() {{{3
   function! ShowWhitespace(flags)
          let bad = ''
          let pat = []
          for c in split(a:flags, '\zs')
                 if c == 'e'
                        call add(pat, '\s\+$')
                 elseif c == 'i'
                        call add(pat, '^\t*\zs \+')
                 elseif c == 's'
                        call add(pat, ' \+\ze\t')
                 elseif c == 't'
                        call add(pat, '[^\t]\zs\t\+')
                 else
                        let bad .= c
                 endif
          endfor

          if len(pat) > 1
                 let s = join(pat, '\|')
                 exec 'syntax match ExtraWhitespace "'.s.'" containedin=ALL'
          else
                 syntax clear ExtraWhitespace
          endif

          if len(bad) > 1|echo 'ShowWhitespace ignored: '.bad|endif
   endfunction



   " FUNCTION - ToggleShowWhitespace {{{3
   " I use this all the time, it's mapped to , ts
   function! ToggleShowWhitespace()
          if !exists('b:ws_show')|let b:ws_show = 1|endif
          if !exists('b:ws_flags')|let b:ws_flags = 'est'|endif
          let b:ws_show = !b:ws_show
          if b:ws_show|call ShowWhitespace(b:ws_flags)|else|call ShowWhitespace('')|endif
   endfunction


   " FUNCTION - ValidVimCheck {{{3
   function! ValidVimCheck()
          if has('quickfix') && &buftype =~ 'nofile'
                 "echoerr "Buffer is marked as not a file"
                 return 0
          endif

          if empty(glob(expand('%:p')))
                 "echoerr "File does not exist on disk"
                 return 0
          endif

          if len($TMP) && expand('%:p:h') == $TMP
                 "echoerr "Also in temp dir"
                 return 0
          endif
          return 1
   endfunction


   " ------------------------------------------------------------- }}}2 ENDOF DECLARATIONS

endif

" ------------------------------------------------------------------------------------ }}}1 ENDOF CUSTOM FUNCTIONS




" OPTIONS "{{{1
" ====================================================================================


" DYNAMIC OPTIONS {{{2
" ================================================================================
" DISABLE MOUSE NO GOOEYS {{{3
if has('mouse')|set mouse=|endif

" SET TITLESTRING {{{3
if has('title')|set titlestring=%t%(\ [%R%M]%)|endif

" SET TABLINE {{{3
if exists("*s:MyTabL")|set tabline=%!MyTabL()|endif

let g:vimsyn_folding='af'

"DISABLE FILETYPE-SPECIFIC MAPS {{{3
let no_plugin_maps=1

"}}}2 DYNAMIC OPTIONS



" BACKUP, FILE OPTIONS {{{2
" ================================================================================
set backup                        " Make a backup before overwriting a file. 
set backupcopy=auto " When writing a file and a backup is made.  comma separated list of words. - value: yes,no,auto

set swapfile
set swapsync=fsync

"}}}2 BACKUP, FILE OPTIONS

" BASIC SETTINGS "{{{2
" ================================================================================
set nocompatible                " vim, not vi.. must be first, because it changes other options as a side effect
set modeline

set statusline=%M%h%y\ %t\ %F\ %p%%\ %l/%L\ %=[%{&ff},%{&ft}]\ [a=\%03.3b]\ [h=\%02.2B]\ [%l,%v]
set title titlelen=150 titlestring=%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ %{v:servername}

"set tags=tags;/                        " search recursively up for tags

set ttyfast                             " we have a fast terminal
set scrolljump=5          " when scrolling up down, show at least 5 lines
"set ttyscroll=999        " make vim redraw screen instead of scrolling when there are more than 3 lines to be scrolled

"set tw=500                             " default textwidth is a max of 5

set undolevels=1000             " 50 undos - saved in undodir
set updatecount=250             " switch every 250 chars, save swap

set whichwrap+=b,s,<,>,h,l,[,]                  " backspaces and cursor keys wrap to
"set wildignore+=*.o,*~,.lo,*.exe,*.bak " ignore object files
"set wildmenu                                                   " menu has tab completion
"set wildmode=longest:full                              " *wild* mode
set nowrap

set autoindent smartindent              " auto/smart indent

set autoread                                    " watch for file changes

set backspace=indent,eol,start  " backspace over all kinds of things

set cmdheight=1                                 " command line two lines high
set complete=.,w,b,u,U,t,i,d    " do lots of scanning on tab completion
set cursorline                                  " show the cursor line
"set enc=utf-8 fenc=utf-8               " utf-8

set history=3000                                " keep 3000 lines of command line history

set keywordprg=TERM=mostlike\ man\ -s\ -Pless

set laststatus=2

"set lazyredraw                                 " don't redraw when don't have to
set linebreak                                   " wrap at 'breakat' instead of last char
set magic                                               " Enable the "magic"

set maxmem=25123        " 24 MB -  max mem in Kbyte to use for one buffer.  Max is 2000000

set noautowrite                                 " don't automagically write on :next

set noexpandtab                                 " no expand tabs to spaces"
set noruler                                     " show the line number on the bar
set nospell
set nohidden                                    " close the buffer when I close a tab (I use tabs more than buffers)

set noerrorbells visualbell t_vb= " Disable ALL bells

set number                                      " line numbers

set pastetoggle=<F11>

set scrolloff=3                         " keep at least 3 lines above/below
set shiftwidth=3                        " shift width

set showcmd                                     " Show us the command we're typing
set showfulltag                         " show full completion tags
set showmode                            " show the mode all the time

set sidescroll=2                        " if wrap is off, this is fasster for horizontal scrolling
set sidescrolloff=2                     "keep at least 5 lines left/right

set noguipty

set splitright
set splitbelow

set restorescreen=on " restore screen contents when vim exits -  disable withset t_ti= t_te=

"set sessionoptions=word,blank,buffers,curdir,folds,globals,help,localoptions,resize,sesdir,tabpages,winpos,winsize
set winheight=25
set winminheight=1      " minimal value for window height
"set winheight=30       " set the minimal window height
set equalalways         " all the windows are automatically sized same
set eadirection=both    " only equalalways for horizontally split windows

set hlsearch

set laststatus=2

set tabstop=4
set softtabstop=4

set shiftwidth=3
set switchbuf=usetab

set commentstring=#%s

set tabpagemax=55
set showtabline=2               " 2 always, 1 only if multiple tabs
set smarttab                    " tab and backspace are smart

set foldmethod=marker
set foldenable
set foldcolumn=7                                " the blank left-most bar left of the numbered lines


set incsearch                                   " incremental search
"set ignorecase                                 " search ignoring case
set sc                                                  " override 'ignorecase' when pattern has upper case characters
set smartcase                                   " Ignore case when searching lowercase

set showmatch                                   " show matching bracket
set diffopt=filler,iwhite               " ignore all whitespace and sync"
set stal=2

set viewoptions=folds,localoptions,cursor

" ------------------------------------------------------------------------------------ }}}1 ENDOF OPTIONS


" PLUGIN SETTINGS {{{1
" ====================================================================================
" Settings for :TOhtml "{{{3
let html_number_lines=1
let html_use_css=1
let use_xhtml=1
" ------------------------------------------------------------------------------------ }}}1 ENDOF PLUGIN SETTINGS


" AUTOCOMMANDS "{{{1
" ====================================================================================
"{
"if !exists(":DiffOrig") | command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis | endif

" auto load extensions for different file types
if has('autocmd')

   if !exists("autocommands_loaded")

          let autocommands_loaded = 1



          " LASTMOD COMMANDS {{{2
          " ================================================================================
          augroup aazzlastmod
                 autocmd!

                 " INSERT CURRENT DATE AND TIME WHEN WRITING IT {{{3
                 autocmd BufWritePre,FileWritePre *.sh,.htaccess,*.conf,vimrc,.bash*,.*,*.cron ks|call LastMod()|'s

                 " AA_ZZZ LAST MOD {{{3
                 autocmd BufWritePre,FileWritePre zzz_askapache-bash.sh,*.sh ks|call LastModAAZZZ()|'s
          augroup END
          " ------------------------------------------------------------- }}}2 ENDOF LASTMOD COMMANDS


          " AUTOMKVIEW COMMANDS {{{2
          " ================================================================================
                 augroup aazzzmakeviewcheck
                        autocmd!

                        autocmd BufWinLeave * if ValidVimCheck() | mkview! |endif
                        autocmd BufWinEnter * if ValidVimCheck() | silent loadview | endif
                 augroup END
          " ------------------------------------------------------------- }}}2 ENDOF AUTOMKVIEW COMMANDS



          " MISC COMMANDS {{{2
          " ================================================================================

          " SAVE BACKUPFILE AS BACKUPDIR/FILENAME-06-13-1331 {{{3
          autocmd BufWritePre * let &bex = strftime("-%m-%d-%H%M")


          " CLEARMATCHES ON BUFWINLEAVE {{{3
          if exists("*clearmatches")
                 autocmd BufWinLeave *.* call clearmatches()
          endif

          " STRIP TRAILING WHITESPACE {{{3
          if exists("*s:StripTrailingWhitespace")
                 autocmd BufWritePre *.cpp,*.hpp,*.i,*.sh,.htaccess,*.conf :call s:StripTrailingWhitespace()
          endif
          " ------------------------------------------------------------- }}}2 ENDOF MISC COMMANDS





          " FILETYPES {{{2
          " ================================================================================
          " SET VIM SETTINGS FOR AA_ZZZ SCRIPTS {{{3
          autocmd BufRead .bash_profile,.bashrc,.bash_logout setlocal ts=4 sw=3 ft=sh foldmethod=marker tw=500 foldcolumn=7

          " TMUX FILETYPE {{{3
          autocmd BufRead tmux.conf,.tmux.conf,.tmux*,*/tmux-sessions/* setlocal filetype=tmux foldmethod=marker

          " LOGROTATE FILETYPE {{{3
          autocmd BufRead /etc/logrotate.d/*,/etc/logrotate.conf setlocal filetype=logrotate

          " FSTAB FILETYPE {{{3
          autocmd BufRead /etc/fstab,fstab setlocal foldmethod=marker


          " APACHE2 FILETYPE {{{3
          autocmd BufRead /etc/httpd/*.conf,httpd.conf setlocal filetype=apache foldmethod=marker foldcolumn=7 foldlevel=2


          " SH FILETYPES {{{3
          autocmd BufRead *.sh,*.cron,*.bash setlocal filetype=sh


          " SYSLOG-NG FILETYPE {{{3
          autocmd BufRead syslog-ng.conf setlocal filetype=syslog-ng


          " NET-PROFILES FILETYPE {{{3
          autocmd BufRead /etc/network.d/* setlocal filetype=conf


          " XDEFAULTS "{{{3
          autocmd FileType xdefaults setlocal foldmethod=marker foldlevel=2 commentstring=!%s

          " ------------------------------------------------------------- }}}2 ENDOF FILETYPES


          " MAN RUNTIME - TODO REPLACE WITH TMUXES CTRL-M BINDING {{{2
          " Lets you type :Man anymanpage and it will load in vim, color-coded and searchable
          " runtime ftplugin/man.vim

   endif
endif

" ------------------------------------------------------------------------------------ }}}1 ENDOF AUTOCOMMANDS





" MAPS "{{{1
" ====================================================================================

" FUNCTION MAPS {{{2
" ---------------------------------
" APPEND MODELINE {{{3
map <silent> <LocalLeader>ml :call AppendModeline()<CR>


" SHOW WHITESPACE {{{3
nnoremap <LocalLeader>ts :call ToggleShowWhitespace()<CR>


" SUDO A WRITE {{{3
command! W :execute ':silent w !sudo tee % > /dev/null' | :edit!
"cmap w!! %!sudo tee > /dev/null %
" :w !sudo tee > /dev/null %


" SET TABLINE {{{3
" My Personal Fav, inserts last-modified manually on current line when you press <F12> key
if exists("*ManualLastMod")
   map <silent> <F12> :call ManualLastMod()<CR>
endif


" RELOAD VIMRC FILES {{{3
map <LocalLeader>. :mkview<CR>:unlet! AskApacheLoaded autocommands_loaded<CR>:mapclear<CR>:source /etc/vimrc<CR>:loadview<CR>



" SCROLLING MAPS {{{3
map <PageDown> :set scroll=0<CR>:set scroll^=2<CR>:set scroll-=1<CR><C-D>:set scroll=0<CR>
map <PageUp> :set scroll=0<CR>:set scroll^=2<CR>:set scroll-=1<CR><C-U>:set scroll=0<CR>
nnoremap <silent> <PageUp> <C-U><C-U>
vnoremap <silent> <PageUp> <C-U><C-U>
inoremap <silent> <PageUp> <C-\><C-O><C-U><C-\><C-O><C-U>
nnoremap <silent> <PageDown> <C-D><C-D>
vnoremap <silent> <PageDown> <C-D><C-D>
inoremap <silent> <PageDown> <C-\><C-O><C-D><C-\><C-O><C-D>
"}}}3





" KEY MAPS {{{2
" physically map keys to produce different key, type CTRL-V in insert mode followed by any key to see how vim sees it
" ----------------------------------------
imap <ESC>[8~ <End>
map <ESC>[8~ <End>

imap <ESC>[7~ <Home>
map <ESC>[7~ <Home>

imap <ESC>OH <Home>
map <ESC>OH <Home>

imap <ESC>OF <End>
map <ESC>OF <End>


" Basic Maps  {{{2
" ----------------------------------------
" TOGGLE PASTE MODE {{{3
map <LocalLeader>pm :set nonumber! foldcolumn=0<CR>

" REINDENT FILE {{{3
map <LocalLeader>ri G=gg<CR>

" CLEAR SPACES AT END OF LINE {{{3
map <LocalLeader>cs :%s/\s\+$//e<CR>

" Y YANKS FROM CURSOR TO $ {{{3
map <LocalLeader>y "5y$
map <LocalLeader>r "_d$p




map <LocalLeader>dd _d<CR>

" DON'T USE EX MODE, USE Q FOR FORMATTING {{{3
map Q gq
map! ^H ^?

" NEXT SEARCH RESULT {{{3
map <silent> <LocalLeader>cn :cn<CR>

" WRAP? {{{3
map <silent> <LocalLeader>ww :ww

" ERR INSERTION {{{3
"map <silent> <LocalLeader>e <Home>A<C-R>=printf('%s', '_err "$0 $FUNCNAME:$LINENO FAILED WITH ARGS= $*"')<CR><Home><Esc>

" CUSTOM LINES FOR CODING {{{3
map <silent> <LocalLeader>l1 <Home>A<C-R>=printf('%s%s', printf(&commentstring, ' '), repeat('=', 160))<CR><Home><Esc>
map <silent> <LocalLeader>l2 <Home>A<C-R>=printf('%s%s', printf(&commentstring, ' '), repeat('=', 80))<CR><Home><Esc>
map <silent> <LocalLeader>l3 <Home>A<C-R>=printf('%s%s', printf(&commentstring, ' '), repeat('-', 40))<CR><Home><Esc>
map <silent> <LocalLeader>l4 <Home>A<C-R>=printf('%s%s', printf(&commentstring, ' '), repeat('-', 20))<CR><Home><Esc>

" CHANGE DIRECTORY TO THAT OF CURRENT FILE {{{3
nmap <LocalLeader>cd :cd%:p:h<CR>

" CHANGE LOCAL DIRECTORY TO THAT OF CURRENT FILE {{{3
nmap <LocalLeader>lcd :lcd%:p:h<CR>

" TOGGLE WRAPPING {{{3
nmap <LocalLeader>ww :set wrap!<CR>
nmap <LocalLeader>wo :set wrap<CR>



" TABS "{{{2
" ---------------------------------

" CREATE A NEW TAB {{{3
map <LocalLeader>tc :tabnew %<CR>

" LAST TAB {{{3
map <LocalLeader>t<Space> :tablast<CR>

" CLOSE A TAB {{{3
map <LocalLeader>tk :tabclose<CR>

" NEXT TAB {{{3
map <LocalLeader>tn :tabnext<CR>

" PREVIOUS TAB {{{3
map <LocalLeader>tp :tabprev<CR>









" FOLDS  "{{{2
" ---------------------------------
" Fold with paren begin/end matching
nmap F zf%

" When I use ,sf - return to syntax folding with a big foldcolumn
nmap <LocalLeader>sf :set foldcolumn=6 foldmethod=syntax<cr>
"}}}2

" ------------------------------------------------------------------------------------ }}}1 ENDOF MAPS


" HILITE "{{{1
" ====================================================================================
hi NonText cterm=NONE ctermfg=NONE
hi Search cterm=bold ctermbg=99 ctermfg=17
" ------------------------------------------------------------------------------------ }}}1 ENDOF HILITE







" VIM TIPS / HELP / TRICKS   {{{1
" ====================================================================================

" BEST TRICKS {{{2

" TERMCAP HELP {{{3
" :help termcap

" :g/^\s*$/;//-1sort to sort each block of lines in a file.


" VIEW DIFF OF EDITS AGAINST BUFFER VS ORIGINAL FILE {{{3
" :w !colordiff -u % -


" INSERT CURRENT FILENAME {{{3
" :r! echo %

" DELETE TRAILING WHITESPACE {{{3
" :%s/\s\+$//

" Changing Case
" guu                             : lowercase line
" gUU                             : uppercase line
" Vu                              : lowercase line
" VU                              : uppercase line
" g~~                             : flip case line
" vEU                             : Upper Case Word
" vE~                             : Flip Case Word
" ggguG                           : lowercase entire file
" " Titlise Visually Selected Text (map for .vimrc)
" vmap ,c :s/\<\(.\)\(\k*\)\>/\u\1\L\2/g<CR>
" " Title Case A Line Or Selection (better)
" vnoremap <F6> :s/\%V\<\(\w\)\(\w*\)\>/\u\1\L\2/ge<cr> [N]
" " titlise a line
" nmap ,t :s/.*/\L&/<bar>:s/\<./\u&/g<cr>  [N]
" " Uppercase first letter of sentences
" :%s/[.!?]\_s\+\a/\U&\E/g


" :r file " read text from file and insert below current line

" :so $VIMRUNTIME/syntax/hitest.vim       " view highlight options

"}}}2


" HELP HELP {{{3
" ---------------------------------
" :helpg pattern                                          search grep!! ---  JUMP TO OTHER MATCHES WITH: >
" :help holy-grail
" :help all
" :help termcap
"  :help user-toc.txt          Table of contents of the User Manual. >
"  :help :subject              Ex-command "subject", for instance the following: >
"  :help :help                 Help on getting help. >
"  :help CTRL-B                Control key <C-B> in Normal mode. >
"  :help 'subject'             Option 'subject'. >
"  :help EventName             Autocommand event "EventName"
"  :help pattern<Tab>          Find a help tag starting with "pattern".  Repeat <Tab> for others. >
"  :help pattern<Ctrl-D>       See all possible help tag matches "pattern" at once. >
"                 :cn                         next match >
"                 :cprev, :cN                 previous match >
"                 :cfirst, :clast             first or last match >
"                 :copen,  :cclose            open/close the quickfix window; press <Enter> to jump to the item under the cursor



" SET HELP {{{3
" ---------------------------------
" :verbose set opt? - show where opt was set
" set opt!              - invert
" set invopt            - invert
" set opt&              - reset to default
" set all&              - set all to def
" :se[t]                        Show all options that differ from their default value.
" :se[t] all            Show all but terminal options.
" :se[t] termcap                Show all terminal options.  Note that in the GUI the



" TAB HELP   {{{3
" ---------------------------------
" tc    - create a new tab
" td    - close a tab
" tn    - next tab
" tp    - previous tab



" UPPERCASE, LOWERCASE, INDENTS {{{3
" ---------------------------------
" '.    - last modification in file!
" gf  - open file under cursor
" guu - lowercase line
" gUU - uppercase line
" =   - reindent text



" FOLDS {{{3
" ---------------------------------
" F     - create a fold from matching parenthesis
" fm    - (zm)  more folds
" fl  - (zr) less/reduce folds
" fo    - open all folds (zR)
" fc    - close all folds (zM)
" ff  -  (zf)   - create a fold
" fd    - (zd)  - delete fold at cursor
" zF    - create a fold N lines
" zi    - invert foldenable



" KEYSEQS HELP {{{3
" ---------------------------------
" CTRL-I - forward trace of changes
" CTRL-O - backward trace of changes!
" C-W W  - Switch to other split window
" CTRL-U                  - DELETE FROM CURSOR TO START OF LINE
" CTRL-^                  - SWITCH BETWEEN FILES
" CTRL-W-TAB  - CREATE DUPLICATE WINDOW
" CTRL-N                  - Find keyword for word in front of cursor
" CTRL-P                  - Find PREV diddo


" SEARCH / REPLACE {{{3
" ---------------------------------
" :%s/\s\+$//    - delete trailing whitespace
" :%s/a\|b/xxx\0xxx/g             modifies a b      to xxxaxxxbxxx
" :%s/\([abc]\)\([efg]\)/\2\1/g   modifies af fa bg to fa fa gb
" :%s/abcde/abc^Mde/              modifies abcde    to abc, de (two lines)
" :%s/$/\^M/                      modifies abcde    to abcde^M
" :%s/\w\+/\u\0/g                 modifies bla bla  to Bla Bla
" :g!/\S/d                              delete empty lines in file


"  COMMANDS {{{3
" ---------------------------------
" :runtime! plugin/**/*.vim  - load plugins
" :so $VIMRUNTIME/syntax/hitest.vim       " view highlight options
" :so $VIMRUNTIME/syntax/colortest.vim

" :!!date - insert date
" :%!sort -u  - only show uniq (and sort)

" :r file " read text from file and insert below current line
" :v/./.,/./-1join  - join empty lines

" :e! return to unmodified file
" :tabm n  - move tab to pos n
" :jumps
" :history
" :reg   -  list registers

" delete empty lines
" global /^ *$/ delete


" ------------------------------------------------------------------------------------ }}}1 ENDOF VIM TIPS / HELP / TRICKS

Colorscheme

Here is a colorscheme file optimized for 256 colors. It will work if saved in ~/.vim/colors/askapachecode.vim or likewise in your runtimepath. Additionally, you could just paste it in the bottom of the above vimrc.

The code really needs to be cleaned up, but it looks awesome.

~/.vim/colors/askapachecode.vim
" vim: ft=vim fdm=marker fdl=0
" Vim color file -- askapachecode
" Maintainer: AskApache <askapache@gmail.com>
" Last Change: Thu Oct 3 06:30:42 2013
" %s/[\t] {1, }/ /g | %s/[\t]*//g



set background=dark
hi clear

if exists("syntax_on")
 syntax reset
endif

let g:colors_name="askapachecode"

hi CursorLine ctermbg=236
hi CursorColumn ctermbg=236
hi MatchParen ctermfg=157 ctermbg=237 cterm=bold
hi Pmenu ctermfg=255 ctermbg=238
hi PmenuSel ctermfg=0 ctermbg=148

" General colors
hi Cursor ctermbg=241
hi Normal ctermfg=253 ctermbg=232
hi NonText ctermfg=244 ctermbg=235
hi LineNr ctermfg=244 ctermbg=232
hi StatusLine ctermfg=253 ctermbg=238 cterm=italic
hi StatusLineNC ctermfg=246 ctermbg=238
hi VertSplit ctermfg=238 ctermbg=238
hi Folded ctermbg=4 ctermfg=248
hi Title ctermfg=254 cterm=bold
hi Visual ctermfg=254 ctermbg=4
hi SpecialKey ctermfg=244 ctermbg=236

hi pythonOperator ctermfg=103

hi Search cterm=NONE	




" basic highlight groups (:help highlight-groups) {{{1

" text {{{2
hi Normal ctermfg=white ctermbg=black cterm=NONE
hi Folded ctermfg=lightgray ctermbg=black cterm=underline
hi LineNr ctermfg=darkgray ctermbg=NONE cterm=NONE
hi Directory ctermfg=cyan ctermbg=NONE cterm=NONE
hi NonText ctermfg=yellow ctermbg=NONE cterm=NONE
hi SpecialKey ctermfg=green ctermbg=NONE cterm=NONE

hi DiffAdd ctermfg=white ctermbg=darkblue cterm=NONE
hi DiffChange ctermfg=black ctermbg=darkmagenta cterm=NONE
hi DiffDelete ctermfg=black ctermbg=red cterm=bold
hi DiffText ctermfg=white ctermbg=green cterm=bold


" borders / separators / menus {{{2
hi FoldColumn ctermfg=lightgray ctermbg=darkgray cterm=NONE
hi SignColumn ctermfg=lightgray ctermbg=darkgray cterm=NONE
hi Pmenu ctermfg=white ctermbg=darkgray cterm=NONE
hi PmenuSel ctermfg=white ctermbg=lightblue cterm=NONE
hi PmenuSbar ctermfg=black ctermbg=black cterm=NONE
hi PmenuThumb ctermfg=gray ctermbg=gray cterm=NONE

hi StatusLine ctermfg=black ctermbg=white cterm=bold
hi StatusLineNC ctermfg=darkgray ctermbg=white cterm=NONE
hi WildMenu ctermfg=white ctermbg=darkblue cterm=bold
hi VertSplit ctermfg=white ctermbg=white cterm=NONE

if &t_Co == 256|hi TabLine ctermfg=15 ctermbg=242 term=underline|else|hi TabLine ctermfg=grey ctermbg=white term=underline|endif



hi TabLineFill ctermfg=grey ctermbg=white cterm=NONE
hi TabLineSel ctermfg=green ctermbg=black term=bold


" cursor / dynamic / other {{{2
hi Cursor ctermfg=black ctermbg=white cterm=NONE
hi CursorIM ctermfg=black ctermbg=white cterm=reverse
hi CursorLine ctermfg=NONE ctermbg=NONE cterm=NONE
hi CursorColumn ctermfg=NONE ctermbg=NONE cterm=NONE

hi Visual ctermfg=white ctermbg=lightblue cterm=NONE
hi IncSearch ctermfg=white ctermbg=yellow cterm=NONE
hi Search ctermfg=white ctermbg=darkgreen cterm=NONE


" LISTINGS / MESSAGES {{{2
hi ModeMsg ctermfg=yellow ctermbg=NONE cterm=NONE
hi Title ctermfg=red ctermbg=NONE cterm=bold
hi Question ctermfg=green ctermbg=NONE cterm=NONE
hi MoreMsg ctermfg=green ctermbg=NONE cterm=NONE
hi ErrorMsg ctermfg=white ctermbg=red cterm=bold
hi WarningMsg ctermfg=yellow ctermbg=NONE cterm=bold

hi Directory term=bold ctermfg=4 "{{{
hi ErrorMsg term=standout ctermfg=15 ctermbg=1  
hi IncSearch term=reverse cterm=reverse 
hi Search term=NONE ctermfg=255 ctermbg=135
hi MoreMsg term=bold ctermfg=2  
hi ModeMsg term=bold cterm=bold 
hi LineNr term=underline ctermfg=244 ctermbg=232  
hi Question term=standout ctermfg=2  
hi StatusLine term=bold,reverse cterm=italic ctermfg=253 ctermbg=238   
hi StatusLineNC term=reverse cterm=reverse ctermfg=246 ctermbg=238  
hi VertSplit term=reverse cterm=reverse ctermfg=238 ctermbg=238  
hi Title term=bold cterm=bold ctermfg=254  
hi Visual term=reverse ctermfg=254 ctermbg=4  
hi VisualNOS term=bold,underline cterm=bold,underline
hi WarningMsg term=standout ctermfg=1 
hi WildMenu term=standout ctermfg=0 ctermbg=11  
hi Folded term=standout cterm=BOLD ctermfg=7 ctermbg=27
hi FoldColumn term=NONE cterm=NONE ctermfg=75 ctermbg=16
hi IncSearch term=bold,underline cterm=bold,underline ctermfg=7 ctermbg=9
hi DiffAdd term=bold ctermbg=12 
hi DiffChange term=bold ctermbg=13 
hi DiffDelete term=bold ctermfg=12 ctermbg=14   
hi DiffText term=reverse cterm=bold ctermbg=9  
hi SpellBad term=reverse ctermbg=9  
hi SpellCap term=reverse ctermbg=12  
hi SpellRare term=reverse ctermbg=13  
hi SpellLocal term=underline ctermbg=14  
hi Pmenu ctermfg=255 ctermbg=238  
hi PmenuSel ctermfg=0 ctermbg=148  
hi PmenuSbar ctermbg=7 
hi PmenuThumb cterm=reverse 
hi TabLine term=underline cterm=underline ctermfg=0 ctermbg=7  
hi TabLineSel term=bold cterm=bold 
hi TabLineFill term=reverse cterm=reverse 
hi CursorLine term=underline cterm=bold ctermbg=234
hi Cursor ctermbg=241 
hi MatchParen term=reverse cterm=bold ctermfg=157 ctermbg=237   
hi Error term=reverse ctermfg=15 ctermbg=9  





" :hi TabLineSel|hi TabLineFill|hi TabLine
"hi TabLineSel term=bold cterm=bold 
"hi TabLineFill term=reverse cterm=reverse 
"hi TabLine term=underline cterm=underline ctermfg=15 ctermbg=242 
hi ExtraWhitespace ctermbg=red
hi Comment term=none ctermfg=darkgrey 
hi Constant term=underline ctermfg=Magenta 
hi Special term=bold ctermfg=DarkMagenta 
hi Identifier term=underline cterm=bold ctermfg=Cyan 
hi Statement term=bold ctermfg=Yellow 
hi PreProc term=underline ctermfg=LightBlue 
hi Type term=underline ctermfg=LightGreen 
hi Repeat term=underline ctermfg=White 
hi Operator ctermfg=Red 
hi Ignore ctermfg=black 
hi Error term=reverse ctermbg=Red ctermfg=White 
hi Todo term=standout ctermbg=Yellow ctermfg=Black 



" COMMON GROUPS THAT LINK TO DEFAULT HIGHLIGHTING.
hi Function ctermfg=85
hi String ctermfg=204
hi Statement term=bold cterm=bold ctermfg=81
hi Function term=bold cterm=bold ctermfg=32
hi Number ctermfg=129
hi Conditional term=bold cterm=bold ctermfg=47
hi Special term=underline ctermfg=191
hi Normal ctermfg=7
hi PreProc ctermfg=141

" Syntax highlighting
hi Comment ctermfg=244
hi Todo ctermfg=245
hi Boolean ctermfg=148
hi String ctermfg=148
hi Identifier ctermfg=148
hi Function ctermfg=124
hi Type ctermfg=103
hi Statement ctermfg=103
hi Keyword ctermfg=81
hi Constant ctermfg=81
hi Number ctermfg=81
hi Special ctermfg=81
hi PreProc ctermfg=230
" Code-specific colors
 

" SYNTAX HIGHLIGHTING GROUPS (:HELP GROUP-NAME) {{{2

hi FoldColumn ctermbg=0 ctermfg=2
hi Folded cterm=none ctermfg=2
hi NonText cterm=NONE ctermfg=NONE 
hi StatusLine ctermfg=black ctermbg=White cterm=bold
hi StatusLineNC ctermfg=White ctermbg=green cterm=NONE
hi CursorLine cterm=bold term=bold

" FINAL THOUGHTS "{{{2
"syn region myFold start="{" end="}" transparent fold
hi Search term=reverse ctermfg=0 ctermbg=11
hi LineNr term=underline ctermfg=244 ctermbg=232
hi MatchParen ctermfg=15 ctermbg=242
hi String ctermfg=10
hi Constant ctermfg=14
hi Identifier ctermfg=14

hi Operator ctermfg=13
hi NonText cterm=NONE ctermfg=NONE
hi Search cterm=bold ctermbg=99 ctermfg=17

See also

Some more examples can be found in Vim#Example_configurations.