Created
August 17, 2013 02:37
-
-
Save ebuckley/6254978 to your computer and use it in GitHub Desktop.
vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
set list nolist | |
inoremap jj <esc> | |
runtime bundle/pathogen.vim | |
silent! call pathogen#helptags() | |
silent! call pathogen#runtime_append_all_bundles() | |
filetype plugin indent on | |
syntax on | |
set mouse=a | |
set history=1000 | |
set showmode | |
set cursorline | |
hi cursorline guibg=#333333 | |
hi CurorColumn guibg=#333333 | |
set nu | |
set showmatch | |
set incsearch | |
set hlsearch | |
set ignorecase | |
set smartcase | |
set wildmenu | |
set wildmode=list:longest,full " command <Tab> completion, list matches, then longest common part, then all. | |
set whichwrap=b,s,h,l,<,>,[,] " backspace and cursor keys wrap to | |
set scrolljump=5 " lines to scroll when cursor leaves screen | |
set scrolloff=3 " minimum lines to keep above and below cursor | |
set foldenable " auto fold code | |
set gdefault " the /g flag on :s substitutions by default | |
"set list | |
set nocompatible | |
set list nolist | |
inoremap jj <esc> | |
runtime bundle/pathogen.vim | |
silent! call pathogen#helptags() | |
silent! call pathogen#runtime_append_all_bundles() | |
filetype plugin indent on | |
syntax on | |
set mouse=a | |
set history=1000 | |
set showmode | |
set cursorline | |
hi cursorline guibg=#333333 | |
hi CurorColumn guibg=#333333 | |
set nu | |
set showmatch | |
set incsearch | |
set hlsearch | |
set ignorecase | |
set smartcase | |
set wildmenu | |
set wildmode=list:longest,full " command <Tab> completion, list matches, then longest common part, then all. | |
set whichwrap=b,s,h,l,<,>,[,] " backspace and cursor keys wrap to | |
set scrolljump=5 " lines to scroll when cursor leaves screen | |
set scrolloff=3 " minimum lines to keep above and below cursor | |
set foldenable " auto fold code | |
set gdefault " the /g flag on :s substitutions by default | |
"set list | |
" Formatting { | |
set nowrap " wrap long lines | |
set autoindent " indent at the same level of the previous line | |
set shiftwidth=4 " use indents of 4 spaces | |
set expandtab " tabs are spaces, not tabs | |
set tabstop=4 " an indentation every four columns | |
set softtabstop=4 " let backspace delete indent | |
"set matchpairs+=<:> | |
" Formatting { | |
set nowrap " wrap long lines | |
set autoindent " indent at the same level of the previous line | |
set shiftwidth=4 " use indents of 4 spaces | |
set expandtab " tabs are spaces, not tabs | |
set tabstop=4 " an indentation every four columns | |
set softtabstop=4 " let backspace delete indent | |
"set matchpairs+=<:> " match, to be used with % | |
set pastetoggle=<F12> " pastetoggle (sane indentation on pastes) | |
"set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks | |
" Remove trailing whitespaces and ^M chars | |
" autocmd FileType c,cpp,java,php,js,python,twig,xml,yml autocmd BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")')) | |
" } | |
" Key (re)Mappings { | |
"The default leader is '\', but many people prefer ',' as it's in a standard | |
"location | |
let mapleader = ',' | |
" Making it so ; works like : for commands. Saves typing and eliminates :W style typos due to lazy holding shift. | |
nnoremap ; : | |
" Easier moving in tabs and windows | |
map <C-J> <C-W>j<C-W>_ | |
map <C-K> <C-W>k<C-W>_ | |
map <C-L> <C-W>l<C-W>_ | |
map <C-H> <C-W>h<C-W>_ | |
map <C-K> <C-W>k<C-W>_ | |
" Wrapped lines goes down/up to next row, rather than next line in file. | |
nnoremap j gj | |
nnoremap k gk | |
" Stupid shift key fixes | |
cmap W w | |
cmap WQ wq | |
cmap wQ wq | |
cmap Q q | |
cmap Tabe tabe | |
" Yank from the cursor to the end of the line, to be consistent with C and D. | |
nnoremap Y y$ | |
"clearing highlighted search | |
nmap <silent> <leader>/ :nohlsearch<CR> | |
" Fix home and end keybindings for screen, particularly on mac | |
" - for some reason this fixes the arrow keys too. huh. | |
" This section has hidden characters, please checkout from github. | |
" For when you forget to sudo.. Really Write the file. | |
cmap w!! w !sudo tee % >/dev/null | |
" Supertab { | |
let g:SuperTabDefaultCompletionType = "context" | |
let g:SuperTabContextDefaultCompletionType = "<c-x><c-o>" | |
" } | |
" Command-t { | |
let g:CommandTSearchPath = $HOME . '/Code' | |
" } | |
hi Pmenu guifg=#000000 guibg=#F8F8F8 ctermfg=black ctermbg=Lightgray | |
hi PmenuSbar guifg=#8A95A7 guibg=#F8F8F8 gui=NONE ctermfg=darkcyan ctermbg=lightgray cterm=NONE | |
hi PmenuThumb guifg=#F8F8F8 guibg=#8A95A7 gui=NONE ctermfg=lightgray ctermbg=darkcyan cterm=NONE | |
" some convenient mappings | |
inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>" | |
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" | |
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>" | |
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>" | |
inoremap <expr> <C-d> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>" | |
inoremap <expr> <C-u> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>" | |
" and make sure that it doesn't break supertab | |
let g:SuperTabCrMapping = 0 | |
" automatically open and close the popup menu / preview window | |
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif | |
set completeopt=menu,preview,longest | |
" } | |
" Delimitmate { | |
au FileType * let b:delimitMate_autoclose = 1 | |
" If using html auto complete (complete closing tag) | |
au FileType xml,html,xhtml let b:delimitMate_matchpairs = "(:),[:],{:}" | |
" } | |
" AutoCloseTag { | |
" Make it so AutoCloseTag works for xml and xhtml files as well | |
au FileType xhtml,xml ru ftplugin/html/autoclosetag.vim | |
" } | |
" SnipMate { | |
" Setting the author var | |
" If forking, please overwrite in your .vimrc.local file | |
" Shortcut for reloading snippets, useful when developing | |
nnoremap ,smr <esc>:exec ReloadAllSnippets()<cr> | |
" } | |
" NerdTree { | |
map <C-e> :NERDTreeToggle<CR>:NERDTreeMirror<CR> | |
map <leader>e :NERDTreeFind<CR> | |
nmap <leader>nt :NERDTreeFind<CR> | |
let NERDTreeShowBookmarks=1 | |
let NERDTreeIgnore=['\.pyc', '\~$', '\.swo$', '\.swp$', '\.git', '\.hg', '\.svn', '\.bzr'] | |
let NERDTreeChDirMode=0 | |
let NERDTreeQuitOnOpen=1 | |
let NERDTreeShowHidden=1 | |
let NERDTreeKeepTreeInNewTab=1 | |
" } | |
" php-doc command { | |
nmap <leader>pd :call PhpDocSingle()<CR> | |
vmap <leader>pd :call PhpDocRange()<CR> | |
" } | |
" Taglist Variables { | |
let Tlist_Auto_Highlight_Tag = 1 | |
let Tlist_Auto_Update = 1 | |
let Tlist_Exit_OnlyWindow = 1 | |
let Tlist_File_Fold_Auto_Close = 1 | |
let Tlist_Highlight_Tag_On_BufEnter = 1 | |
let Tlist_Use_Right_Window = 1 | |
let Tlist_Use_SingleClick = 1 | |
let g:ctags_statusline=1 | |
" Override how taglist does javascript | |
let g:tlist_javascript_settings = 'javascript;f:function;c:class;m:method;p:property;v:global' | |
" } | |
" } | |
" } | |
" GUI Settings { | |
" GVIM- (here instead of .gvimrc) | |
if has('gui_running') | |
colorscheme obsidian | |
set guioptions-=T " remove the toolbar | |
set lines=40 " 40 lines of text instead of 24, | |
set guifont=Monospace\ 11 | |
else | |
set term=builtin_ansi " Make arrow and other keys work | |
endif | |
" } | |
function! InitializeDirectories() | |
let separator = "." | |
let parent = $HOME | |
let prefix = '.vim' | |
let dir_list = { | |
\ 'backup': 'backupdir', | |
\ 'views': 'viewdir', | |
\ 'swap': 'directory' } | |
for [dirname, settingname] in items(dir_list) | |
let directory = parent . '/' . prefix . dirname . "/" | |
if exists("*mkdir") | |
if !isdirectory(directory) | |
call mkdir(directory) | |
endif | |
endif | |
if !isdirectory(directory) | |
echo "Warning: Unable to create backup directory: " . directory | |
echo "Try: mkdir -p " . directory | |
else | |
let directory = substitute(directory, " ", "\\\\ ", "") | |
exec "set " . settingname . "=" . directory | |
endif | |
endfor | |
endfunction | |
call InitializeDirectories() | |
function! NERDTreeInitAsNeeded() | |
redir => bufoutput | |
buffers! | |
redir END | |
let idx = stridx(bufoutput, "NERD_tree") | |
if idx > -1 | |
NERDTreeMirror | |
NERDTreeFind | |
wincmd l | |
endif | |
endfunction | |
" Use local vimrc if available { | |
if filereadable(expand("~/.vimrc.local")) | |
source ~/.vimrc.local | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment