Created
August 28, 2018 13:33
-
-
Save jwhett/1e0409904101b23582ec02d9ffb43af6 to your computer and use it in GitHub Desktop.
VIM Config
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
" PEP-8 Additions {{{ | |
" PEP-8 Indentation {{{ | |
" Number of spaces that a pre-existing tab is equal to. | |
" For the amount of space used for a new tab use shiftwidth. | |
au BufRead,BufNewFile *py,*pyw,*.c,*.h set tabstop=4 | |
" This will affect Ctrl-T and 'autoindent'. | |
" Python: 4 spaces | |
" C: tabs (pre-existing files) or 4 spaces (new files) | |
au BufRead,BufNewFile *.py,*pyw,*.c,*.h set shiftwidth=4 | |
au BufRead,BufNewFile *.py,*.pyw set expandtab | |
au BufRead,BufNewFile Makefile* set noexpandtab | |
"}}} | |
" Bad Whitespace {{{ | |
" Use the below highlight group when displaying bad whitespace is desired. | |
highlight BadWhitespace ctermbg=red guibg=red | |
" Display tabs at the beginning of a line in Python mode as bad. | |
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/ | |
" Make trailing whitespace be flagged as bad. | |
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/ | |
" Wrap text after a certain number of characters | |
" Python: 79 | |
" C: 79 | |
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h set textwidth=79 | |
" End Bad Whitespace }}} | |
" Comment Formatting / formatoptions {{{ | |
" Turn off settings in 'formatoptions' relating to comment formatting. | |
" - c : do not automatically insert the comment leader when wrapping based on | |
" 'textwidth' | |
" - o : do not insert the comment leader when using 'o' or 'O' from command mode | |
" - r : do not insert the comment leader when hitting <Enter> in insert mode | |
" Python: not needed | |
" C: prevents insertion of '*' at the beginning of every line in a comment | |
au BufRead,BufNewFile *.c,*.h set formatoptions-=c formatoptions-=o formatoptions-=r | |
" Use UNIX (\n) line endings. | |
" Only used for new files so as to not force existing files to change their | |
" line endings. | |
" Python: yes | |
" C: yes | |
au BufNewFile *.py,*.pyw,*.c,*.h set fileformat=unix | |
" The following section contains suggested settings. While in no way required | |
" to meet coding standards, they are helpful. | |
" Set the default file encoding to UTF-8: ``set encoding=utf-8`` | |
" Puts a marker at the beginning of the file to differentiate between UTF and | |
" UCS encoding (WARNING: can trick shells into thinking a text file is actually | |
" a binary file when executing the text file): ``set bomb`` | |
" For full syntax highlighting: | |
"``let python_highlight_all=1`` | |
"``syntax on`` | |
let python_highlight_all=1 | |
" Vim5 and later versions support syntax highlighting. Uncommenting the | |
" following enables syntax highlighting by default. | |
if has("syntax") | |
syntax on | |
endif | |
" Automatically indent based on file type: ``filetype indent on`` | |
" Keep indentation level from previous line: ``set autoindent`` | |
filetype indent on | |
set autoindent | |
" End Suggestions }}} | |
" End PEP-8 }}} | |
" VIMRC Prefs {{{ | |
au BufRead,BufNewFile .vimrc,vimrc set foldmethod=marker | |
" End VIMRC Prefs }}} | |
" Filetype Prefs {{{ | |
" Java prefs {{{ | |
au BufRead,BufNewFile *.java,*.class set tabstop=4 | |
au BufRead,BufNewFile *.java,*.class set shiftwidth=4 | |
"au BufNewFile *.java,*.class set expandtab | |
" End Java prefs }}} | |
" Haskell prefs {{{ | |
au Bufenter *.hs compiler ghc | |
let g:haddock_browser = "/bin/elinks" | |
" End Haskell prefs }}} | |
" Ruby prefs {{{ | |
au BufRead,BufNewFile *.rb,Rakefile set tabstop=2 | |
au BufRead,BufNewFile *.rb,Rakefile set shiftwidth=2 | |
au BufRead,BufNewFile *.rb,Rakefile set expandtab | |
" }}} | |
" Markdown prefs {{{ | |
au BufRead,BufNewFile *.md set tabstop=2 | |
au BufRead,BufNewFile *.md set shiftwidth=2 | |
au BufRead,BufNewFile *.md set expandtab | |
" }}} | |
" End Filetype Prefs }}} | |
" Default Prefs not met by filetype {{{ | |
" Standard {{{ | |
" use :retab to fix files with tabs already in it | |
"set so=0 <-- This is normal | |
set so=999 | |
set ruler | |
set number | |
set showcmd | |
set wildmenu | |
set hlsearch | |
set incsearch | |
set tabstop=4 | |
set shiftwidth=4 | |
set foldmethod=syntax | |
set expandtab | |
set smarttab | |
set noswapfile | |
set cursorline | |
set modeline | |
set modelines=1 | |
set background=dark | |
colorscheme molokai | |
" Enable spell checking for non-code | |
" set spell spelllang=en_ca | |
"}}} | |
" Stylistic {{{ | |
" Warn beyond 80 Cols | |
" match ErrorMsg '\%>80v.\+' | |
" Tap 'f' in command-mode to display name of the function the cursor is in. | |
fun! ShowFuncName() | |
let lnum = line(".") | |
let col = col(".") | |
echohl ModeMsg | |
echo getline(search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bW')) | |
echohl None | |
call search("\\%" . lnum . "l" . "\\%" . col . "c") | |
endfun | |
map F :call ShowFuncName() <CR> | |
" Show non-printed characters and tabs as arrows | |
set list | |
set listchars=tab:>-,trail:- | |
" Extension specific commands | |
" if has("autocmd") | |
" autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class | |
" autocmd BufRead *.c,*.cc,*.cpp,*fsm*.h,*.java set tabstop=8 | |
" autocmd BufWritePre *.py normal m`:%s/\s\+$//e `` | |
" | |
" " C syntax highlighting for fsm files | |
" autocmd BufNewFile,BufRead *.fsm setf c | |
" endif | |
" | |
" Set vimdiff to ignore whitespace | |
set diffopt+=iwhite | |
"}}} | |
" Abbreviations {{{ | |
iabbrev <expr> PPP getreg('') | |
" }}} | |
" End Defaults }}} | |
" Keybinds {{{ | |
" Leader | |
let mapleader = "," | |
" NNOREMAP {{{ | |
" Open vimrc wherever I am in vsplit | |
nnoremap <leader>ev :vsplit ~/.vimrc<CR> | |
" Source vimrc | |
nnoremap <leader>sv :source ~/.vimrc<CR> | |
" Clear search | |
" nnoremap <leader>cv :let @/ =""<CR> " OLD DON'T DO THIS | |
nnoremap <leader>cv :nohlsearch<CR> | |
" Highlight line for more vis | |
" nnoremap <C-c> :set cursorline!<CR> | |
" NERDtree | |
nnoremap <leader>n :NERDTreeToggle<CR> | |
" missing ZZ and ZQ counterparts: | |
" quick save-buffer and quit-everything | |
nnoremap ZS :w<CR> | |
nnoremap ZX :qa<CR> | |
" Open file under cursor for editing (new buffer) | |
nnoremap <leader>of :execute 'next ' . expand('<cfile>')<CR> | |
" Open file under cursor for editing (new tab) | |
nnoremap <leader>tf :execute 'tabe ' . expand('<cfile>')<CR> | |
" Evaluate VIM command from last yanked line(s) | |
nnoremap <leader>ec :@" | |
"}}} | |
" NMAP {{{ | |
" Buffer nav | |
" Move to the next buffer | |
nmap <leader>bl :bnext<CR> | |
" Move to the previous buffer | |
nmap <leader>bh :bprevious<CR> | |
" Tab Nav | |
" Move to next tab (right) | |
nmap <leader>tl :tabnext<CR> | |
" Move to prev tab (left) | |
nmap <leader>th :tabprevious<CR> | |
" Open new tab | |
nmap <leader>tn :tabnew<CR> | |
" PageDown with SPACE | |
nmap <SPACE> <PageDown> | |
"}}} | |
" MAP {{{ | |
" Use control + (HJKL) to navigate between vim splits | |
map <C-j> <C-W>j<C-W>_ | |
map <C-k> <C-W>k<C-W>_ | |
map <C-h> <C-W>h<C-W>_ | |
map <C-l> <C-W>l<C-W>_ | |
"}}} | |
" ONOREMAP {{{ | |
" Inner parens AKA parameters | |
onoremap in( :<C-u>normal! f(vi(<CR> | |
onoremap ip( :<C-u>normal! F)vi(<CR> | |
"}}} | |
" VNOREMAP {{{ | |
" Visually comment lines | |
vnoremap <silent> # :s/^/#/<cr>:noh<cr> | |
vnoremap <silent> -# :s/^\s*#//<cr>:noh<cr> | |
" }}} | |
" End Keybinds }}} | |
" Template files {{{ | |
autocmd BufNewFile * silent! 0r ~/.vim/templates/%:e.tmpl | |
" End Template files }}} | |
" Plugins {{{ | |
" powerline | |
set laststatus=2 | |
" CtlP | |
let g:ctrlp_map = '<c-p>' | |
let g:ctrlp_cmd = 'CtrlP' | |
let g:ctrlp_working_path_mode = 'c' | |
" UltiSnips | |
" let g:UltiSnipsExpandTrigger = "<tab>" | |
" let g:UltiSnipsJumpForwardTrigger = "<tab>" | |
" let g:UltiSnipsJumpBackwardTrigger = "<s-tab>" | |
" End Plugins }}} | |
" Autocmds {{{ | |
augroup gui_stuff | |
autocmd! | |
autocmd GUIEnter * colorscheme molokai | |
" autocmd GUIEnter * set lines=50 columns=190 | |
autocmd GUIEnter * set lines=50 columns=100 | |
autocmd GUIEnter * set guifont=Inconsolata-dz\ for\ Powerline\ Medium\ 10 | |
augroup END | |
" End Autocmds }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment