Created
July 2, 2018 16:01
-
-
Save connormanning/0f08ba3e4da0963e36114900a5c311ee 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 lines=65 | |
set columns=175 | |
set nocompatible | |
set number | |
set expandtab | |
set tabstop=4 | |
set shiftwidth=4 | |
set hlsearch | |
set ignorecase | |
set smartcase | |
set backspace=2 | |
set ruler | |
set noswapfile | |
set colorcolumn=80 | |
" Display full path in statusline | |
set statusline=%<%F\ %h%m%r%=%-14.(%l,%c%V%)\ %P | |
let mapleader=',' | |
set timeoutlen=250 | |
set foldmethod=syntax | |
set foldlevelstart=999 | |
let javaScript_fold=1 | |
autocmd Syntax c,cpp normal zR | |
nnoremap <Leader>a za | |
nmap <F1> <nop> | |
imap <F1> <nop> | |
" Disable all system bells | |
set noeb vb t_vb= | |
colorscheme evening | |
syntax on | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" let Vundle manage Vundle, required | |
Plugin 'VundleVim/Vundle.vim' | |
Plugin 'ctrlpvim/ctrlp.vim' | |
call vundle#end() | |
filetype plugin indent on " required | |
" CtrlP settings | |
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*.cs,*.sh,*.bat,*.o,*.txt,*.d,*.hmap,*csmannin*,*node_modules*,*CMakeFiles*,*greyhound/data*,*gtest* | |
let g:ctrlp_working_path_mode = 'ra' | |
let g:ctrlp_match_window = 'bottom,order:ttb,min:12,max:12' | |
" Exit a highlighted search with CR | |
:nnoremap <CR> :noh<CR><CR> | |
:inoremap <S-Tab> <Esc><<i | |
au BufRead,BufNewFile *.tpp set filetype=cpp | |
" Move around tabs | |
nnoremap <C-h> <C-w>h | |
nnoremap <C-j> <C-w>j | |
nnoremap <C-k> <C-w>k | |
nnoremap <C-l> <C-w>l | |
function FuzzySwitch() | |
python << EOF | |
import vim, os.path, sys | |
headers = ['.hpp', '.h', '.hxx'] | |
impls = ['.cpp', '.c', '.cxx', '.cc'] | |
path = vim.current.buffer.name | |
absdir, filename = os.path.split(path) | |
absdir, pardir = os.path.split(absdir) | |
uptwo = os.path.split(absdir)[1] | |
filename, ext = os.path.splitext(filename) | |
doSeed = True | |
# Put the start of the opposite extension to seed the fuzzy find | |
if ext in headers: | |
filename += ".c" | |
elif ext in impls: | |
filename += ".h" | |
else: | |
# Not a C family file, no initial seed | |
doSeed = False | |
vim.command("let g:ctrlp_default_input = 0") | |
if doSeed: | |
if pardir != "src" and uptwo != "include": | |
filename = os.path.join(pardir, filename) | |
vim.command("let g:ctrlp_default_input = '%s'" % filename) | |
vim.command(":CtrlP") | |
EOF | |
endfunction | |
fun! <SID>StripTrailingWhitespace() | |
set bt = "" # Set buftype="" | |
let l = line(".") | |
let c = col(".") | |
%s/\s\+$//e | |
call cursor(l, c) | |
endfun | |
function Unescape() | |
%s/%22/"/g | |
%s/%23/#/g | |
%s/%26/\&/g | |
%s/%2F/\//g | |
%s/%2C/,/g | |
%s/%3A/:/g | |
%s/%3D/=/g | |
%s/%3F/?/g | |
%s/%5B/[/g | |
%s/%5D/]/g | |
%s/%7B/{/g | |
%s/%7D/}/g | |
%s/%3A/:/g | |
endfunction | |
function Wrap() | |
set wrap | |
set linebreak | |
set nolist | |
endfun | |
" '*' is for all file types | |
autocmd BufWritePre * :call <SID>StripTrailingWhitespace() | |
nnoremap <Leader>g :call FuzzySwitch()<CR> | |
nnoremap <Leader>f :let g:ctrlp_default_input = 0|:CtrlP<CR> | |
nnoremap <Leader>u :call Unescape()<CR> | |
nnoremap <Leader>w :call Wrap()<CR> | |
nnoremap <Leader>r :Eval<CR> | |
nnoremap <Leader>e :%Eval<CR> | |
nnoremap <Leader>v :Vex<CR> | |
nnoremap <Leader>h :Hex<CR> | |
inoremap kj <Esc> | |
inoremap jk <Esc> | |
:map Q <Nop> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment