Skip to content

Instantly share code, notes, and snippets.

@igorbabko
Last active November 14, 2016 11:31
Show Gist options
  • Save igorbabko/914665221692e5fa80c075e92a0ef489 to your computer and use it in GitHub Desktop.
Save igorbabko/914665221692e5fa80c075e92a0ef489 to your computer and use it in GitHub Desktop.
" we want the latest VIM settings/options
"let macvim_skip_colorscheme = 1
let mapleader = ',' " setup leader key ( \ - by default )
syntax enable " enable syntax highlighting
"colorscheme atom-dark " setup colorscheme
set noerrorbells visualbell t_vb= " remove damn bell
set complete=.,w,b,u " set our desired autocompletion matching
so ~/.vim/plugins.vim " include plugins.vim
so ~/.vim/BufOnly.vim " scrips to delete all buffers but current
set backspace=indent,eol,start " make backspace behave like every other editor
set number " show line numbers
set linespace=30
set autowriteall " autosave files when closing
"set foldmethod=syntax " set fold method
"let loaded_netrwPlugin = 1 " whether load netrw plugin or not
"----------------------- TAB settings -----------------------
set expandtab " expand tabs to spaces
set tabstop=4
set shiftwidth=4 " indents for normal mode
set softtabstop=4 " indents for insert mode
"Sort PHP use statements
"http://stackoverflow.com/questions/11531073/how-do-you-sort-a-range-of-lines-by-length
vmap <leader><leader>s ! awk '{ print length(), $0 \| "sort -n \| cut -d\\ -f2-" }'<cr>
"----- Movement keys -----"
noremap ; l
noremap l k
noremap k j
noremap j h
"-------------------------"
nnoremap pwd :pwd<cr> " quick pwd call
inoremap jj <esc> " exit insert mode
nmap <leader>w :w<cr> " quick save
nmap <leader>d :bd<cr> " quick buffer deletion
"----- Visuals -----"
let g:enable_bold_font = 1
set showtabline=0
"set background=dark
"colorscheme hybrid_material
set background=dark
"colorscheme hybrid_material
colorscheme hybrid_reverse
"/
"/ Airline confs
"/
"let g:airline_left_sep=''
"let g:airline_right_sep=''
let g:airline_powerline_fonts = 1 " use powerline fonts with special symbols
let g:airline_theme = "hybrid"
set t_Co=256
set guifont=Cousine\ For\ Powerline:h14 " set font family
set t_co=256 " use 256 colors. This is useful for terminal vim
set guioptions-=e " we don't need gui tabs
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
set statusline=0 " hide statusline in macvim
"set laststatus=2
" We'll fake a custom left padding for each window
hi linenr guibg=bg
" set foldcolumn=2
hi foldcolumn guibg=bg
hi vertsplit guibg=bg guifg=bg " get rid of ugly split borders
"-------------- Split management ----------------"
set splitbelow " make new split appear below
set splitright " make new split appera on the right side
nnoremap <C-J> <C-W><C-H>
nnoremap <C-K> <C-W><C-J>
nnoremap <C-L> <C-W><C-K>
nnoremap <C-;> <C-W><C-L>
"set nosmartcase
set ignorecase " ignore case when searching
"-------------- Search ----------------"
set hlsearch " highlight search results
set incsearch " incremental search
nmap <leader><space> :nohlsearch<cr> " Add simple highlight removal
"-------------- Mappings --------------"
:map \s :set smartcase!<CR>:set smartcase?<CR> " toggle smartcase
nmap <leader><leader>a :BufOnly<cr> " close all buffers but current
nmap cf :echo @%<cr> " show current filepath
nmap cd :cd %:p:h<cr> " set current working directory
nmap <leader>ev :tabedit $MYVIMRC<cr> " make it easy to edit the .vimrc file
nmap <leader>ep :tabedit ~/.vim/plugins.vim<cr> " open plugins.vim
nnoremap <leader>ls :ls<cr> " quick list buffers
nnoremap <leader>s :source %<cr> " quick source current file
nnoremap <leader><leader>md <C-]> " quickly go to the method definition under cursor
nnoremap <leader>b <C-^> " open previous buffer
nmap <leader>c :copen<cr> " show copen panel
nnoremap <leader>q :q<cr> " quick close
" nmap <leader>es :e ~/.vim/snippets/ " open snippets file
"--------------Laravel specific-------------------"
nmap <leader>lr :e routes/web.php<cr>
nmap <leader>lm :!php artisan make:
nmap <leader><leader>c :e app/Http/Controllers<cr>
nmap <leader><leader>m :e app/Models<cr>
nmap <leader><leader>v :e resources/views<cr>
"----- buffers -----"
nmap <leader>d :bd<cr> " delete current buffer
nmap <leader>ls :ls<cr> " list all buffers
"-------------------
"-------------- Auto-Commands --------------"
augroup autosourcing
autocmd!
autocmd BufWritePost .vimrc source % " Automatically source the .vimrc file on save
augroup END
"----- Plugins -----"
"/
"/ NERDTree
"/
let NERDTreeHijackNetrw = 0
nmap <leader>nt :NERDTreeToggle<cr>
"/
"/ Ag
"/
nmap <leader>as :Ag
"/
"/ Greplace
"/
set grepprg=ag
let g:grep_cmd_opts = '--line-numbers --noheading'
nmap <leader>s :Gsearch<cr>
nmap <leader>r :Greplace<cr>
"/
"/ Php-cs-fixer
"/
let g:php_cs_fixer_level = "psr2"
nnoremap <silent><leader>fd :call PhpCsFixerFixDirectory()<cr>
nnoremap <silent><leader>ff :call PhpCsFixerFixFile()<cr>
"/
"/ Emmet
"/
let g:user_emmet_leader_key='<C-y>'
"/
"/ Vim-php-namespace
"/
noremap <leader>u :call PhpInsertUse()<cr> " insert use statement
noremap <leader>f :call PhpExpandClass()<cr> " expand fully-qualified classname
"/
"/ CtrlP
"/
nmap cp :CtrlP<cr>
nmap ce :CtrlPBufTag<cr>
nmap cm :CtrlPMRUFiles<cr>
let g:ctrlp_custom_ignore = 'node_modules\|git\.DS_Store'
let g:ctrlp_match_window = 'top,order:ttb,min:1;max:30,result:30'
"/
"/ CTags
"/
nmap tt :tag
nmap <leader><leader>tn :tn<cr> " go to next tag
nmap <leader><leader>tp :tp<cr> " go to previus tag
nmap <leader><leader>ts :ts<cr> " go to specified tag
"/
"/ PHP doc
"/
let g:pdv_template_dir = $HOME ."/.vim/bundle/pdv/templates_snip"
nnoremap <leader>pd :call pdv#DocumentWithSnip()<CR>
"/
"/ Syntastic
"/
let g:syntastic_javascript_checkers = ['jshint']
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
"let g:syntastic_always_populate_loc_list = 1
"let g:syntastic_auto_loc_list = 1
"let g:syntastic_check_on_open = 1
"let g:syntastic_check_on_wq = 0
"/
"/ Syntastic ( isn't installed)
"/
"let g:neocomplete#enable_at_startup = 1
"/
"/ Tagbar
"/
nmap <leader>tb :TagbarToggle<CR>
"/
"/ UltiSnips
"/
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
let g:UltiSnipsSnippetsDir = "~/.vim/bundle/ultisnips/UltiSnips"
nmap <leader>/ :UltiSnipsEdit<cr>
"/
"/ Autoformat
"/
noremap <leader>af :Autoformat<cr>
let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp'
if executable('ag')
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
endif
" Notes -----------------------------------------------------------------------------
" zz - center line
" ysiw<tagname> - surround with a tag
" <leader>c<space> - toggle comments on selected lines
" <leader>cm - toggle multi-line comments
" <leader>ci - toggle individual comments
" <leader>cc - add comments to the current or selected lines
" -------------------- Marks -----------------------------------
" :marks - show all marks
" m<any key> - set the mark
" '<any key> - go to the mark
" m<uppercased key> - set global mark
" `<any key> - go to the mark at the exact position
" also we can delete content until the specified mark ( d'<any key> )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment