Skip to content

Instantly share code, notes, and snippets.

@rquigley
Created July 10, 2013 19:59
Show Gist options
  • Save rquigley/5969711 to your computer and use it in GitHub Desktop.
Save rquigley/5969711 to your computer and use it in GitHub Desktop.
set nocompatible
set number
set ruler
syntax on
" Set encoding
set encoding=utf-8 nobomb
set showmode
set visualbell
"set cursorline
set ttyfast
set timeout timeoutlen=1000 ttimeoutlen=50
"set clipboard=unnamed " copies y, yy, d, D, dd and other to the
" system clipboard
" ----------------------------------------------------------------------------
" moving around, searching and patterns
" ----------------------------------------------------------------------------
set nostartofline " keep cursor in same column for long-range motion cmds
set incsearch " Highlight pattern matches as you type
set ignorecase " ignore case when using a search pattern
set smartcase " override 'ignorecase' when pattern
" has upper case character
" ----------------------------------------------------------------------------
" displaying text
" ----------------------------------------------------------------------------
set scrolloff=3 " number of screen lines to show around
" the cursor
set linebreak " For lines longer than the window,
" wrap intelligently. This doesn't
" insert hard line breaks.
"set showbreak=↪\ \ " string to put before wrapped screen
" lines
set sidescrolloff=2 " min # of columns to keep left/right of cursor
set display+=lastline " show last line, even if it doesn't fit in the window
set cmdheight=2 " # of lines for the command window
" cmdheight=2 helps avoid 'Press ENTER...'
" prompts
" ----------------------------------------------------------------------------
" multiple windows
" ----------------------------------------------------------------------------
set switchbuf=usetab " Jump to the 1st open window which contains
" specified buffer, even if the buffer is in
" another tab.
" TODO: Add 'split' if you want to split the
" current window for a quickfix error window.
" Don’t show the intro message when starting vim
set shortmess=atI
" allow cursorkeys in insert mode
set esckeys
"let mapleader = ","
set pastetoggle=<f5>
" sticky fingers
:command WQ wq
:command Wq wq
:command W w
:command Q q
" Whitespace stuff
"set nowrap
"set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
set list listchars=tab:\ \ ,trail:·
" ----------------------------------------------------------------------------
" reading and writing files
" ----------------------------------------------------------------------------
set autoread " Automatically re-read files changed outside of Vim
" Show trailing whitespace
"set listchars=tab:>-,trail:·,eol:$
nmap <silent> <leader>s :set nolist!<CR>
"Strip all trailing whitespace
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
"set list listchars=tab:>.,trail:.,extends:#,nbsp:.
"autocmd filetype html,xml set listchars-=tab:>.
" Remove any trailing whitespace that is in the file
" autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif
" Don’t reset cursor to start of line when moving around.
set nostartofline
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
set autoindent
" 'smartindent' and 'cindent' might interfere with file type based
" indentation, and should never be used in conjunction with it.
"set smartindent
set copyindent
" Set line at 80th column
"set colorcolumn=80
"highlight ColorColumn ctermbg=darkgrey guibg=darkgrey
colorscheme ir_black
"colorscheme solarized
" Folding Stuffs
"set foldmethod=marker
" Disable folding
set nofoldenable
call pathogen#infect()
"hide buffers instead of closing them
"set hidden
set title
set t_Co=256
"Mouse
set selectmode=mouse
set mouse=a
"map <xCSI>[62~ <MouseDown>
" File-type highlighting and configuration.
" Run :filetype (without args) to see what you may have
" to turn on yourself, or just set them all to be sure.
syntax on
filetype on
filetype plugin on
filetype indent on
set ofu=syntaxcomplete#Complete
"au BufNewFile,BufRead *.j2 set filetype=jinja
au BufNewFile,BufRead *.j2 set filetype=html
au BufNewFile,BufRead *.less set filetype=css
au BufNewFile,BufRead *.sass set filetype=css
"Use w!! to sudo write
cmap w!! w !sudo tee % >/dev/null
" Inserts the path of the currently edited file into a command
" Command mode: Ctrl+P
"cmap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
"nnoremap j gj
"nnoremap k gk
" Intuitive backspacing in insert mode
set backspace=indent,eol,start
"textmate style rewrap
"nnoremap <leader>q gqip
"try mapping jj to esc
"inoremap jj <ESC>
"new split
"nnoremap <leader>w <C-w>v<C-w>l
"map window movements
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nmap <tab> v>
nmap <s-tab> v<
vmap <tab> >gv
vmap <s-tab> <gv
cmap <c-a> <home>
cmap <c-e> <end>
" Always show status line, even for one window
set laststatus=2
set showmatch
" Jump to matching bracket for 2/10th of a second (works with showmatch)
set matchtime=2
" start/end tag matching
runtime macros/matchit.vim
" Don't highlight results of a search
set nohlsearch
"set hlsearch
" ...dynamically as they are typed.
set incsearch
set ignorecase
set smartcase
" Scroll when cursor gets within 3 characters of top/bottom edge
set scrolloff=3
" Show (partial) commands (or size of selection in Visual mode) in the status line
set showcmd
" Remember things between sessions
" ----------------------------------------------------------------------------
" command line editing
" ----------------------------------------------------------------------------
set history=200 " Save more commands in history
" See Practical Vim, by Drew Neil, pg 68
" '20 - remember marks for 20 previous files
" \"50 - save 50 lines for each register
" :20 - remember 20 items in command-line history
" % - remember the buffer list (if vim started without a file arg)
" n - set name of viminfo file
set viminfo='20,\"50,:20,%,n~/.viminfo
" Use menu to show command-line completion (in 'full' case)
set wildmenu
" Set command-line completion mode:
" - on first <Tab>, when more than one match, list all matches and complete
" the longest common string
" - on second <Tab>, complete the next full match and show menu
set wildmode=list:longest,full
set wildignore=*.swp,*.bak,*.pyc,*.class,.svn,.git
" Fix my <Backspace> key (in Mac OS X Terminal)
"set t_kb=
fixdel
let g:ctrlp_map = '<c-t>'
let g:ctrlp_cmd = 'CtrlP'
"let g:ctrlp_custom_ignore = '\v\~$|\.(o|swp|pyc|wav|mp3|ogg|blend)$|(^|[/\\])\.(hg|git|bzr)($|[/\\])|__init__\.py'
"let g:ctrlp_working_path_mode = 0
let g:ctrlp_dotfiles = 0
"let g:ctrlp_switch_buffer = 0
let g:ctrlp_match_window_reversed = 0
let g:ctrlp_match_window_bottom = 0
" Generic highlight changes
highlight Comment cterm=none ctermfg=Gray
highlight IncSearch cterm=none ctermfg=Black ctermbg=DarkYellow
highlight Search cterm=none ctermfg=Black ctermbg=DarkYellow
highlight String cterm=none ctermfg=DarkGreen
highlight treeDir cterm=none ctermfg=Cyan
highlight treeUp cterm=none ctermfg=DarkYellow
highlight treeCWD cterm=none ctermfg=DarkYellow
highlight netrwDir cterm=none ctermfg=Cyan
set statusline=
set statusline+=%-3.3n\ " buffer number
set statusline+=%f\ " filename
set statusline+=%h%m%r%w " status flags
"set statusline+=%= " right align remainder
"set statusline+=0x%-8B " character value
"set statusline+=%-14(%l,%c%V%) " line, character
"set statusline+=%<%P " file position
set statusline+=%= " right align
set statusline+=%r " are you read only?
"set statusline+=\ \ \ \ %y " what the file type
set statusline+=[ "
set statusline+=\ Line: "
set statusline+=%3l/ " Line number with padding
set statusline+=%L " Total lines in the file
set statusline+=:%2c " column number
set statusline+=]
set helpheight=30 " Set window height when opening Vim help windows
set formatoptions+=j " delete comment char on second line when
" joining two commented lines
set completeopt+=longest " better omni-complete menu
set nrformats-=octal " don't treat numbers with leading zeros as octal
" when incrementing/decrementing
" CTags
map <Leader>rt :!ctags --extra=+f -R *<CR><CR>
map <C-\> :tnext<CR>
" Remember last location in file
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
" Go back to the position the cursor was on the last time this file was edited
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")|execute("normal `\"")|endif
" Thorfile, Rakefile, Vagrantfile and Gemfile are Ruby
au BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,config.ru} set ft=ruby
" add json syntax highlighting
au BufNewFile,BufRead *.json set ft=javascript
autocmd FileType python set ft=python.django " For SnipMate
autocmd FileType html set ft=htmldjango.html " For SnipMate
" load the plugin and indent settings for the detected filetype
filetype plugin indent on
" Opens an edit command with the path of the currently edited file filled in
" Normal mode: <Leader>e
map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
" Enable syntastic syntax checking
"let g:syntastic_enable_signs=1
"let g:syntastic_quiet_warnings=1
" Directories for swp files
set undodir=~/.vim/tmp/undo " undo files
set backupdir=~/.vim/tmp/backup " backups
set directory=~/.vim/tmp/swap " swap files
set backup " enable backups
" Highlight VCS conflict markers
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
" Turn off jslint errors by default
let g:JSLintHighlightErrorLine = 0
"Disable pylint checking every save
let g:pymode_lint_write = 0
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
if !exists("*TimeStamp")
fun TimeStamp()
return "--RQ (" . strftime("%d %b %Y %X") . ")"
endfun
endif
iab RQ <C-R>=TimeStamp()<cr>
"autocmd vimenter * if !argc() | NERDTree | endif
map <C-n> :NERDTreeToggle<CR>
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment