Skip to content

Instantly share code, notes, and snippets.

@l3lake
Forked from JeffreyWay/.vimrc
Last active August 29, 2019 14:39
Show Gist options
  • Select an option

  • Save l3lake/ee34c6438e45046876b9 to your computer and use it in GitHub Desktop.

Select an option

Save l3lake/ee34c6438e45046876b9 to your computer and use it in GitHub Desktop.
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
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)
" gui settings
set guifont=Menlo\Regular: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
set showcmd "Show (partial) command in the status line
" Fast saves
nmap <leader>w :w!<cr>
nmap <leader>q :q!<cr>
nmap <leader>x :x!<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>
highlight Search cterm=underline
" Open splits
nmap vs :vsplit<cr>
nmap sp :split<cr>
" Create split below
nmap :sp :rightbelow sp<cr>
" the first quote will autoclose so you'll get 'foo' and hitting <c-a> will
" put the cursor right after the quote
imap <C-a> <esc>wa
" Zoom in
map <silent> ,gz <C-w>o
" Source current file Cmd-% (good for vim development)
nmap <silent> ,so :so %<CR>
"-------------------------------------------------------------------
"
" My Additions
"
"-------------------------------------------------------------------
" Quickly toggle line numbers
:nmap <C-N><C-N> :set invnumber<CR>
" Toggle NERDTree
map <leader>n :NERDTreeToggle<CR>
" Quickly write file as using sudo
map <leader>ww :!sudo tee > /dev/null %<cr>
" Quickly open vimrc.after
nmap <leader>vi :e ~/.vimrc.after<cr>
" Edit todo list for project
nmap ,todo :e todo.txt<cr>
" Quickly go forward or backward to buffer
"nmap <leader>bp :BufSurfBack<cr>
"nmap <leader>bn :BufSurfForward<cr>
nmap <leader>bh :bp<cr>
nmap <leader>bl :bn<cr>
" Quickly swtich between alternate buffers
nnoremap <leader><leader> <c-^>
" Create new tab
nmap <leader>nt :tabe<cr>
" Quickly go forward or backward b/t tabs
nmap <leader>tp gt<cr>
nmap <leader>tn gT<cr>
" Quickly turn off highlights
"nnoremap <leader><space> :noh<cr>
noremap nn :noh<cr>
autocmd cursorhold * set nohlsearch
autocmd cursormoved * set hlsearch
" Swap files out of the project root
set backupdir=~/.vim/backup/
set directory=~/.vim/swap/
" 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/**
" Create/edit file in the current directory
nmap :ed :edit %:p:h/
" Gist https://github.com/mattn/gist-vim/blob/master/README.mkd#usage
let g:gist_clip_command = 'pbcopy' " Mac
let g:gist_clip_command = 'putclip' " Others
let g:gist_clip_command = 'xclip -selection clipboard' " Linux
let g:gist_detect_filetype = 1 " Let Gist detect filetype
" 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
" redo
nmap <leader>r :red<cr>
"Load the current buffer in Chrome (mac)
nnoremap <leader>g :exe ':silent !open -a /Applications/Google\ Chrome.app %'<CR>
"Load the current buffer in Chrome (pc)
"map <silent> ,pc :!open -a Google\ Chrome %<CR><CR>
"-------------------------------------------------------------------
"
" Laravel
"
"-------------------------------------------------------------------
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
autocmd BufWritePre *.txt :%s/\s\+$//e
autocmd BufWritePre *.html :%s/\s\+$//e
" 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>
"-------------------------------------------------------------------
"
" PHP
"
"-------------------------------------------------------------------
" Abbreviations
"abbrev pft PHPUnit_Framework_TestCase
" Run PHPUnit tests
"map <Leader>t :!phpunit %<cr>
" 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment