Skip to content

Instantly share code, notes, and snippets.

@gotar
Created June 13, 2012 11:19
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 gotar/2923506 to your computer and use it in GitHub Desktop.
Save gotar/2923506 to your computer and use it in GitHub Desktop.
vim config
" General ********************************************************************
set nocompatible
set encoding=utf-8
set fileencodings=utf-8,latin2
" Autowrite current buffer on switch
set autowrite
" Tabs ************************************************************************
set softtabstop=2
set shiftwidth=2
set tabstop=2
set expandtab
set sta " a <Tab> in an indent inserts 'shiftwidth' spaces
" Indenting ********************************************************************
set ai " Automatically set the indent of a new line (local to buffer)
set si " smartindent (local to buffer)
" Scrollbars ******************************************************************
set sidescrolloff=2
set numberwidth=4
" Cursor highlights ***********************************************************
set cursorline
" Searching *******************************************************************
set hlsearch " highlight search
set incsearch " incremental search, search as you type
set ignorecase " Ignore case when searching
set smartcase " Ignore case when searching lowercase
" Colors **********************************************************************
set t_Co=256 " 256 colors
syntax on " syntax highlighting
set background=light
colorscheme solarized
" Status Line *****************************************************************
set showcmd
set ruler " Show ruler
set ch=2 " Make command line one lines high
" Line Wrapping ***************************************************************
set nowrap
set linebreak " Wrap at word
" Sets path to directory buffer was loaded from
autocmd BufEnter * lcd %:p:h
" File Stuff ******************************************************************
filetype plugin indent on
" Set the correct file type for some files
au BufRead,BufNewFile,BufFilePost *.nc set filetype=nesc
au BufRead,BufNewFile,BufFilePost *.plt set filetype=gnuplot
au BufRead,BufNewFile,BufFilePost sconstruct set filetype=python
au BufRead,BufNewFile,BufFilePost *.cls,*.tex set filetype=tex
au BufRead,BufNewFile,BufFilePost *.json,*.js set filetype=javascript
" Omni Completion *************************************************************
autocmd FileType html set filetype=xhtml " we couldn't care less about html
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete " may require ruby compiled in
"LaTex
set shellslash
set grepprg=grep\ -nH\ $*
let g:tex_flavor='latex'
" JSON formatted
map <leader>jt <Esc>:%!json_xs -f json -t json-pretty<CR>
" Misc ************************************************************************
set backspace=indent,eol,start
set number " Show line numbers
set matchpairs+=<:>
set vb t_vb= " Turn off the bell, this could be more annoying, but I'm not sure how
" Set list Chars - for showing characters that are not
" normally displayed i.e. whitespace, tabs, EOL
set list!
set listchars=tab:▸\ ,eol:¬
" Cursor Movement *************************************************************
" Make cursor move by visual lines instead of file lines (when wrapping)
map <up> gk
map k gk
imap <up> <C-o>gk
map <down> gj
map j gj
imap <down> <C-o>gj
map E ge
" Window movment
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
if has("gui_running")
set guifont=Monaco\ 9
endif
" Source the vimrc file after saving it
if has("autocmd")
autocmd bufwritepost .vimrc source $MYVIMRC
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment