Skip to content

Instantly share code, notes, and snippets.

@HerringtonDarkholme
Created September 25, 2013 14:37
Show Gist options
  • Save HerringtonDarkholme/6700567 to your computer and use it in GitHub Desktop.
Save HerringtonDarkholme/6700567 to your computer and use it in GitHub Desktop.
""""""""""""""""""""""""""""""""""""""""""""""""
" => configuration
""""""""""""""""""""""""""""""""""""""""""""""""
set encoding=utf-8
set hidden
set foldlevel=99
set foldmethod=indent
let tabsize=4
""""""""""""""""""""""""""""""""""""""""""""""""
" => highlight help
""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable
set number
set title
"turn on wild menu
set cursorline
set wildmenu
set wildignore=*.o,*.pyc
"highlight search result"
set hlsearch
"instant search(help re?)"
set incsearch
"egrep for PCRE"
nnoremap <leader>/ :call eregex#toggle()<CR>
let g:eregex_default_enable = 0
"Vim-airline"
"keep statusline fixed
set laststatus=2
"skip mode info in cmd
set noshowmode
"quick leave insert mode
if ! has('gui_running')
set ttimeoutlen=10
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
augroup END
endif
" GUIsh insert cursor"
au InsertEnter * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape ibeam"
au InsertLeave * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape block"
""""""""""""""""""""""""""""""""""""""""""""""""
" => plugin
""""""""""""""""""""""""""""""""""""""""""""""""
filetype plugin indent on
execute pathogen#infect()
set omnifunc=syntaxcomplete#Complete
""""""""""""""""""""""""""""""""""""""""""""""""
" => auto complete and snippet for DarkVimMaster
""""""""""""""""""""""""""""""""""""""""""""""""
"NeoComplCache will produce annoying syntax file for once
"remove pesky keyword manually"
let g:neocomplcache_enable_at_startup=1
let g:neocomplcache_enable_smart_case=1
let g:neocomplcache_auto_completion_start_length=1
let g:neocomplcache_enable_auto_select=1
"cursor move for insert mode"
let g:neocomplcache_enable_insert_char_pre=1
"let g:neocomplcache_enable_cursor_hold_i = 1
"make compl list reasonably long. George Miller: huh?"
let g:neocomplcache_max_list=7
"don't auto close preview. makes it no ostentatious"
let g:neocomplcache_enable_auto_close_preview=0
set splitbelow
set previewheight=2
set completeopt-=preview
"Disable faux syntax element"
"if !exists('g:neocomplcache_keyword_patterns')
"let g:neocomplcache_keyword_patterns = {}
"endif
"let g:neocomplcache_keyword_patterns.javascript = '\<\(javaScript\)\@!\w*'
"let g:neocomplcache_keyword_patterns.coffee = '\<\(coffee)\@!\w*'
" Enable omni completion."
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
"autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" <CR>: close popup and save indent.
ino <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
"use silent mode to avoid bizzare char insertion"
function! s:my_cr_function()
return pumvisible() ? neocomplcache#close_popup() : "\<CR>"
endfunction
" Plugin key-mappings.
inoremap <expr><C-g> neocomplcache#undo_completion()
inoremap <expr><C-l> neocomplcache#complete_common_string()
" Close popup by <Space>.
inoremap <expr><Space> pumvisible() ? neocomplcache#smart_close_popup() : "\<Space>"
""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, Tab and Indent Related
""""""""""""""""""""""""""""""""""""""""""""""""
"Replace tabs with spaces"
set expandtab
"Make tabs 4 spaces"
exe "set tabstop=".tabsize
exe "set shiftwidth=".tabsize
exe "set softtabstop=".tabsize
autocmd FileType jade setlocal shiftwidth=2 tabstop=2 softtabstop=2
"auto indent"
set autoindent
set smartindent
"Remove trailing whitespaces
autocmd BufWritePre * :%s/\s\+$//e
" indent line"
let g:indentLine_color_term=238
let g:indentLine_noConcealCursor = 1
""""""""""""""""""""""""""""""""""""""""""""""""
" => Files and Backup
"""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
" Reload files modified outside of Vim"
set autoread
""""""""""""""""""""""""""""""""""""""""""""""""
" => color!!
""""""""""""""""""""""""""""""""""""""""""""""""
"Allow 256 colors in Terminal
set t_Co=16
set t_ZH=
"Set colorscheme
colorscheme monoterm
"lint"
let g:syntastic_auto_loc_list=1
let g:syntastic_check_on_open=1
let g:syntastic_always_populate_loc_list=1
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='!!'
let g:toggle_list_no_mappings=1
""""""""""""""""""""""""""""""""""""""""""""""""
" => key binding
""""""""""""""""""""""""""""""""""""""""""""""""
" => jsbeautify
autocmd FileType javascript nn <buffer> <leader>f :call JsBeautify()<cr>
" for html
autocmd FileType html nn <buffer> <leader>f :call HtmlBeautify()<cr>
" for css or scss
autocmd FileType css nn <buffer> <leader>f :call CSSBeautify()<cr>
""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving Around!!
""""""""""""""""""""""""""""""""""""""""""""""""
"move between windows
nn <C-j> <C-W>j
nn <C-k> <C-W>k
nn <C-h> <C-W>h
nn <C-l> <C-W>l
"make j,k moves between visual line, and gj,gk moves between real lines
no j gj
no k gk
no gj j
no gk k
""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing Mappings!!
""""""""""""""""""""""""""""""""""""""""""""""""
"Move a line with jkhl and alt, kick ass ST"
"http://vim.wikia.com/wiki/Moving_lines_up_or_down"
nn <A-j> :m .+1<CR>==
nn <A-k> :m .-2<CR>==
vn <A-j> :m '>+1<CR>gv=gv
vn <A-k> :m '<-2<CR>gv=gv
nn <A-h> <lt><lt>
nn <A-l> >>
"vn <A-h> <lt>gv4h
exe "vn <A-h> <lt>gv".tabsize."h"
"vn <A-l> >gv4l
exe "vn <A-l> >gv".tabsize."l"
set <A-j>=j
set <A-k>=k
set <A-h>=h
set <A-l>=l
set <A-f>=f
set <A-b>=b
" => File Browswing
nn <leader>b :NERDTreeToggle<CR>
" => Syntastic Lint
nnoremap <silent><F2> :call ToggleLocationList()<CR>
" => TernJs shortcut
autocmd FileType javascript nn <buffer> <leader>. :TernDef<cr>
autocmd FileType javascript nn <buffer> <leader>r :TernRefs<cr>
autocmd FileType javascript nn <buffer> <leader>t :TernType<cr>
autocmd FileType javascript nn <buffer> <leader>q :TernRename<cr>
nn <silent> <leader>u :GundoToggle<CR>
nn <silent> <F12> :YRShow<CR>
nn <silent> <F4> :set nohls<CR>
nn <silent> <F8> :TagbarToggle<CR>
nn <silent> <leader>g :Grep<CR>
nn <leader>s :VimShellPop<CR>
let g:vimshell_prompt_expr =
\ 'escape(fnamemodify(getcwd(), ":~").">", "\\[]()?! ")." "'
let g:vimshell_prompt_pattern = '^\%(\f\|\\.\)\+> '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment