Skip to content

Instantly share code, notes, and snippets.

@diogeneshamilton
Last active December 19, 2015 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diogeneshamilton/5936800 to your computer and use it in GitHub Desktop.
Save diogeneshamilton/5936800 to your computer and use it in GitHub Desktop.
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" this is all indentation stuff. hm. thanks nathan!
set smarttab " smart tab interpretation
set expandtab " expand tabs to spaces
set softtabstop=4 " 4-space tabs
set shiftwidth=4 " 4-space (auto) indent
set smartindent " smart indentation
set cindent " smart C indentation
set incsearch " incremental search (show while typing)
set listchars=eol:$,tab:>- " for non-printable characters
set bs=2 " allow backspacing over everything in insert mode
set ai " always set autoindenting on
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set vb t_vb= " blink, don't beep.
" settings for vim
" Vitaliy's .vimrc below:
" ================================
" Display Settings
" ================================
" Show (partial) command in the last line of the screen
set showcmd
" turn on syntax highlighting
syntax on
" print line numbers in front of each line
set number
" Don't keep backup, but keep backup while file is being written
set nobackup
set writebackup
" Stop the annoying beep
set visualbell t_vb=
" Always show status line
set laststatus=2
" always leave 4 lines above and below screen top/bottom
set scrolloff=4
" Assume dark background (putty window)
set background=dark
" Load filetype specific plugins
filetype plugin indent on
" For pydiction, this is the location of the dictionary file
let g:pydiction_location = '/Users/peyton/Sources/pydiction-1.2/complete-dict'
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
" set nohlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" In text files, always limit the width of text to 78 characters
" autocmd BufRead *.txt set tw=78
" Set tab width to 4 characters for Perl programs.
autocmd FileType *.pl set ts=4
" Set up autocomplete for python
autocmd FileType python set omnifunc=pythoncomplete#Complete
" may need this at some point if we ever use edit_headers in mutt.
" autocmd BufNewFile,BufRead mutt* :normal 1G}j
autocmd BufNewFile,BufRead ~/.tmp/mutt* set ai fo=tcq2 et nosi tw=72 syntax=mail
augroup cprog
" Remove all cprog autocommands
au!
" When starting to edit a file:
" For C and C++ files set formatting of comments and set C-indenting on.
" For other files switch it off.
" Don't change the order, it's important that the line with * comes first.
autocmd FileType * set formatoptions=tcql nocindent comments&
autocmd FileType c,cpp set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
augroup END
" This is disabled, because it changes the jumplist. Can't use CTRL-O to go
" back to positions in previous files more than once.
if 0
" When editing a file, always jump to the last cursor position.
" This must be after the uncompress commands.
autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif
endif
endif " has("autocmd")
set laststatus=2
set showcmd
set showmatch
set showmode
set nostartofline
" set statusline=#%n\ %m\ %F\ %=%l/%L\ \(%p%%\)
if (has("win32"))
colorscheme darkblue
else
set statusline=%1*%m\ %F%(\ [#%n%Y%R]%)%=%l/%L
colorscheme darkblue
endif
hi User1 term=inverse,bold cterm=bold ctermbg=blue ctermfg=white
" set list listchars=tab:»·,trail:·
" if (&t_Co > 2 || has("gui_running")) && !$SSH_CLIENT
" set list
" endif
hi nontext ctermfg=darkgray
" ================================
" Indentation Settings
" ================================
" Copy indent from current line when starting a new line
set autoindent
" Indent/unindent after open/close braces
set smartindent
set tabstop=8
" Set tab to be 4 spaces
set shiftwidth=4
" Number of spaces that tab counts, backspace over tabs works as expected
set softtabstop=4
" Use spaces instead of tabs
set expandtab
" Round indent to multiple of 'shiftwidth'
set shiftround
" Show tabs correctly when doing 'set list'
set listchars=tab:>-,eol:$ " for non-printable characters
" Shortcut to toggle display of Tags/EOLs
map <F7> :set list!<CR>
" Don't indent to the left when pressing the # key
" set indentkeys=!^F,o,O,<:>,0),0],0},=elif,=except,0#
" toggle insert in paste mode
set pastetoggle=<F6>
" Always use tab character for Makefiles and fssync configuration files
autocmd FileType make set noet ts=8
autocmd BufRead /proj/fssync/etc/* set noet ts=8 sw=8 sts=8
" ================================
" Typing
" ================================
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" When a bracket is inserted, briefly jump to matching one
set showmatch
" show match very briefly (tenths of sec)
set matchtime=1
" expand syntax search area
syn sync maxlines=4000
syn sync minlines=2000
" ================================
" Searching
" ================================
" case-insensitive search by default
set ignorecase
" unless at least 1 letter is capitalized
set smartcase
" highligh search results by default
set hlsearch
" highlight search as you type
set incsearch
" \\ turns off highlighting
map <silent> \ :let @/=""<cr>
" Suppress all spaces at end/beginning of lines
nmap _s :%s/\s\+$//<CR>
nmap _S :%s/^\s\+//<CR>
" configure syntax highlighting to work with GUI or xterm
if ! has("gui_running")
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
endif
" highlight long lines
nnoremap <Leader>H :call<SID>LongLineHLToggle()<cr>
hi OverLength ctermbg=none cterm=none
match OverLength /\%>80v/
fun! s:LongLineHLToggle()
if !exists('w:longlinehl')
let w:longlinehl = matchadd('ErrorMsg', '.\%>80v', 0)
echo "Long lines highlighted"
else
call matchdelete(w:longlinehl)
unl w:longlinehl
echo "Long lines unhighlighted"
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment