Skip to content

Instantly share code, notes, and snippets.

@Mulkave
Last active August 29, 2015 14:03
Show Gist options
  • Save Mulkave/0722568b30dc196fea80 to your computer and use it in GitHub Desktop.
Save Mulkave/0722568b30dc196fea80 to your computer and use it in GitHub Desktop.
My way to VIM from Sublime Text - .vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'elzr/vim-json'
Plugin 'joonty/vdebug'
Plugin 'AutoComplPop'
Plugin 'kien/ctrlp.vim'
Plugin 'tobyS/vmustache'
Plugin 'mattn/emmet-vim'
Plugin 'SirVer/ultisnips'
Plugin 'xsbeats/vim-blade'
Plugin 'gmarik/Vundle.vim'
Plugin 'Lokaltog/powerline'
Plugin 'gregsexton/MatchTag'
Plugin 'tacahiroy/ctrlp-funky'
Plugin 'scrooloose/syntastic'
Plugin 'scrooloose/nerdtree'
Plugin 'StanAngeloff/php.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'ekalinin/Dockerfile.vim'
Plugin 'chriskempson/base16-vim'
Plugin 'kchmck/vim-coffee-script'
Plugin 'scrooloose/nerdcommenter'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'nelstrom/vim-markdown-preview'
Plugin 'neo4j-contrib/cypher-vim-syntax'
" SnipMate installation
Plugin 'tomtom/tlib_vim'
Plugin 'honza/vim-snippets'
Plugin 'garbas/vim-snipmate'
Plugin 'MarcWeber/vim-addon-mw-utils'
" Git plugin not hosted on GitHub
"Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
"Plugin 'user/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - list configured plugins
" :PluginInstall(!) - install (update) plugins
" :PluginSearch(!) foo - search (or refresh cache first) for foo
" :PluginClean(!) - confirm (or auto-approve) removal of unused plugins
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this lin2
" Configure ctrlp
let g:ctrlp_map = '<c-p>'
let g:ctrlp_show_hidden = 1
nmap <C-i> :CtrlPFunky<cr>
let g:ctrlp_extensions = ['funky']
" Color Scheme Configuration
"colorscheme xoria256
set background=dark
colorscheme base16-eighties
" Font and syntax
set number
set hlsearch
set tabstop=4
set linespace=2
set guifont=source\ code\ pro\ for\ powerline:h14
set tags=tags
set softtabstop=4 " when hitting <BS>, pretend like a tab is removed, even if spaces
set shiftwidth=4 " use multiple shiftwidth when indenting with '<' and '>'
set expandtab " expand tabs by default
set ignorecase " ignore case when searching
set smartcase " ignore case if seach pattern is all lowercase
set visualbell " don't beep
set noerrorbells " don't beep
"set mouse=a
set mouse=a
set clipboard=unnamed
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set nowrap " do not wrap lines by default
set formatoptions+=or " comment auto indent
" hide annoying scrollbars
set guioptions-=r " always hide the right scrollbar
set guioptions-=R " hide right scrollbar when a split window is preset
set guioptions-=l " always hide the left scrollbar
set guioptions-=L " hide left scrollbar when a split window is preset
" With a mal leader it's possible to do exta key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saves
nmap <leader>w :w!<cr>
" Buffer previous/next mappings
nnoremap [b :bprevious <cr>
nnoremap ]b :bnext <cr>
" Vdebug configuration for XDebug
" First let's ask it not to break at the beginning of the execution
" so that it only stops at our first breakpoint.
let g:vdebug_options = {
\ "break_on_open" : 0,
\}
let g:vdebug_keymap = {
\ 'set_breakpoint': '<leader>bp',
\ 'close': '<leader>0',
\ 'Vetach': '<F7>',
\ 'run': '<leader>5',
\ 'run_to_cursor': '<leader>6',
\ 'step_over': '<Down>',
\ 'step_into': '<Right>',
\ 'step_out': '<Left>',
\ 'get_context': '<leader>4',
\ 'eval_under_cursor': '<Leader>]',
\ 'eval_visual': '<leader>['
\}
" Change the green color of the breakpoint line
hi default DbgBreakptLine term=reverse ctermfg=White ctermbg=Green guifg=#ffffff guibg=#FDFABC
hi default DbgBreakptSign term=reverse ctermfg=White ctermbg=Green guifg=#ffffff guibg=#FDFABC
" Autoclose brackets, parantheses and squares
:inoremap ( ()<Esc>:let leavechar=")"<CR>i
:inoremap { {}<Esc>:let leavechar="}"<CR>i
:inoremap [ []<Esc>:let leavechar="]"<CR>i
" When hitting Enter after { it will automatically put the cursor in the
" middle of to braces on a new line.
inoremap {<CR> {<CR>}<Esc>O<TAB>
" Escape from the autoentered right char using <C-j> and enter editing mode
" after it.
:inoremap <C-j> <Esc>/[)}"'\]>]<CR>:nohl<CR>a
" Down is really the next line
nnoremap j gj
nnoremap k gk
" Quickly go forward or backward to buffer
nmap :bp :BufSurfBack<cr>
nmap :bn :BufSurfForward<cr>
highlight Search cterm=underline
" Easy escaping to normal model
"nmap kj <esc>
" Auto change directory to match current file ,cd
nnoremap ,cd :cd %:p:h<CR>:pwd<CR>
" Toggle sidebar
nmap <C-b> :NERDTreeToggle<cr>
" Resize vsplit
nmap <C-v> :vertical resize +5<cr>
nmap 50 <c-w>=
" Easier window navigtaion
nmap <C-h> <C-w>h
nmap <C-k> <C-w>k
nmap <C-j> <C-w>j
nmap <C-l> <C-w>l
" phpcomplete plugin Configuration
" To enable omni complete
autocmd FileType php setlocal omnifunc=phpcomplete_extended#CompletePHP
let g:phpcomplete_index_composer_command="php /usr/local/bin/composer"
" Swap files out of the project
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
" Enable omni completion
filetype plugin on
set omnifunc=syntaxcomplete#Complete
" doesn't select the first completion item
set completeopt=longest,menuone
" the Enter key will select the highlighted menu item
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" vim-airline
"let g:airline#extensions#tabline#enabled = 1
"let g:airline_powerline_fonts = 1
"let g:airline_theme="base16"
" this overrides the space character fixing an airline issue
"if !exists('g:airline_symbols')
"let g:airline_symbols = {}
"endif
"let g:airline_symbols.space = "\ua0"
" Powerline (Fancy thingy at the bottom)
set rtp+=~/.vim/bundle/powerline/powerline/bindings/vim/
let g:Poserline_symbols = 'fancy'
set laststatus=2 " always show the statusline
set encoding=utf-8 " necessary to show Unicode glyphs
set noshowmode "hide the default mode text (e.g. -- INSERT -- belo the statusline
" Remove search results
command! H let @/=""
" Set the color high
set t_Co=256
" Set syntax
syntax enable
" Make NERDTree show hiddne files
let NERDTreeShowHidden=1
let NERDTreeHighlightCursorline=1
" Configure phpunit
let g:phpunit_cmd = "./vendor/bin/phpunit"
" Automatically remove trailing whitespace on save
autocmd BufWritePre * :%s/\s\+$//e
nmap <leader>lr :e app/routes.php<cr>
nmap <leader>lca :e app/config/app.php<cr>81Gf(%0
nmap <leader>lc :e composer.json<cr>
" I don't want to pull up these folders/files when calling CtrlP
set wildignore+=*/vendor/**,*/node_modules/**
"nmap <leader>r :CtrlPBufTagAll<cr>
"let g:ctrlp_buftag_ctags_bin = "./tags" " load the tags so that we can go-to their definition in open buffers
" Command Aliases
nmap <leader>vinprd :cd ~/Developer/Vinelab/Products/<cr>
nmap <leader>najem :cd ~/Developer/Vinelab/Products/najem/core/najem/<cr>
nmap <leader>dev :cd ~/Developer/<cr>
" PHP Stuff
" Add a new dependency to a PHP class
function! AddDependency()
let dependency = input('Var Name: ')
let namespace = input('Class Path: ')
let segments = split(namespace, '\')
let typehint = segments[-1]
exec 'normal gg/construct^M:H^Mf)i, ' . typehint . ' $' . dependency . '^[/}^>O$this->^[a' . dependency . ' = $' . dependency . ';^[?{^MkOprotected $' . dependency . ';^M^[?{^MOuse ' . namespace . ';^M^['
" Remove opening comma if there is only one dependency
exec 'normal :%s/(, /(/g^M'
endfunction
nmap ,2 :call AddDependency()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment