FREE THOUGHT · FREE SOFTWARE · FREE WORLD

Home  »  Linux  »  Optimized Vimrc with 256 Colorscheme

by 7 comments

This is 90% geared for purely console/terminal/pty/tty/ssh/putty/telnet/tmux/screen users. I've only just the past couple years started understanding why it was key to learn vim, in the past I never had the patience for it and preferred nano-like editors. Now vim is all I use when on linux, it's so much more productive.. especially with a customized vimrc file. This doesn't require a git checkout, a vim update, a bash update, an OS update, a plugin. No. This is a single file that I use on Arch Linux, NetBSD, FreeBSD, OpenBSD, Debian, Ubuntu, Cent OS, Red Hat, and that's it so far. This is geared for users who use SSH more than anything else. Of course, it works perfect on an X enabled box locally as well.


ScreenShot

Screenshot of this vimrc in action

Setup

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

source /etc/vimrc

To install for a single user just save it in their home dir at /web/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.

Optimized Vimrc

Download - Optimized vimrc

" Updated: Wed Feb 22 13:25:23 2012 by galileo@galileo
 
" For all key mappings like ', .' to reload vimrc
let maplocalleader=','
 
" BACKUPS, SWAPFILES, VIEWDIR, TMPDIR  "{{{1
" ================================================================================================================================================================
 
" SET RUNTIMEPATH {{{3
if isdirectory(expand("$HOME/.vim"))
  let $VIMRUNTIME=expand("$HOME/.vim")
  set runtimepath=$VIMRUNTIME
endif
 
" IF BKDIR IS NOT SET OR EMPTY, SET {{{3
if $BKDIR == ""
  let $BKDIR=expand("$HOME/.bk")
  if !isdirectory(expand("$BKDIR"))
    call mkdir(expand("$BKDIR"), "p", 0700)
  endif
endif
 
" MAKE DIRS IF mkdir exists {{{3
if exists("*mkdir")
  if !isdirectory(expand("$BKDIR/.vim/viewdir"))|call mkdir(expand("$BKDIR/.vim/viewdir"), "p", 0700)|endif
  if !isdirectory(expand("$BKDIR/.vim/tmp"))|call mkdir(expand("$BKDIR/.vim/tmp"), "p", 0700)|endif
  if !isdirectory(expand("$BKDIR/.vim/backups"))|call mkdir(expand("$BKDIR/.vim/backups"), "p", 0700)|endif
endif
 
" SETTINGS USING NEW DIRS {{{3
let &dir=expand("$BKDIR") . "/.vim"
let &viewdir=expand("$BKDIR") . "/.vim/viewdir"
let &backupdir=expand("$BKDIR") . "/.vim/backups"
"let &verbosefile=expand("$BKDIR") . "/.vim/vim-messages.
 
" VIMINFO {{{3
" COMMENTED OUT {{{4
"  "       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'.  Must be the last oneEnvironment variables are expanded when opening the file, not when setting the option
"  r       Removable media.  The argument is a string
"  s       Maximum size of an item in Kbyte
"   }}}4 COMMENTED OUT
let &viminfo="%200,'200,/800,h,<500,:500,s150,r/tmp,r" . expand("$BKDIR") . "/.vim/tmp,n" . expand("$BKDIR") ."/.vim/.vinfo"
 
" CUSTOM FUNCTIONS "{{{1
" ================================================================================================================================================================
if !exists("AskApacheLoaded")
  let AskApacheLoaded=1
 
  " FUNCTION - LastMod {{{3
  " 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! LastMod()
    exe "silent! 1,20s/Updated: .*/" . printf('Updated: %s by %s@%s', strftime("%c"), expand("$LOGNAME"), hostname()) . "/e"
  endfunction
 
  " 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
 
  " 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 - 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
  " automatically remove trailing whitespace before write
  function! StripTrailingWhitespace()
    normal mZ
    %s/s+$//e
    if line("'Z") != line(".")|echo "Stripped whitespacen"|endif
    normal `Z
  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 - 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 - 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, ' +zet')
      elseif c == 't'
        call add(pat, '[^t]zst+')
      else
        let bad .= c
      endif
    endfor
 
    if len(pat) > 0
      let s = join(pat, '|')
      exec 'syntax match ExtraWhitespace "'.s.'" containedin=ALL'
    else
      syntax clear ExtraWhitespace
    endif
 
    if len(bad) > 0|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 = 0|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
 
endif
 
" DYNAMIC SETTINGS / COLORS / TERMINAL {{{1
" ================================================================================================================================================================
 
" 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
 
"}}}1 DYNAMIC SETTINGS / COLORS / TERMINAL
 
" OPTIONS "{{{1
" ===========================================================================================================================================================================
 
" BACKUP, FILE OPTIONS {{{2
" ================================================================================
set backup        " Make a backup before overwriting a file.  Leave it around after the file has been successfully written.
set backupcopy=auto " When writing a file and a backup is made, this option tells how it's done.  This is a comma separated list of words. - value: yes,no,auto - no:rename the file and write a new one
 
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=10    " 50 undos - saved in memory
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=6        " 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
 
"}}}1 OPTIONS
 
" PLUGIN SETTINGS {{{1
" ================================================================================================================================================================
" Settings for :TOhtml "{{{3
let html_number_lines=1
let html_use_css=1
let use_xhtml=1
"}}}1 PLUGIN SETTINGS
 
" COLORSCHEME IF MORE THAN 2 COLORS lol {{{1
" ================================================================================================================================================================
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
 
    filetype indent plugin on
    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
 
"}}}1
 
" 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
 
    " JUMP TO LAST POS {{{3
    " 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
    " (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.
    au BufReadPost * if line("'"") > 1 && line("'"") <= line("$") | exe "normal! g`"" | endif
 
    " CLEARMATCHES ON BUFWINLEAVE {{{3
    au BufWinLeave * call clearmatches()
 
    " STRIP TRAILING WHITESPACE {{{3
    autocmd BufWritePre *.cpp,*.hpp,*.i :call StripTrailingWhitespace()
 
    " AA_ZZZ LAST MOD {{{3
    autocmd BufWritePre,FileWritePre,TabLeave zzz_askapache-bash.sh ks|call LastModAAZZZ()|'s
 
    " 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
    autocmd BufRead quickfix setlocal nobuflisted wrap number
 
    " SAVE BACKUPFILE AS BACKUPDIR/FILENAME-06-13-1331 {{{3
    autocmd BufWritePre * let &bex = strftime("-%m-%d-%H%M")
 
    " TMUX FILETYPE {{{3
    autocmd BufRead tmux.conf,.tmux.conf,.tmux*,*/tmux-sessions/* setlocal filetype=tmux foldmethod=marker
 
    " 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
 
    " SYSLOG-NG FILETYPE {{{3
    autocmd BufRead syslog-ng.conf setlocal filetype=syslog-ng
 
    " COMMENTSTRING FOR VIM "{{{3
    au FileType vim setlocal commentstring="%s
 
    " COMMENTSTRING FOR XDEFAULTS "{{{3
    au FileType xdefaults setlocal foldmethod=marker foldlevel=2 commentstring=!%s
 
    " VIMRC {{{3
    augroup vimrc
      au BufReadPre * setlocal foldmethod=indent
      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
    augroup END
 
    " 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
" ===========================================================================================================================================================================
 
" 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
" call setline(1, printf('%sUpdated: %s by %s@%s', printf(&commentstring, ' '), strftime("%c"), expand("$LOGNAME"), hostname()))
if exists("*s:LastModNow")
  map <silent> <f12> :call LastModNow()<cr>
endif
 
" RELOAD VIMRC FILES {{{3
map <localLeader>. :mkview<cr>:unlet! AskApacheLoaded autocommands_loaded<cr>:mapclear<cr>:source /etc/vimrc<cr>:echoerr 'VIMRC RELOADED'<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>
 
" 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 Y y$
 
" 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
 
" HILITE "{{{1
" ===========================================================================================================================================================================
hi NonText cterm=NONE ctermfg=NONE
hi Search cterm=bold ctermbg=99 ctermfg=17
"}}}
 

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.

Download - askapachecode - 256 Colors Vim Colorscheme

~/.vim/colors/askapachecode.vim

" Vim color file -- askapachecode
" Maintainer: AskApache <webmaster@askapache.com>
" Updated: Wed Feb 22 14:10:54 2012 by galileo@galileo
 
set background=dark
hi clear
 
if exists("syntax_on")|syntax reset|endif
 
let g:colors_name="askapachecode"
 
" Vim >= 7.0 specific colors
if version >= 700
 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
endif
 
" 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 TabLine ctermfg=white ctermbg=white cterm=NONE
hi TabLineFill ctermfg=grey ctermbg=white cterm=NONE
"hi TabLineSel ctermfg=black ctermbg=green cterm=NONE
hi TabLineSel ctermfg=green ctermbg=black term=bold
"hi TabLineSel term=bold cterm=bold
"hi TabLineFill term=reverse cterm=reverse
"hi TabLine term=underline cterm=underline ctermfg=15 ctermbg=242
 
"hi Menu
"hi Scrollbar
"hi Tooltip
 
" 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

Additional Resources

  1. The perfect .vimrc vim config file

Tags

December 3rd, 2012

Comments Welcome

  • bronso

    Getting an error using this .vimrc on Redhat Linux 5.7

    Error detected while processing BufWinLeave Auto commands for "*":
    E117: Unknown function: clearmatches

    Error doesn't occur on current version of Cygwin.

  • xref

    Hey! Really awesome post this. However I keep getting this error:

    Error detected while processing /web//.vimrc:
    line 270:
    E36: Not enough room

    Why is this happening? I want to make my vim look as awesome as the screenshot in your post! I use it for programming in python.

    • AskApache

      I think that's due to your terminal size is too small for the auto-height options... You can always type this from within vim to find out:

      : helpg E36
  • Gaetan Asselin

    Hi!

    Just installed VIM from FreeBSD ports.
    I would appreciate your help by either pointing me in the right direction or simply tell me how
    to apply your ".vmrc" file to it ?

    Looking forward to your reply. Thank you very much.

    Best salutations !

    Gaetan

    • AskApache

      Just save this file as ~/.vimrc and you are good to go. Don't forget the colorscheme. Let me know how it works, I haven't used extensively on FreeBSD.

  • Edward Beckett

    Nice ...

    MUST HAVES for me ... :-)

    • Pathogen ... it's just an awesome way to manage vim plugins ...
    • NERDTree ... Great way to explore directories ...

    My minimal .vimrc ...

    call pathogen#infect()
    call pathogen#runtime_append_all_bundles()
    call pathogen#helptags()
    filetype plugin indent on
    autocmd vimenter * NERDTree
    autocmd vimenter * wincmd l
    autocmd WinEnter * call s:IfNoBuffers()
    function! s:IfNoBuffers()
      if exists("t:NERDTreeBufName")
        if bufwinnr(t:NERDTreeBufName) != -1
          if winnr("$") == 1
            q
          endif
        endif
      endif
    endfunction
    nmap  :NERDTreeToggle
    :colorscheme elflord
    :set mouse=a
    :set number
    :set guifont=Monospace 12
    :syntax enable
    :set guicursor=a:ver25-Cursor/lCursor
    :set showcmd
    :set ruler
    :set hlsearch
    :set incsearch
  • Tommy Nguyen

    Wow! This is a tremendous .vimrc! Thanks for sharing :-)

My Online Tools


Popular Articles



Hacking and Hackers

The use of "hacker" to mean "security breaker" is a confusion on the part of the mass media. We hackers refuse to recognize that meaning, and continue using the word to mean someone who loves to program, someone who enjoys playful cleverness, or the combination of the two. See my article, On Hacking.
-- Richard M. Stallman



Related Articles

Twitter









[hide]

It's very simple - you read the protocol and write the code. -Bill Joy

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. NCSA HTTPd.
UNIX ® is a registered Trademark of The Open Group. POSIX ® is a registered Trademark of The IEEE.

+Askapache | askapache

Site Map | Contact Webmaster | License and Disclaimer | Terms of Service

↑ TOPMain