Skip to content

Instantly share code, notes, and snippets.

@cmosguy
Created February 29, 2016 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmosguy/174ede1adf2514f02a03 to your computer and use it in GitHub Desktop.
Save cmosguy/174ede1adf2514f02a03 to your computer and use it in GitHub Desktop.
let &runtimepath.=',$HOME/.vim'
set nocompatible "we want latest vim settings and options
so ~/.vim/plugins.vim
"-------------General Settings--------------"
set directory+=$HOME
set directory+=$TEMP
set nowrap
syntax enable
"colorscheme desert
colorscheme atom-dark
set backspace=indent,eol,start "Make backspace behave like every other editor.
let mapleader = ',' "The default leader is \, but a comma is much better.
set number "Let's activate line numbers.
set autochdir "Set current working directory to automatically be where the current file is located
set noerrorbells visualbell t_vb= "No damn bells!
set visualbell t_vb= "no bells in gvim
set autowriteall "automatically write when writing buffers
set complete=.,w,u "set desired autocompletion to current buffer (.), window (w), buffer (b)
set statusline=2 "showing stausline
set laststatus=2 "need to set to always show status line in last window for some reason
"-------------Visuals--------------"
set t_CO=256 "Use 256 colors. This is useful for Terminal Vim.
if has("win32") || has("win16")
set guifont=consolas:h12 "Set the default font family and size.
else
set guifont=Monospace\ 12
endif
set linespace=15 "Macvim-specific line-height.
set guioptions-=l "Disable Gui scrollbars.
set guioptions-=L
set guioptions-=r
set guioptions-=R
set guioptions-=e "remove the tabs in the gui
"make side line number background more pretty
hi LineNr guibg=bg
"get rid of ugly split borders
hi vertsplit guifg=bg guibg=bg
"set tab spacing to 4 and for auto indenting
set tabstop=4
set shiftwidth=4
"-------------Search--------------"
set hlsearch
set incsearch
"-------------Split Management--------------"
set splitbelow "Make splits default to below...
set splitright "And to the right. This feels more natural.
"We'll set simpler mappings to switch between splits.
nmap <C-J> <C-W><C-J>
nmap <C-K> <C-W><C-K>
nmap <C-H> <C-W><C-H>
nmap <C-L> <C-W><C-L>
"-------------Mappings--------------"
"Make it easy to edit the Vimrc file.
"nmap <Leader>ev :tabedit $MYVIMRC<cr>
nmap <Leader>ev :tabedit ~/.vim/vimrc.vim<cr>
nmap <Leader>es :e ~/.vim/snippets
"Add simple highlight removal.
nmap <Leader><space> :nohlsearch<cr>
"Make NERDTree easier to toggle
nmap <A-1> :NERDTreeToggle<cr>
"Quickly browse to any tag/symbol in the project.
"Tip: run ctags -R to regenerated the index.
nmap <Leader>f :tag<space>
" CTRL-P plugin
nmap <c-R> :CtrlPBufTag<cr>
nmap <space><space> :CtrlPMRUFiles<cr>
" auto indent parts of the file
map <c-F> mzgg=G`z
"NERD commenter
"nmap <c-B> NERDComToggleComment
"open hosts.lm file
if has("win32") || has("win16")
nmap <Leader>h :tabedit C:\Windows\System32\drivers\etc\hosts<cr>
endif
"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>
"-------------Plugins--------------"
"/
"/ CtrlP
"/
let g:ctrlp_custom_ignore = 'node_modules\DS_Store\|git'
let g:ctrlp_match_window = 'top,order:ttb,min:1,max:30,results:30'
"let g:ctrlp_extensions = ['symbol']
"let g:symbol_patterns['javascript'] = '\.prototype.\zs\w\+\ze\ = function'
"/
"/ NERDTree
"/
let NERDTreeHijackNetrw = 0
"/
"/ tcl.vim
"/
let tcl_extended_syntax=1
"
" perforce.vim
"
runtime perforce/perforceutils.vim
runtime perforce/perforcemenu.vim
"
" snipmate
"
"let g:snippets_dir='$HOME\vimfiles\snippets,$HOME\vimfiles\bundle\snipmate.vim\snippets'
let g:snippets_dir='$HOME\.vim\snippets'
"
" vim-php-namespace
"
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>
"status line
set encoding=utf-8
scriptencoding utf-8
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"?":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}',
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
"
" Gist vim
"
let g:gist_open_browser_after_post = 1
"-------------Auto-Commands--------------"
"Automatically source the Vimrc file on save.
augroup autosourcing
autocmd!
autocmd BufWritePost $MYVIMRC nested source $MYVIMRC
autocmd BufWritePost ~/.vim/vimrc.vim nested source %
augroup END
"-------------Tips and Reminders--------------"
"switch between buffers :bn (next buffer)
"zz - center screen to cursor line
"C-W f - open file under cursor in split window
"zc - close fold
"zo - open fold
"tpopes vim-surround
"cs - change surrounding with character then replaced character: ie cs('
"change () wih ''
"ls - list all buffers
"bd - destroy current buffer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment