Created
August 23, 2018 17:08
-
-
Save Resisty/2c58112835213f9238ef4fee2bbf100e to your computer and use it in GitHub Desktop.
Increasingly large (and maybe shitty) .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
" vimrc file for following the coding standards specified in PEP 7 & 8. | |
" | |
" 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. | |
execute pathogen#infect() | |
set clipboard=unnamed | |
autocmd bufnewfile *.html so ~/code_headers/html_header.txt | |
autocmd bufnewfile *.html exe "1," . 10 . "g/File Name :.*/s//File Name : " .expand("%") | |
autocmd bufnewfile *.html exe "1," . 10 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%Y") | |
autocmd Bufwritepre,filewritepre *.html execute "normal ma" | |
autocmd Bufwritepre,filewritepre *.html exe "1," . 10 . "g/Last Modified :.*/s/Last Modified :.*/Last Modified : " .strftime("%c") | |
autocmd bufwritepost,filewritepost *.html execute "normal `a" | |
autocmd bufnewfile *.js so ~/code_headers/js_header.txt | |
autocmd bufnewfile *.js exe "1," . 10 . "g/File Name :.*/s//File Name : " .expand("%") | |
autocmd bufnewfile *.js exe "1," . 10 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%Y") | |
autocmd Bufwritepre,filewritepre *.js execute "normal ma" | |
autocmd Bufwritepre,filewritepre *.js exe "1," . 10 . "g/Last Modified :.*/s/Last Modified :.*/Last Modified : " .strftime("%c") | |
autocmd bufwritepost,filewritepost *.js execute "normal `a" | |
autocmd bufnewfile *.perl so ~/code_headers/perl_header.txt | |
autocmd bufnewfile *.perl exe "1," . 10 . "g/File Name :.*/s//File Name : " .expand("%") | |
autocmd bufnewfile *.perl exe "1," . 10 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%Y") | |
autocmd Bufwritepre,filewritepre *.perl execute "normal ma" | |
autocmd Bufwritepre,filewritepre *.perl exe "1," . 10 . "g/Last Modified :.*/s/Last Modified :.*/Last Modified : " .strftime("%c") | |
autocmd bufwritepost,filewritepost *.perl execute "normal `a" | |
autocmd bufnewfile *.cpp so ~/code_headers/cpp_header.txt | |
autocmd bufnewfile *.cpp exe "1," . 10 . "g/File Name :.*/s//File Name : " .expand("%") | |
autocmd bufnewfile *.cpp exe "1," . 10 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%Y") | |
autocmd Bufwritepre,filewritepre *.cpp execute "normal ma" | |
autocmd Bufwritepre,filewritepre *.cpp exe "1," . 10 . "g/Last Modified :.*/s/Last Modified :.*/Last Modified : " .strftime("%c") | |
autocmd bufwritepost,filewritepost *.cpp execute "normal `a" | |
autocmd bufnewfile *.c so ~/code_headers/c_header.txt | |
autocmd bufnewfile *.c exe "1," . 10 . "g/File Name :.*/s//File Name : " .expand("%") | |
autocmd bufnewfile *.c exe "1," . 10 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%Y") | |
autocmd Bufwritepre,filewritepre *.c execute "normal ma" | |
autocmd Bufwritepre,filewritepre *.c exe "1," . 10 . "g/Last Modified :.*/s/Last Modified :.*/Last Modified : " .strftime("%c") | |
autocmd bufwritepost,filewritepost *.c execute "normal `a" | |
autocmd bufnewfile *.pp so ~/code_headers/pp_header.txt | |
autocmd Bufwritepre,filewritepre *.pp execute "normal ma" | |
autocmd bufwritepost,filewritepost *.pp execute "normal `a" | |
autocmd bufnewfile *_spec.rb so ~/code_headers/spec_header.txt | |
autocmd Bufwritepre,filewritepre *_spec.rb execute "normal ma" | |
autocmd bufwritepost,filewritepost *_spec.rb execute "normal `a" | |
autocmd bufnewfile *.sml so ~/code_headers/sml_header.txt | |
autocmd bufnewfile *.sml exe "1," . 10 . "g/File Name :.*/s//File Name : " .expand("%") | |
autocmd bufnewfile *.sml exe "1," . 10 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%Y") | |
autocmd Bufwritepre,filewritepre *.sml execute "normal ma" | |
autocmd Bufwritepre,filewritepre *.sml exe "1," . 10 . "g/Last Modified :.*/s/Last Modified :.*/Last Modified : " .strftime("%c") | |
autocmd bufwritepost,filewritepost *.sml execute "normal `a" | |
autocmd bufnewfile *.pl so ~/code_headers/pl_header.txt | |
autocmd bufnewfile *.pl exe "1," . 10 . "g/File Name :.*/s//File Name : " .expand("%") | |
autocmd bufnewfile *.pl exe "1," . 10 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%Y") | |
autocmd Bufwritepre,filewritepre *.pl execute "normal ma" | |
autocmd Bufwritepre,filewritepre *.pl exe "1," . 10 . "g/Last Modified :.*/s/Last Modified :.*/Last Modified : " .strftime("%c") | |
autocmd bufwritepost,filewritepost *.pl execute "normal `a" | |
autocmd bufnewfile *.notes so ~/code_headers/notes_header.txt | |
autocmd bufnewfile *.notes exe "1," . 10 . "g/File Name :.*/s//File Name : " .expand("%") | |
autocmd bufnewfile *.notes exe "1," . 10 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%Y") | |
autocmd Bufwritepre,filewritepre *.notes execute "normal ma" | |
autocmd Bufwritepre,filewritepre *.notes exe "1," . 10 . "g/Last Modified :.*/s/Last Modified :.*/Last Modified : " .strftime("%c") | |
autocmd bufwritepost,filewritepost *.sml execute "normal `a" | |
" Number of spaces to use for an indent. | |
" This will affect Ctrl-T and 'autoindent'. | |
" Python: 4 spaces | |
" Perl: 4 spaces | |
" CGI: 4 spaces | |
" C: 8 spaces (pre-existing files) or 4 spaces (new files) | |
" Go: 4 spaces | |
au BufRead,BufNewFile *.pl,*.plx,*.cgi,*.py,*pyw,*.go,*.js set shiftwidth=4 | |
au BufRead,BufNewFile *.java,*.c,*.h,*.lisp,*.notes,*.js,*.html set shiftwidth=4 | |
au BufRead,BufNewFile *.pp,*.rb,*.bash,*.sh,*.tf,*.yaml,*.yml set shiftwidth=2 | |
"au BufNewFile *.c,*.h set shiftwidth=4 | |
" C: 8 spaces always! | |
au BufRead,BufNewFile *.tex,*.notes set textwidth=100 | |
au BufRead,BufNewFile *.plx,*.pl,*.cgi,*py,*pyw,*.scm,*.c,*.h,*.lisp,*.bash,*.sh,*.java,*.pp,*.rb,*.go,*.js,*.yaml,*.yml set textwidth=80 | |
" Number of spaces that a pre-existing tab is equal to. | |
" For the amount of space used for a new tab use shiftwidth. | |
" Python: 4 | |
" C: 4 | |
" Perl: 4 | |
" CGI: 4 | |
au BufRead,BufNewFile *.plx,*.pl,*.cgi,*py,*pyw,*.scm,*.c,*.h,*.lisp,*.bash,*.sh,*.java,*.notes,*.go,*.js set tabstop=4 | |
au BufRead,BufNewFile *.pp,*.rb,*.tf,*.yaml,*.yml set tabstop=2 | |
" Replace tabs with the equivalent number of spaces. | |
" Also have an autocmd for Makefiles since they require hard tabs. | |
" Python: yes | |
" Perl: yes | |
" CGI: yes | |
" C: no | |
" Makefile: no | |
" Go: yes | |
au BufRead,BufNewFile *.pp,*.rb,*.pl,*.plx,*.cgi,*.py,*.pyw,*.go,*.js,*.yaml,*.yml set expandtab | |
au BufRead,BufNewFile *.c,*.h,*.java,*.scm,*.notes set noexpandtab | |
au BufRead,BufNewFile Makefile* set noexpandtab | |
au BufRead,BufNewFile *.txt,*.bash,*.sh,*.lisp,*.tf set expandtab | |
" control how many columns vim uses when you hit Tab in insert mode. | |
" Python: yes | |
" Perl: yes | |
" CGI: yes | |
" C: no | |
" Makefile: no | |
" Go: yes | |
au BufRead,BufNewFile *.pp,*.rb,*.pl,*.plx,*.cgi,*.py,*.pyw,*.go,*.js,*.tf,*.yaml,*.yml set softtabstop=2 | |
au BufRead,BufNewFile *.c,*.h,*.java,*.scm,*.notes set softtabstop=4 | |
au BufRead,BufNewFile Makefile* set softtabstop=4 | |
au BufRead,BufNewFile *.txt,*.bash,*.sh,*.lisp set softtabstop=4 | |
" Use the below highlight group when displaying bad whitespace is desired | |
highlight BadWhiteSpace ctermfg=red | |
highlight LineNr ctermfg=black | |
highlight Statement ctermfg=grey | |
" Display tabs at the beginning of a line in Python mode as bad. | |
au BufRead,BufNewFile *.py,*.pyw,*.go,*.js,*.tf match BadWhitespace /^\t\+/ | |
" Make trailing whitespace be flagged as bad. | |
au BufRead,BufNewFile *.py,*.pyw,*.h,*.go,*.js,*.tf match BadWhitespace /\s\+$/ | |
" Wrap text after a certain number of characters | |
" Python: 79 | |
" C: 79 | |
" Go: 79 | |
au BufRead,BufNewFile *.py,*.pyw,*.go,*.js set textwidth=79 | |
" C: Removed the text wrapping | |
" 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 | |
" Go: yes | |
au BufNewFile *.py,*.pyw,*.c,*.h,*.java,*.bash,*.sh,*.go,*.js,*.yaml,*.yml set fileformat=unix | |
" Turn the damn ruler on | |
au BufRead,BufNewFile * set ruler | |
map ,c :!pdflatex % <CR> | |
map ,b :!bibtex %< <CR> | |
map ,p :!open %<.pdf <CR> | |
map ,pl :!perl % <CR> | |
"map ,j | |
" ---------------------------------------------------------------------------- | |
" 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`` | |
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 | |
syntax on | |
highlight Statement ctermfg=5 | |
" Automatically indent based on file type: ``filetype indent on`` | |
" Keep indentation level from previous line: ``set autoindent`` | |
filetype on | |
filetype indent on | |
filetype plugin on | |
filetype plugin indent on | |
set autoindent | |
" Folding based on indentation: ``set foldmethod=indent`` | |
"set foldmethod=indent | |
au BufRead,BufNewFile *.hs,*.c,*.h,*,java,*.py,*.pyw,*.scm,*.txt,*.cpp,*.bash,*.sh,*.lisp,*.js,*.yaml,*.yml set number | |
if &term == "linux" | |
set t_kb= | |
fixdel | |
endif | |
set shell=/bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment