Skip to content

Instantly share code, notes, and snippets.

@igorbabko
Last active October 15, 2016 15:56
Show Gist options
  • Save igorbabko/be90a94c5380f2dd77c8a41ce9391d6d to your computer and use it in GitHub Desktop.
Save igorbabko/be90a94c5380f2dd77c8a41ce9391d6d to your computer and use it in GitHub Desktop.
set backspace=indent,eol,start " make backspace behave like every other editor
set number " let's activate line numbers
set linespace=25 " mac-vim specific lineheight
set noerrorbells visualbell t_vb= " remove damn bell
set autowriteall " autosave files when closing
let mapleader = ',' " the default leader is \, but a comma is much better
set shiftwidth=4 " indents will have a width of 4
set softtabstop=4 " sets the number of columns for a tab
set expandtab " expand tabs to spaces
set tabstop=4 " the width of a tab is set to 4.
" still it is a \t. it is just that
" vim will interpret it to be having
" a width of 4.
set statusline=0
"----------- plugins ----------------"
"/
"/ vim
"/
let g:user_emmet_leader_key='<C-Y>' " Ctrl + Y + <leader> will expand emmet abbreviation
let g:user_emmet_mode='a' "enable all function in all mode.
"/
"/ js-beautify
"/
".vimrc
map <leader><leader>f :call HtmlBeautify()<cr>
" or
"autocmd FileType javascript noremap <buffer> <c-f> :call JsBeautify()<cr>
" for json
"autocmd FileType json noremap <buffer> <c-f> :call JsonBeautify()<cr>
" for jsx
"autocmd FileType jsx noremap <buffer> <c-f> :call JsxBeautify()<cr>
" for html
"autocmd FileType html noremap <buffer> <leader><leader>f :call HtmlBeautify()<cr>
" for css or scss
"autocmd FileType css noremap <buffer> <c-f> :call CSSBeautify()<cr>
"/
"/ Vim-coffee-script
"/
filetype off
set rtp+=~/.vim/bundle/vundle/
"call vundle#rc()
syntax enable
filetype plugin indent on
"/
"/ UltiSnips
"/
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
nnoremap <leader><leader>s :UltiSnipsEdit<cr> " Quickly open snippets file
"/
"/ PDV (php documentor)
"/
let g:pdv_template_dir = $HOME ."/.vim/bundle/pdv/templates_snip"
nnoremap <leader>pd :call pdv#DocumentWithSnip()<CR>
"/
"/ 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'
nmap <leader>p <Plug>PeepOpen
"/
"/ NERDTree
"/
let NERDTreeHijackNetrw = 0
nmap nt :NERDTreeToggle<cr>
so ~/.vim/plugins.vim " include plugins.vim file
"/
"/ php-cs-fixer
"/
let g:php_cs_fixer_level = "psr2"
"nnoremap <silent><leader>pcd :call PhpCsFixerFixDirectory()<CR>
nnoremap <silent><leader>pf :call PhpCsFixerFixFile()<CR>
"/
"/ Greplace
"/
set grepprg=ag " We want to use Ag for a search
let g:grep_cmd_opts = '--line-numbers --noheading'
"/
"/ 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
"----------- visuals ----------------"
set guifont=fira_code:h17
set t_co=256 " use 256 colors. this is useful for terminal vim
colorscheme atom-dark
"colorscheme tomorrow-night
set guioptions-=e " we don't need guioptions
set guioptions-=l
set guioptions-=l
set guioptions-=r
set guioptions-=r
" we'll fake a custom left padding for each window
hi linenr guibg=bg
"set foldcolumn=2
"hi foldcolumn guibg=bg
" get rid of ugly split borders
hi vertsplit guibg=bg guifg=bg
"-------------- Split management ----------------"
set splitbelow
set splitright
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>
"-------------- Search ----------------"
set hlsearch
set incsearch
nmap <leader><space> :nohlsearch<cr> " Add simple highlight removal
"-------------- Laravel-Specific --------------"
nmap <leader>lr :e app/Http/routes.php<cr> " Quick open of routes.php
nmap <leader>lm :!php artisan make:
nmap <leader><leader>c :e app/Http/Controllers/<cr>
nmap <leader><leader>m :e app/<cr>
nmap <leader><leader>v :e resources/views/<cr>
"-------------- testing -------------------"
nmap <leader>t :!phpunit<cr>
nmap <leader>st :!phpunit %<cr>
nmap <leader>m yiw:!phpunit --filter "<cr>
"-------------- Mappings --------------"
nmap <leader>ev :tabedit $MYVIMRC<cr> "Make it easy to edit the vimrc file
nmap <leader>es :e ~/.vim/snippets/
nmap cd :cd %:p:h
nnoremap pwd :pwd<cr>
noremap ; l
noremap l k
noremap k j
noremap j h
nmap <leader>w :w<cr> " quick file save
nnoremap <leader><leader>l :!ls<cr>
" quick list files
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-^> " quickly get back to previous buffer
inoremap jj <esc> " exit insert mode
nmap <leader>d :bd<cr> " delete current buffer
nmap <leader><leader>d :bd!<cr> " delete current buffer
nmap <leader><leader>b :ls<cr>
" quick list all buffers
nmap <leader><leader>t :!/usr/local/bin/ctags -R --exclude=node_modules<cr> " run ctags
"Sort PHP use statements
"http://stackoverflow.com/questions/11531073/how-do-you-sort-a-range-of-lines-by-length
vmap <Leader>su ! awk '{ print length(), $0 \| "sort -n \| cut -d\\ -f2-" }'<cr>
"-------------- Auto-Commands --------------"
augroup autosourcing
autocmd!
autocmd BufWritePost .vimrc source % " Automatically source the .vimrc file on save
augroup END
function! IPhpInsertUse()
call PhpInsertUse()
call feedkeys('a', 'n')
endfunction
autocmd FileType php inoremap <Leader>n <Esc>:call IPhpInsertUse()<CR>
autocmd FileType php noremap <Leader>n :call PhpInsertUse()<CR>
function! IPhpExpandClass()
call PhpExpandClass()
call feedkeys('a', 'n')
endfunction
autocmd FileType php inoremap <Leader>nf <Esc>:call IPhpExpandClass()<CR>
autocmd FileType php noremap <Leader>nf :call PhpExpandClass()<CR>
" Notes and Tips
" zz - position line under cursor in the center of the screen
" copen - open some kind of console with grep results and anything else :)
" :call ReloadAllSnippets() - reload all snippets
" select something and press :sort. It will sort in alphabetical order
" . - repeat previous command
" :UltiSnipsEdit - open file with snippets which corresponds to current filetype
" J - concatenate current and next lines
" sbuffer <buffer number> - open buffer in split window
" ------------------ marks ----------------------
" m <button> - mark particular position
" when capital key is specified for mark then it works accross files
" ' <button> - go to specified mark
" ' <button> - go to specified mark and position
" ------------------ multiple cursors ------------------
" Ctrl + n - put multiple cursor on the highlighted lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment