Skip to content

Instantly share code, notes, and snippets.

@netsmertia
Last active August 29, 2015 14:02
Show Gist options
  • Save netsmertia/ffb2692b8a08c7961c5f to your computer and use it in GitHub Desktop.
Save netsmertia/ffb2692b8a08c7961c5f to your computer and use it in GitHub Desktop.
My .vimrc
"GENERAL
"==============================================
set background=dark " Assume a dark background
syntax on " Syntax highlighting
filetype plugin indent on " Automatically detect file types.
if !has('gui')
set term=$TERM " Make arrow and other keys work
endif
set hidden " Allow buffer switching without saving
set history=1000 " Store a ton of history (default is 20)
set virtualedit=onemore " Allow for cursor beyond last character
set mousehide " Hide the mouse cursor while typing
set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
"VIM UI
"==============================================
set guioptions-=T "disable toolbar in gvim
set guioptions-=rL "disable scrollbar in gvim
set tabpagemax=15 " Only show 15 tabs
set showmode " Display the current mode
set cursorline " Highlight current line
set ruler " Show the ruler
set showcmd " Show partial commands in status line and
" Selected characters/lines in visual mode
set ttyfast
if has('statusline')
set laststatus=2
" Broken down into easily includeable segments
set statusline=%<%f\ " Filename
set statusline+=%w%h%m%r " Options
"set statusline+=%{fugitive#statusline()} " Git Hotness
set statusline+=\ [%{&ff}/%Y] " Filetype
set statusline+=\ [%{getcwd()}] " Current dir
set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
endif
set number " Line numbers on
set incsearch " Find as you type search
set ignorecase " Case insensitive search
set smartcase " Case sensitive when uc present
set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
set wildmode=list:longest,full " Command <Tab> completion, list matches, " then longest common part, then all.
set scrolloff=3 " Minimum lines to keep above and below cursor
set pumheight=9 " Set popup menu height
set list
set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
set splitright " Puts new vsplit windows to the right of the current
set splitbelow " Puts new split windows to the bottom of the current
"FORMATTING
"==============================================
set nowrap " Wrap long lines
set autoindent " Indent at the same level of the previous line
set shiftwidth=4 " Use indents of 4 spaces
set shiftround
set expandtab " Tabs are spaces, not tabs
set tabstop=4 " An indentation every four columns
set softtabstop=4 " Let backspace delete indent
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set smarttab
set matchpairs+=<:> " Match, to be used with %
"KEY REMAPPING
"==============================================
" Set leader key to ',' for easy access
let mapleader = ","
" Wrapped lines goes down/up to next row, rather than next line in file.
noremap j gj
noremap k gk
" Fast tab switching
map <S-H> gT
map <S-L> gt
" Yank from the cursor to the end of the line, to be consistent with C and D.
nnoremap Y y$
" Toggle search highlighting rather than clear the current
nmap <silent> <leader>/ :set invhlsearch<CR>
" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
" Allow using the repeat operator with a visual selection (!)
vnoremap . :normal .<CR>
"BUNDLES
"==============================================
"Vundle startup
"==============================================
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
"All bundles
"==============================================
"General
"-------------------------------------
Bundle 'scrooloose/nerdtree'
Bundle 'thinca/vim-fontzoom'
" Change font size with <s-+>, reset :Fontzoom!
Bundle 'bling/vim-airline'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'Shougo/unite.vim'
Bundle 'Shougo/unite-outline'
Bundle 'Shougo/vimproc.vim'
Bundle 'myusuf3/numbers.vim'
Bundle 'tsaleh/vim-matchit'
Bundle 'Lokaltog/vim-easymotion'
" Easy buffer management
Bundle 'Soares/butane.vim'
"General programming
"-------------------------------------
Bundle 'scrooloose/syntastic'
Bundle 'scrooloose/nerdcommenter'
Bundle 'tpope/vim-surround'
"snippets and autocomplete
"-------------------------------------
Bundle 'Valloric/YouCompleteMe'
"Bundle 'SirVer/ultisnips'
"Bundle 'Shougo/neocomplete.vim'
"Bundle 'Shougo/neosnippet'
"Bundl 'netsmertia/ultisnips-neocomplete'
"Bundle 'asmod3us/neocomplete-ultisnips'
"PHP
"-------------------------------------
Bundle 'shawncplus/phpcomplete.vim'
Bundle 'StanAngeloff/php.vim'
Bundle 'arnaud-lb/vim-php-namespace'
"Bundle 'spf13/PIV'
"Bundle 'vim-scripts/PHP-correct-Indenting'
Bundle 'vim-scripts/php.vim-html-enhanced'
"JS
"-------------------------------------
Bundle 'pangloss/vim-javascript'
Bundle 'elzr/vim-json'
"HTML & CSS
"-------------------------------------
Bundle 'othree/html5.vim'
Bundle 'hail2u/vim-css3-syntax'
Bundle 'wavded/vim-stylus'
Bundle 'jade.vim'
Bundle 'amirh/HTML-AutoCloseTag'
Bundle 'tpope/vim-haml'
Bundle 'mattn/emmet-vim'
"Bundle 'tristen/vim-sparkup'
"SETTINGS
"==============================================
"Plugins settings
"-------------------------------------
"NerdTree {
nmap <leader>n :NERDTreeToggle<CR>:NERDTreeMirror<CR>
map <leader>e :NERDTreeFind<CR>
let NERDTreeShowBookmarks=1
let NERDTreeIgnore=['\.pyc', '\~$', '\.swo$', '\.swp$', '\.git', '\.hg', '\.svn', '\.bzr']
let NERDTreeChDirMode=0
let NERDTreeQuitOnOpen=0
let NERDTreeMouseMode=1
let NERDTreeShowHidden=0
let NERDTreeKeepTreeInNewTab=1
let g:nerdtree_tabs_open_on_gui_startup=0
"}
"vim-airline {
" Set configuration options for the statusline plugin vim-airline.
" Use the powerline theme and optionally enable powerline symbols.
" To use the symbols , , , , , , and .in the statusline
" segments add the following to your .vimrc.before.local file:
" let g:airline_powerline_fonts=1
" If the previous symbols do not render for you then install a
" powerline enabled font.
let g:airline_theme ='bubblegum'
"dark
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_powerline_fonts=0
let g:airline_section_b = '%{strpart(getcwd(),stridx(getcwd(),"/",strlen(getcwd())-12))}'
let g:airline_symbols.space = "\ua0"
"old vim-powerline symbols
let g:airline_left_sep = '⮀'
let g:airline_left_alt_sep = '⮁'
let g:airline_right_sep = '⮂'
let g:airline_right_alt_sep = '⮃'
let g:airline_symbols.branch = '⭠'
let g:airline_symbols.readonly = '⭤'
let g:airline_symbols.linenr = '⭡'
"}
"jade.vim {
autocmd BufNewFile,BufRead *.jade set filetype=jade
"}
"Unite {
let g:unite_source_history_yank_enable = 1
nnoremap <leader>t :<C-u>Unite -no-split -buffer-name=files -start-insert file_rec/async<cr>
"call unite#filters#matcher_default#use(['matcher_fuzzy'])
nnoremap <leader>f :<C-u>Unite -no-split -buffer-name=files -start-insert file<cr>
nnoremap <leader>r :<C-u>Unite -no-split -buffer-name=mru -start-insert file_mru<cr>
nnoremap <leader>o :<C-u>Unite -no-split -buffer-name=outline -start-insert outline<cr>
nnoremap <leader>y :<C-u>Unite -no-split -buffer-name=yank history/yank<cr>
nnoremap <leader>e :<C-u>Unite -no-split -buffer-name=buffer buffer<cr>
" Custom mappings for the unite buffer
autocmd FileType unite call s:unite_settings()
function! s:unite_settings()
" Play nice with supertab
let b:SuperTabDisabled=1
" Enable navigation with control-j and control-k in insert mode
imap <buffer> <C-j> <Plug>(unite_select_next_line)
imap <buffer> <C-k> <Plug>(unite_select_previous_line)
endfunction
"}
"butane {
noremap <leader>bd :Bclose<CR> " Close the buffer.
noremap <leader>bl :ls<CR> " List buffers.
noremap <leader>bn :bn<CR> " Next buffer.
noremap <leader>bp :bp<CR> " Previous buffer.
noremap <leader>bt :b#<CR> " Toggle to most recently used buffer.
noremap <leader>bx :Bclose!<CR> " Close the buffer & discard changes.
"}
""UltiSnips {
"autocmd filetype css,stylus,sass,scss UltiSnipsAddFiletype scss.sass.css stylus.css
"autocmd filetype php UltiSnipsAddFiletype php
"function! g:UltiSnips_Complete()
" call UltiSnips_ExpandSnippet()
" if g:ulti_expand_res == 0
" if pumvisible()
" return "\<C-n>"
" else
" call UltiSnips_JumpForwards()
" if g:ulti_jump_forwards_res == 0
" return "\<TAB>"
" endif
" endif
" endif
" return ""
"endfunction
"au BufEnter,BufRead * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
"let g:UltiSnipsJumpForwardTrigger="<tab>"
"let g:UltiSnipsListSnippets="<c-e>"
""}
"Custom settings and commands
"-------------------------------------
"SuperIndent {
" Return indent (all whitespace at start of a line), converted from
" tabs to spaces if what = 1, or from spaces to tabs otherwise.
" When converting to tabs, result has no redundant spaces.
function! Indenting(indent, what, cols)
let spccol = repeat(' ', a:cols)
let result = substitute(a:indent, spccol, '\t', 'g')
let result = substitute(result, ' \+\ze\t', '', 'g')
if a:what == 1
let result = substitute(result, '\t', spccol, 'g')
endif
return result
endfunction
" Convert whitespace used for indenting (before first non-whitespace).
" what = 0 (convert spaces to tabs), or 1 (convert tabs to spaces).
" cols = string with number of columns per tab, or empty to use 'tabstop'.
" The cursor position is restored, but the cursor will be in a different
" column when the number of characters in the indent of the line is changed.
function! IndentConvert(line1, line2, what, cols)
if &readonly || ! &modifiable
return
endif
let savepos = getpos('.')
let cols = &tabstop
execute a:line1 . ',' . a:line2 . 's/^\s\+/\=Indenting(submatch(0), a:what, cols)/e'
call histdel('search', -1)
call setpos('.', savepos)
endfunction
command! -nargs=? -range=% Space2Tab call IndentConvert(<line1>,<line2>,0,<q-args>)
command! -nargs=? -range=% Tab2Space call IndentConvert(<line1>,<line2>,1,<q-args>)
command! -nargs=? -range=% RetabIndent call IndentConvert(<line1>,<line2>,&et,<q-args>)
":autocmd BufRead * silent Space2Tab
":autocmd BufWritePre * silent Tab2Space
":autocmd BufWritePost * silent Space2Tab
nmap <leader>mst :Space2Tab<CR>
nmap <leader>mts :Tab2Space<CR>
"}
"HighlightGroupCheck {
function! SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
"}
" Strip whitespace {
function! StripTrailingWhitespace()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" do the business:
%s/\s\+$//e
" clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
" }
"MY SETTINGS
"================================================
"General
"-------------------------------------
colorscheme Peacock
set guifont=Source\ Code\ Pro\ 14
"set 256 color support
set t_Co=256
"set min width and height of split
set winwidth=40
set winheight=12
"Key bindings
"-------------------------------------
"Exit insert mode with jj
inoremap jj <ESC>
inoremap <c-\> <ESC>
"Fast command with space
nmap <space> :
"Bubble single lines (kicks butt)
nmap <C-Up> ddkP
nmap <C-Down> ddp
"Bubble multiple lines
vmap <C-Up> xkP`[V`]
vmap <C-Down> xp`[V`]
"easier window navigation
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l
" Some helpers to edit mode
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>mw :e %%
map <leader>ms :sp %%
map <leader>mv :vsp %%
map <leader>mt :tabe %%
" Adjust viewports to the same size
map <Leader>= <C-w>=
" Display all lines with keyword under cursor
nmap <Leader>mf [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
" Easier horizontal scrolling
map zl zLz6h
map zh zHz6l
" Delete in normal mode with BS
nmap <bs> X
nmap <c-bs> db
"use ,b to list buffer and select by number
nnoremap <leader>b :ls<CR>:buffer<Space>
" Insert mode workflow
inoremap AA <c-o>A
inoremap <c-l><c-l> <c-o>A
inoremap <c-s-l> <c-o>A
inoremap jw <esc>:w<cr>
imap ,n <esc>,n
"run PHP script
nmap ,pr <esc>:!clear && php %:p <cr>
" Omni complete with <c-space>
if has('gui_running')
inoremap <expr><C-space> <c-x><c-o><c-p>
else
inoremap <Nul> <C-X><C-O><C-P>
endif
"Colorscheme fix
"-------------------------------------
hi Normal guibg=#262626 ctermbg=none "set terminal background to #0D1B1E
hi Nontext guibg=#1c1c1c ctermbg=235 "set terminal background to #0D1B1E
hi SpecialKey ctermbg=none guibg=NONE
hi Pmenu ctermfg=236 ctermbg=249 guifg=bg guibg=#b2b2b2
hi PmenuSel ctermfg=188 ctermbg=24 guifg=fg guibg=#005f87
hi PmenuSbar ctermfg=249 ctermbg=252 guifg=#b2b2b2 guibg=#d0d0d0
hi PmenuThumb ctermfg=188 ctermbg=244 guifg=fg guibg=#808080
hi TabLine term=none cterm=none ctermfg=236 ctermbg=249 gui=none guifg=bg guibg=#b2b2b2
hi TabLineSel cterm=bold ctermfg=188 ctermbg=24 gui=bold guifg=fg guibg=#005f87
hi TabLineFill ctermfg=239 ctermbg=249 guifg=#4e4e4e guibg=#b2b2b2
"hi Type ctermfg=203 guifg=#ff5d38
"
@netsmertia
Copy link
Author

Change color scheme whatever you want. .vimrc is working fine for me on Mac OSX 10.9 and Ubuntu. Some Bundles are commented with " because may be they are not working fine Or may be I don't find them useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment