Skip to content

Instantly share code, notes, and snippets.

@Reder
Last active June 8, 2017 18:47
Show Gist options
  • Save Reder/1977757 to your computer and use it in GitHub Desktop.
Save Reder/1977757 to your computer and use it in GitHub Desktop.
.vimrc
" Reder's vimrc
" Reder Tseng <reder.tseng@gmail.com>
" Ref:
" 1. <https://github.com/vgod/vimrc>
" 2. <https://github.com/gmarik/vimfiles>
"
" Usage:
" 1. Download .vimrc
" 2. Setup vundle:
" git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
" 3. Open Vim. Run `:PluginInstall`
" VundleVim: https://github.com/VundleVim/Vundle.vim
set nocompatible " be iMproved, required
filetype off " required for Vundle
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'ervandew/supertab'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'majutsushi/tagbar'
" For Clojure
Plugin 'guns/vim-clojure-static'
Plugin 'tpope/vim-fireplace'
Plugin 'guns/vim-clojure-highlight'
" Plugin 'tpope/vim-surround'
" Plugin 'paredit.vim'
" Plugin 'bhurlow/vim-parinfer'
" Other languages / formats
Plugin 'javacomplete'
Plugin 'Reder/groovy.vim'
Plugin 'tpope/vim-rails'
Plugin 'vim-ruby/vim-ruby'
Plugin 'jngeist/vim-multimarkdown'
Plugin 'Reder/xmledit'
Plugin 'csv.vim'
Plugin 'pangloss/vim-javascript'
" colorscheme
Plugin 'altercation/vim-colors-solarized'
Plugin 'dracula/vim'
Plugin 'w0ng/vim-hybrid'
call vundle#end() " required
" filetype settings (should be after Bundle settings)
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
syntax on " syntax highlight
colorscheme dracula
" disable sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Encoding Settings
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,big5,latin1
set bs=2 " allow backspacing over everything in insert mode
set backspace=2 " make backspace work like most other apps
set autoread " auto read when file is changed from outside
set history=100 " keep 100 lines of command line history
set ruler " show the cursor position all the time
set number " display line numbers
set cursorline " underline current cursor
" Command Settings
set showcmd
set showmatch " Cursor shows matching ) and }
set showmode " Show current mode
set wildchar=<TAB> " start wild expansion in the command line using <TAB>
set wildmenu " wild char completion menu
" TAB Settings
set expandtab " replace <TAB> with spaces
set autoindent " auto indentation
set copyindent " copy the previous indentation on autoindenting
set smarttab " insert tabs on the start of a line according to context
set shiftwidth=4 " use indents of 4 spaces
set softtabstop=4 " let backspace delete indent
set tabstop=4 " an indentation every four columns
" Search Settings
set hlsearch " search highlighting
set ignorecase " search with case insensitive
set smartcase " ignore case if search pattern is all lowercase,case-sensitive otherwise
set incsearch
" Formatting
set fo+=on " Automatically insert the current comment letter after hitting 'o' or 'O' in normal mode.
set fo-=r " Do not automatically insert a comment after an enter
" Files Settings
set nobackup " no *~ backup files
set nowritebackup
set noswapfile
set viewoptions=folds,options,cursor,unix,slash " better unix / windows compatibility
set clipboard=unnamed " yank to the system register (*) by default
" auto reload vimrc when editing it
autocmd! bufwritepost .vimrc source ~/.vimrc
"remove unwanted whitespace
autocmd BufWritePre * :%s/\s\+$//e
" gvim
if has("gui_running")
colorscheme solarized
set background=dark
set lines=60 columns=200
set guifont=Monospace\ 12,Menlo:h14
set t_Co=256 " 256 color mode
set mouse =a
set mousehide
set guioptions= " remove scrollbars
:nnoremap <leader>m :silent !open -a Marked.app '%:p'<cr>
endif
" set indent for differnt file types
autocmd FileType ruby setlocal shiftwidth=2 tabstop=2
" Enable omni completion. (Ctrl-X Ctrl-O)
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType java set omnifunc=javacomplete#Complete
" use syntax complete if nothing else available
if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif
" Automatically change the current directory
autocmd BufEnter * silent! lcd %:p:h
" NERDTree
autocmd StdinReadPre * let s:std_in=1 " for below
" open a NERDTree automatically when vim starts up if no files were specified
" and focus the editor window
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | wincmd p | endif
" open NERDTree automatically when vim starts up on opening a directory
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
" close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" SuperTab
let g:SuperTabDefaultCompletionType = "context"
let g:SuperTabNoCompleteAfter = ['^', ',', '\s'] "no completion at the start of a line, after a comma, or after a space
" vim-clojure-highlight
" Evaluate Clojure buffers on load
autocmd BufRead *.clj try | silent! Require | catch /^Fireplace/ | endtry
"ctrlp.vim
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ca'
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
let g:tagbar_width = 60
let g:tagbar_show_linenumbers = 1
" Auto open TagBar with supported files
autocmd VimEnter * nested :call tagbar#autoopen(1)
" Auto open TagBar with supported files in a running Vim
autocmd FileType * nested :call tagbar#autoopen(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment