Skip to content

Instantly share code, notes, and snippets.

Created Mar 21, 2016
What would you like to do?
let &runtimepath.=',$HOME/.vim'
set nocompatible "we want latest vim settings and options
so ~/.vim/plugins.vim
"so ~/.vim/indent/tcl.vim
"-------------General Settings--------------"
set directory+=$HOME
set directory+=$TEMP
set nowrap
syntax enable
"colorscheme desert
if has('gui_running')
colorscheme atom-dark
let g:solarized_termcolors=256
colorscheme solarized
set background=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
set autoread "When file changed outside vim auto read
autocmd FileChangedShell *
\ echohl WarningMsg |
\ echo "File has been changed outside of vim." |
\ echohl None
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.
set guifont=Monospace\ 12
set linespace=5 "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
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>
"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
nmap <Leader>csh :e ~/.cshrc.$USER<cr>
"Add simple highlight removal.
nmap <Leader><space> :nohlsearch<cr>
"easily replace under word and search and replace
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
"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>
"Sort PHP use statements
vmap <Leader>su ! awk '{ print length(), $0 \| "sort -n \| cut -d\\ -f2-" }'<cr>
"/ 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
au BufRead,BufNewFile *.test setfiletype tcl
" 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')
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')
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
"set misc filetypes
au BufRead,BufNewFile *.scs setfiletype spectre
"Automatically source the Vimrc file on save.
augroup autosourcing
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