Skip to content

Instantly share code, notes, and snippets.

@GregLevenhagen
Last active December 1, 2016 02:14
Show Gist options
  • Save GregLevenhagen/8908696 to your computer and use it in GitHub Desktop.
Save GregLevenhagen/8908696 to your computer and use it in GitHub Desktop.
vimrc linux
set nocompatible
" Remove ALL auto-commands. This avoids having the autocommands twice when
" the vimrc file is sourced again.
autocmd!
" Suffixes that get lower priority when doing tab completion for filenames.
" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
set encoding=utf-8
set showcmd " display incomplete commands
set ruler
set laststatus=2 " Always show the statusline
set number " show line numbers
" tab settings
filetype plugin indent on " load file type plugins + indentation from indent folder
set autoindent " should not interfere with filetype based indentation, but smartident would
set tabstop=4
set shiftwidth=4
set expandtab " use spaces, not tabs
" Whitespace, except tabs
set nowrap " don't wrap lines
set backspace=indent,eol,start " make backspace work like most other apps
" Searching
set hlsearch " highlight matches
set incsearch " incremental search
set ignorecase " searches are case insensitive
set smartcase " depends on ignorecase: searches case insensitive unless one capital is used
" Menu
set wildmenu
set wildmode=list:longest,full
set sidescroll=1
set updatecount=0
set taglength=0
set tags+=../tags,/usr/local/include/tags,/usr/include/tags
set wrapscan
set shell=$SHELL\ -f
set report=1
set noshowmode
set showmatch
set helpheight=100
set nostartofline
set highlight=l:MySearch
set clipboard=autoselect
set visualbell t_vb=
set viminfo='20,\"50
if &fileformat == "dos"
set backupdir=C:/temp
else
set backupdir=/tmp
endif
let c_syntax_for_h=1
let perl_fold=1
if &fileformat == "dos" || &term =~ "xterm" || &term =~ "vt220"
set title
endif
if &term == "xterm" || &term == "vt220"
" Automatically restores the xterm screen even if it wasn't compiled in.
set t_ti=7[?47h
set t_te=[?47l8
" Let the title stuff work even if we don't open the DISPLAY
set t_ts=]2;
set t_fs=
endif
autocmd BufEnter * let &titlestring = $HOSTNAME . ":" . expand("%:p:~")
" Make the function keys work from home
if &term == "vt220"
set t_k1=[11~
set t_k2=[12~
set t_k3=[13~
set t_k4=[14~
set t_k5=[15~
endif
" turn search highlighting on and off
map <F5> :set hls!<bar>set hls?<CR>
imap <F5> <Esc>:set hls!<bar>set hls?<CR>i
map <F6> :r !date<CR>
imap <F6> <Esc>:r !date<CR>i
map M :set paste!<bar>set paste?<CR>
map F :set formatoptions=tcql<bar>set tw=72<CR>
map s :source $HOME/.vimrc<CR>
map  $
map  :bn<CR>
" map Ctrl-A, Ctrl-E, and Ctrl-K in *all* modes. map! makes the mapping work in
" insert and commandline modes too.
map <C-A> <Home>
map <C-E> <End>
map <C-K> J
map! <C-A> <Home>
map! <C-E> <End>
imap <C-K> <Esc>Ji
" I'm used to Q formatting text. Newer versions of Vim changed this, so I
" change it back
map Q gq
" Turn off incremental searching for files over 10,000,000 bytes. It's too slow.
function! IncSearch()
if line2byte(line("$")) < 10000000
set incsearch
else
set noincsearch
endif
endfunction
autocmd BufReadPost * call IncSearch()
autocmd BufEnter * doautocmd FileType
if &filetype == ""
setfiletype text
endif
function! PoundComment()
map - 0i# <ESC>j
map _ :s/^\s*# \=//g<CR>j
set comments=:#
endfunction
function! LispComment()
map - 0i; <ESC>j
map _ :s/^\s*; \=//g<CR>j
set comments=:;
endfunction
function! HTMLComment()
map - $a --><ESC>0i<!-- <ESC><CR>
map _ :s/^\s*<!-- \=//g<CR>:s/ \=-->[ \t]*$//g<CR>j
set tw=0 formatoptions=tcq
endfunction
function! CComment()
map - $a */<ESC>0i/* <ESC><CR>
map _ :s/^\s*\/\* \=//g<CR>:s/ \=\*\/[ \t]*$//g<CR>j
set nocindent comments=sr:/*,mb:*,ex:*/,://
" set nocindent comments=:/*,://
endfunction
function! TexComment()
map - 0i% <ESC>j
map _ :s/^\s*% \=//g<CR>j
set nocindent comments=sr:%,mb:%,el:%,://
set tw=72 formatoptions=tcqro
endfunction
function! CPlusPlusComment()
map - 0i// <ESC>j
map _ :s/^\s*\/\/ \=//g<CR>j
set nocindent comments=:\/\/
endfunction
function! VHDLComment()
map - 0i-- <ESC>j
map _ :s/^\s*-- \=//g<CR>j
set comments=:--
endfunction
" function! CDSLibComment()
" map - 0i-- <ESC>j
" map _ :s/^\s*-- \=//g<CR>j
" set nocindent comments=:--
" endfunction
function! SpiceComment()
map - 0i* <ESC>j
map _ :s/^\s*\* \=//g<CR>j
set comments=:*
endfunction
function! ConfigComment()
map - 0idnl <ESC>j
map _ :s/^\s*dnl \=//g<CR>j
set comments=:dnl
endfunction
function! VimComment()
map - 0i" <ESC>j
map _ :s/^\s*" \=//g<CR>j
set comments=:\"
endfunction
function! XDefaultsComment()
map - 0i! <ESC>j
map _ :s/^\s*! \=//g<CR>j
set comments=:\!
endfunction
function! PostscriptComment()
map - 0i%% <ESC>j
map _ :s/^\s*%%\= \=//g<CR>j
set comments=:\!
endfunction
function! FT_text()
call PoundComment()
set tw=72 formatoptions=tcq
endfunction
autocmd Filetype html call HTMLComment()
autocmd Filetype vhdl call VHDLComment()
autocmd Filetype c call CComment()
autocmd Filetype cs call CComment()
autocmd Filetype js call CComment()
autocmd Filetype synopsys call CComment()
autocmd Filetype tex call TexComment()
autocmd Filetype cpp call CPlusPlusComment()
autocmd Filetype java call CPlusPlusComment()
autocmd Filetype verilog call CPlusPlusComment()
autocmd Filetype xdefaults call XDefaultsComment()
autocmd Filetype config call ConfigComment()
autocmd Filetype vim call VimComment()
autocmd Filetype lisp call LispComment()
autocmd Filetype skill call LispComment()
autocmd Filetype dosini call LispComment()
autocmd Filetype spice call SpiceComment()
autocmd Filetype perl call PoundComment()
autocmd Filetype apache call PoundComment()
autocmd Filetype csh call PoundComment()
autocmd Filetype sh call PoundComment()
autocmd Filetype cdslib call PoundComment()
autocmd Filetype tcl call PoundComment()
autocmd Filetype xs call PoundComment()
autocmd Filetype make call PoundComment()
autocmd Filetype conf call PoundComment()
autocmd Filetype fvwm call PoundComment()
autocmd Filetype samba call PoundComment()
autocmd Filetype postscr call PostscriptComment()
autocmd Filetype text call FT_text()
" Use the colors by number from 0 to 15. I care about the cterm variables only.
" I set the colors that I want in the .Xdefaults file. The first 8 colors have
" been set to be the same as 8-color ANSI so that other apps (besides VIM!) can
" have those colors set correctly.
"
" xterm*color0: black 0 0 0
" xterm*color1: red 255 0 0
" xterm*color2: green 0 255 0
" xterm*color3: yellow 255 255 0
" xterm*color4: blue 0 0 255
" xterm*color5: magenta 255 0 255
" xterm*color6: cyan 0 255 255
" xterm*color7: white 255 255 255
" xterm*color8: burlywood1 255 211 155 (ffd39b)
" xterm*color9: sienna1 255 130 71 (ff8247)
" xterm*color10: PaleVioletRed1 255 130 171 (ff82a0)
" xterm*color11: LightSkyBlue 135 206 250 (87cefa)
" xterm*color12: white
" xterm*color13: white
" xterm*color14: white
" xterm*color15: white
" highlighting for the GUI mode
highlight Normal guifg=#e5e5e5 guibg=#000000
highlight Comment guifg=#ffd39b
highlight Keyword guifg=#ffffff gui=bold
highlight Statement guifg=#ffffff
highlight String guifg=#87cefa
highlight PreProc guifg=#ff8247
highlight Define guifg=#ff8247
highlight Include guifg=#ff8247
highlight Defined guifg=#ffff00
highlight Function guifg=#ffff00 gui=bold
highlight Type guifg=#ff82a0
highlight StorageClass guifg=#ff82a0
highlight MySearch guibg=#0000ff
highlight Constant guifg=#ffffff
highlight Special guifg=#87cefa
highlight Identifier guifg=#ffffff
if &term =~ "xterm" || &term =~ "vt220"
set t_Co=16
if has("terminfo")
set t_AB=[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
set t_AF=[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
else
set t_Sf=[3%dm
set t_Sb=[4%dm
endif
highlight Comment ctermfg=8
highlight SpecialComment ctermfg=8
highlight Constant ctermfg=12
highlight String ctermfg=11
highlight Character ctermfg=11
highlight Function ctermfg=3 cterm=bold
highlight Identifier ctermfg=12
highlight Statement ctermfg=7
highlight Conditional ctermfg=7
highlight Repeat ctermfg=7
highlight Label ctermfg=7
highlight Operator ctermfg=7
highlight Keyword ctermfg=13 cterm=bold
highlight Exception ctermfg=7
highlight PreProc ctermfg=9
highlight Include ctermfg=9
highlight Define ctermfg=9
highlight Macro ctermfg=9
highlight PreCondit ctermfg=9
highlight Defined ctermfg=3
highlight Type ctermfg=10
highlight StorageClass ctermfg=10
highlight Special ctermfg=11
highlight Error ctermfg=1 ctermbg=3
highlight MySearch ctermbg=4
else
" set the colors when not on a 16 color xterm. In this case,
" only the ANSI colors 0-7 are available.
set t_Co=8
if has("terminfo")
set t_Sf=[3%p1%dm
set t_Sb=[4%p1%dm
else
set t_Sf=[3%dm
set t_Sb=[4%dm
endif
" Comments below are values I changed
highlight Comment ctermfg=7 cterm=bold
highlight SpecialComment ctermfg=7 cterm=bold
highlight Constant ctermfg=4 cterm=bold
highlight String ctermfg=3 cterm=bold
highlight Character ctermfg=3 cterm=bold
highlight Function ctermfg=3
highlight Identifier ctermfg=3 cterm=bold
highlight Statement ctermfg=7
highlight Conditional ctermfg=7
highlight Repeat ctermfg=7
highlight Label ctermfg=7
highlight Operator ctermfg=7
highlight Keyword ctermfg=7 cterm=bold
highlight Exception ctermfg=7
highlight PreProc ctermfg=1 cterm=bold
highlight Include ctermfg=1 cterm=bold
highlight Define ctermfg=1 cterm=bold
highlight Macro ctermfg=1 cterm=bold
highlight PreCondit ctermfg=1 cterm=bold
highlight Defined ctermfg=3
highlight Type ctermfg=2 cterm=bold
highlight StorageClass ctermfg=2 cterm=bold
highlight Special ctermfg=3 cterm=bold
highlight Error ctermfg=1 ctermbg=3
highlight MySearch ctermbg=4
endif
set background=dark
syntax enable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment