Instantly share code, notes, and snippets.

Embed
What would you like to do?
My .vimrc file
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15
set showmode " always show what mode we're currently editing in
set nowrap " don't wrap lines
set tabstop=4 " a tab is four spaces
set smarttab
set tags=tags
set softtabstop=4 " when hitting <BS>, pretend like a tab is removed, even if spaces
set expandtab " expand tabs by default (overloadable per file type later)
set shiftwidth=4 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set number " always show line numbers
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
set timeout timeoutlen=200 ttimeoutlen=100
set visualbell " don't beep
set noerrorbells " don't beep
set autowrite "Save on buffer switch
set mouse=a
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saves
nmap <leader>w :w!<cr>
" Down is really the next line
nnoremap j gj
nnoremap k gk
"Easy escaping to normal model
imap jj <esc>
"Auto change directory to match current file ,cd
nnoremap ,cd :cd %:p:h<CR>:pwd<CR>
"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
"Resize vsplit
nmap <C-v> :vertical resize +5<cr>
nmap 25 :vertical resize 40<cr>
nmap 50 <c-w>=
nmap 75 :vertical resize 120<cr>
nmap <C-b> :NERDTreeToggle<cr>
"Load the current buffer in Chrome
nmap ,c :!open -a Google\ Chrome<cr>
"Show (partial) command in the status line
set showcmd
" Create split below
nmap :sp :rightbelow sp<cr>
" Quickly go forward or backward to buffer
nmap :bp :BufSurfBack<cr>
nmap :bn :BufSurfForward<cr>
highlight Search cterm=underline
" Swap files out of the project root
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
" Run PHPUnit tests
map <Leader>t :!phpunit %<cr>
" Easy motion stuff
let g:EasyMotion_leader_key = '<Leader>'
" Powerline (Fancy thingy at bottom stuff)
let g:Powerline_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 -- below the statusline)
autocmd cursorhold * set nohlsearch
autocmd cursormoved * set hlsearch
" Remove search results
command! H let @/=""
" If you prefer the Omni-Completion tip window to close when a selection is
" made, these lines close it on movement in insert mode or when leaving
" insert mode
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" Abbreviations
abbrev pft PHPUnit_Framework_TestCase
abbrev gm !php artisan generate:model
abbrev gc !php artisan generate:controller
abbrev gmig !php artisan generate:migration
" Auto-remove trailing spaces
autocmd BufWritePre *.php :%s/\s\+$//e
" Edit todo list for project
nmap ,todo :e todo.txt<cr>
" Laravel framework commons
nmap <leader>lr :e app/routes.php<cr>
nmap <leader>lca :e app/config/app.php<cr>81Gf(%O
nmap <leader>lcd :e app/config/database.php<cr>
nmap <leader>lc :e composer.json<cr>
" Concept - load underlying class for Laravel
function! FacadeLookup()
let facade = input('Facade Name: ')
let classes = {
\ 'Form': 'Html/FormBuilder.php',
\ 'Html': 'Html/HtmlBuilder.php',
\ 'File': 'Filesystem/Filesystem.php',
\ 'Eloquent': 'Database/Eloquent/Model.php'
\ }
execute ":edit vendor/laravel/framework/src/Illuminate/" . classes[facade]
endfunction
nmap ,lf :call FacadeLookup()<cr>
" CtrlP Stuff
" Familiar commands for file/symbol browsing
map <D-p> :CtrlP<cr>
map <C-r> :CtrlPBufTag<cr>
" I don't want to pull up these folders/files when calling CtrlP
set wildignore+=*/vendor/**
set wildignore+=*/public/forum/**
" Open splits
nmap vs :vsplit<cr>
nmap sp :split<cr>
" Create/edit file in the current directory
nmap :ed :edit %:p:h/
" Prepare a new PHP class
function! Class()
let name = input('Class name? ')
let namespace = input('Any Namespace? ')
if strlen(namespace)
exec 'normal i<?php namespace ' . namespace . ';
else
exec 'normal i<?php
endif
" Open class
exec 'normal iclass ' . name . ' {^M}^[O^['
exec 'normal i^M public function __construct()^M{^M ^M}^['
endfunction
nmap ,1 :call Class()<cr>
" 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
'
endfunction
nmap ,2 :call AddDependency()<cr>
@elbakly

This comment has been minimized.

elbakly commented Oct 8, 2013

i receive this error but yet everything else is awesome ps.:"i use ubuntu"
Cannot find color scheme xoria256

@lindstrm

This comment has been minimized.

lindstrm commented Oct 14, 2013

@ODelibalta

This comment has been minimized.

ODelibalta commented Nov 8, 2013

Can I please have the list of plugins?

@captbaritone

This comment has been minimized.

captbaritone commented Nov 13, 2013

It might be nice to replace the ,s in your mappings with <Leader>. Thanks for sharing!

@oidevelopment

This comment has been minimized.

oidevelopment commented Dec 30, 2013

Your macro for inserting the namespace and __constuct() won't work for me, I've copied it straight out of your vimrc file? I'm getting missing ' errors, can you help?

@nieldm

This comment has been minimized.

nieldm commented Jan 14, 2014

I made a few changes to make it work

" Prepare a new PHP class
function! Class()
    let name = input('Class name? ')
    let namespace = input('Any Namespace? ')

    if strlen(namespace)
        exec "normal i<?php namespace " . namespace . ";"
    else
        exec "normal i<?php \<C-m>"
    endif

    " Open class
    exec "normal iclass " . name . " {\<C-m>}\<C-[>O\<C-[>"

    exec "normal i\<C-M>    public function __construct()\<C-M>{\<C-M>\<C-M>}\<C-[>"
endfunction
nmap ,1  :call Class()<cr>

i don't know if there is some way to use "^M" instead of the long version ""

@JeffreyChu

This comment has been minimized.

JeffreyChu commented Apr 12, 2014

I also made a few changes to make it work on Win7

" Prepare a new PHP class
function! Class()
let name = input('Class name? ')
let namespace = input('Any Namespace? ')

if strlen(namespace)
    exec "normal i<?php namespace " . namespace . ";\<C-m>\<C-m>"
else
    exec "normal i<?php \<C-m>"
endif

" Open class
exec "normal iclass " . name . " {\<C-m>}\<C-[>O\<C-[>"

exec "normal i\<C-M>public function __construct()\<C-M>{\<C-M>\<C-M>}\<C-[>"
endfunction
nmap ,1 :call Class()
@firedev

This comment has been minimized.

firedev commented Sep 30, 2014

What difference does it make? Tried in Normal and Visual mode, it looks the same.

" Down is really the next line
nnoremap j gj
nnoremap k gk
@firedev

This comment has been minimized.

firedev commented Oct 1, 2014

@Soufraz

This comment has been minimized.

Soufraz commented Jul 12, 2015

I am in linux and this function reproduce an error. I think there is some related to strange chars..
Is there some reference to learn about this chars:

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
'
endfunction

When I try to run this function I get:

Error detected while processing function AddDependency:
line   10:
E115: Missing quote: 'normal :%s/(, /(/g
E15: Invalid expression: 'normal :%s/(, /(/g
Press ENTER or type command to continue
@phaberest

This comment has been minimized.

phaberest commented Feb 3, 2016

^ There's a typo, the single quote should be at the and of the last exec, not alone on the line above endfunction

@cxbig

This comment has been minimized.

cxbig commented Jul 7, 2016

Couldn't understand why this config file has both of them:

...
11| set showmode
...
94| set noshowmode
...
@notgiorgi

This comment has been minimized.

notgiorgi commented Aug 1, 2016

Gives me error
unable to open swap file for .vimrc recovery impossible
On ubuntu 14.04

@notgiorgi

This comment has been minimized.

notgiorgi commented Aug 1, 2016

Fixed unable to open swap file for .vimrc recovery impossible by creating ~/.vim/backup/ and ~/.vim/swap/ directories.

@hichem77

This comment has been minimized.

hichem77 commented Sep 24, 2016

Thanks for sharing

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