Skip to content

Instantly share code, notes, and snippets.

@andrewbolster
Created October 20, 2015 09:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewbolster/913b3c04e4fb71ae4b17 to your computer and use it in GitHub Desktop.
Save andrewbolster/913b3c04e4fb71ae4b17 to your computer and use it in GitHub Desktop.
My Fucked VIMrc
" Pathogen : https://github.com/tpope/vim-pathogen
execute pathogen#infect()
set nocompatible " be iMproved
filetype off " required!
" Setting up Vundle - the vim plugin bundler
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
let iCanHazVundle=0
endif
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
"Add your bundles here
" "uber awesome syntax and errors highlighter
Bundle 'Syntastic'
"...All your other bundles...
" My Bundles here:
"
" original repos on github
Bundle 'altercation/vim-colors-solarized'
Bundle 'gmarik/vundle'
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle 'tpope/vim-rails.git'
Bundle 'scrooloose/nerdtree.git'
Bundle 'aperezdc/vim-template.git'
" vim-scripts repos
Bundle 'L9'
Bundle 'FuzzyFinder'
" non github repos
" Bundle 'git://git.wincent.com/command-t.git'
" git repos on your local machine (ie. when working on your own plugin)
" Bundle 'file:///Users/gmarik/path/to/plugin'
" Bundle 'Valloric/YouCompleteMe'
"
" VIM LESS Handling
Bundle 'groenewege/vim-less'
"
" ...
if iCanHazVundle == 0
echo "Installing Bundles, please ignore key map error messages"
echo ""
:BundleInstall
endif
" Setting up Vundle - the vim plugin bundler end
filetype plugin indent on " required!
"
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..
"""""""""""""""
"" Spellchecking
""""""""""""""
if v:version >= 700
"Sets in-line spellchecking
"set spell
" Set local language
setlocal spell spelllang=en_gb
"setlocal spell spelllang=da
endif
set nospell
"#Mostly stolen from jmcpherson.org/vimrc.html
set nocompatible
set expandtab
set smarttab
set foldenable
set foldlevel=10
set mouse+=a
if &term =~ '^screen'
" tmux knows the extended mouse mode from
" http://superuser.com/questions/549930/cant-resize-vim-splits-inside-tmux
set ttymouse=xterm2
endif
set tabstop=2
set shiftwidth=2
set softtabstop=2
set ruler
set wildmenu
set showmatch
map <C-V> "+gP
cmap <C-V> <C-R>+
vnoremap <C-C> "+y
set guioptions-=T
set vb t_vb=
set ruler
set incsearch
set fo+=w
syntax on
" vimrc file for following the coding standards specified in PEP 8 & 9.
"
" To use this file, source it in your own personal .vimrc file (``source
" <filename>``) or, if you don't have a .vimrc file, you can just symlink to it
" (``ln -s <this file> ~/.vimrc``). All options are protected by autocmds
" (read below for an explanation of the command) so blind sourcing of this file
" is safe and will not affect your settings for non-Python or non-C files.
"
"
" All setting are protected by 'au' ('autocmd') statements. Only files ending
" in .py or .pyw will trigger the Python settings while files ending in *.c or
" *.h will trigger the C settings. This makes the file "safe" in terms of only
" adjusting settings for Python and C files.
"
" Only basic settings needed to enforce the style guidelines are set.
" Some suggested options are listed but commented out at the end of this file.
" 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,*.cpp,*.h set tabstop=4
au BufRead,BufNewFile *.txt,*.rtf set spell
" What to use for an indent.
" 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 set shiftwidth=4
au BufRead,BufNewFile *.py,*.pyw set expandtab
fu Select_c_style()
if search('^\t', 'n', 150)
set shiftwidth=4
set noexpandtab
el
set shiftwidth=4
set expandtab
en
endf
au BufRead,BufNewFile *.c,*.h,*.cpp call Select_c_style()
au BufRead,BufNewFile Makefile* set noexpandtab
" 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,*.cpp match BadWhitespace /\s\+$/
" 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,*.cu,*.cpp,*.h set formatoptions-=c formatoptions-=o formatoptions-=r filetype=cpp
" 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,*.cu,*.cpp,*.h set fileformat=unix
" Markdown
au BufRead,BufNewFile *.md set filetype=markdown
" Octave syntax
au BufRead,BufNewFile *.m,*.oct set filetype=octave
au BufNewFile,BufRead *.m setf octave
au BufNewFile,BufRead *.m set syntax=matlab
" Use keywords from Octave syntax language file for autocomplete
if has("autocmd") && exists("+omnifunc")
autocmd Filetype octave
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif
" ----------------------------------------------------------------------------
" 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
" Folding based on indentation:
set foldmethod=indent
" Mouse Use
set mouse=a
" Turn on line numbers:
set number
" Toggle line numbers and fold column for easy copying:
nnoremap <F2> :set nonumber!<CR>:set foldcolumn=0<CR>
let g:Tex_Folding=0
"I don't like folding.
set iskeyword+=:
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.
filetype plugin on
" IMPORTANT: win32 users will need to have 'shellslash' set so that latex
" can be called correctly.
set shellslash
" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*
" OPTIONAL: This enables automatic indentation as you type.
filetype indent on
" Automatically indent based on file type:
filetype plugin indent on
" Keep indentation level from previous line:
set autoindent
" Per-Word Linebreaking
set linebreak
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
" Minibuf stuff
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
" Omnifunc
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType cpp set omnifunc=omni#cpp#complete#Main
autocmd FileType c set omnifunc=ccomplete#Complete
" configure tags - add additional tags here or comment out not-used ones
set tags+=~/.vim/tags/cpp_files
set tags+=~/.vim/tags/cpp_src/
set tags+=~/.vim/tags/qt
" build tags of your own project with Ctrl-F12
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
" Tlist
map P :TlistToggle<CR>
map T :TaskList<CR>
let Tlist_Use_Right_Window = 1
" NerdTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
map <C-n> :NERDTreeToggle<CR>`
"let g:NERDTreeWinPos = "right"
" Generate tags with: ctags -R -f ~/.vim/tags/python24.ctags
" /usr/lib/python2.4/
" " ctrl-[ to go to the tag under the cursor, ctrl-T to go back.
set tags+=$HOME/.vim/tags/python24.ctags
" Use :make to see syntax errors. (:cn and :cp to move around, :dist to see
" all errors)
set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
" Change the max line length for PEP8 checking
let g:flake8_max_line_length=99
" Color Scheme Selection
colorscheme github
" Cursor Highlighting on insert mode
" http://stackoverflow.com/questions/6158860/change-color-of-cursor-in-vim
au InsertLeave * hi Cursor guibg=red
au InsertEnter * hi Cursor guibg=green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment