" " Author: Hari Sekhon " Date: 2006-07-01 22:52:16 +0100 (Sat, 01 Jul 2006) " syn on " ============================================================================ " " show all settable option values and their values "set all set ai " autoindent set bg=dark " background set et " expandtab set ic " ignorecase set is " incsearch "set list " visually displays eol, tabs etc so you can always see them set ls=1 " laststatus. Status line 0=off, 1=multi-windows, 2=on set listchars=tab:>-,eol:$,trail:.,extends:# " changes the list characters, makes tabs appear as >--- set ml " modeline. respect the vim: stuff at the stop of files. This doesn't seem to work for me set mls=15 " modelines. Controls how many lines to check for modeline, systems often set this to 0, set nocp " nocompatible set nofen "nofoldenable set nohls " nohlsearch "set nu " number (column on left) set ru " ruler set sm " showmatch. show matching brackets {} set scs " smartcase. switch to case sensitive match if uppercase letter is detected set si " smartindent set smd " showmode set sta " smarttab - make "tab" insert indents instead of tabs at beginning of line set sts=4 " softtabstop. changes tab key to 4 spaces wide. This is the one you need set sw=4 " shiftwidth. number of spaces for indentation, should be the same as tabstop really to make tabs and Shift-> the same width set ts=4 " tabstop set tw=0 " textwidth (stops auto wrapping) set viminfo='100,<1000,s10,h " save <1000 lines in the registers instead of <50 lines between files since otherwise I lose lots of lines when deleting and pasting between files set wrap " line wrapping " reload the buffer when file has changed but buffer has not (useful for go fmt from within vim) set autoread set encoding=utf-8 " The encoding displayed. set fileencoding=utf-8 " The encoding written to file. " add comment to next line when using 'o' in command mode " add comment to next line when using Insert mode set formatoptions+=or " ============================================================================ " "behave mswin be xterm :if has("gui_running") "colorscheme slate colo slate :endif " ============================================================================ " filetype plugin indent on filetype plugin on "filetype off " shows what last set ts, ie .vimrc ":verbose set ts " set scrollbind - in each window then windows will scroll together " ============================================================================ " if has("autocmd") " re-open at last cursor line and center screen on the cursor line "au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif autocmd BufReadPost * \ if line ("'\"") > 0 && line ("'\"") <= line ("$") | \ exe "normal! g`\"" | \ exe "normal! g`\"zz" | \ endif " auto-strip trailing whitespace on write autocmd BufWritePre * %s/\s\+$//e " highlight trailing whitespace " XXX: doesn't work "autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red " this works - not using now we auto-strip trailing whitespace above on write anyway and it feels like this constant on/off highlighting slows things down and wastes energy "autocmd Filetype * match Error /\s\+$/ au BufNewFile,BufRead Makefile set noet au BufNewFile,BufRead *Jenkinsfile* set filetype=groovy au BufNewFile,BufRead LICENSE set tw=80 "au BufRead,BufNewFile perl set ts=4 st=4 "au BufRead,BufNewFile *.pl set ts=4 st=4 "au BufNew,BufRead *.pp set syntax=conf " filetype is better than syntax since it figures out indentation and tab completion etc and the ruby is better than conf since it gives more syntax highlighting au BufNew,BufRead *.pp set filetype=ruby sts=2 sw=2 ts=2 au BufNew,BufRead *.yml set sts=2 sw=2 ts=2 au BufNew,BufRead *.yaml set sts=2 sw=2 ts=2 "au BufNew,BufRead *.rb set filetype=ruby sts=2 sw=2 ts=2 " this will disable "au BufNew,BufRead *.txt set ft= au BufNew,BufRead *.txt hi def link confString NONE augroup filetypedetect au! BufRead,BufNewFile *.hta setfiletype html augroup end au BufNew,BufRead *.py nmap ;l :w:!clear; pylint "%" \| headtail.py au BufNew,BufRead *.pl nmap ;l :w:!clear; perl -I . -tc "%" au BufNew,BufRead *.rb nmap ;l :w:!clear; ruby -c "%" au BufNew,BufRead *.go nmap ;l :w:!clear; go fmt "%" au BufNew,BufRead .bash*,*.sh,*.ksh nmap ;l :w:!clear; shellcheck -Calways "%" \| more -R au BufNew,BufRead *.csv nmap ;l :w:!clear; validate_csv.py "%" au BufNew,BufRead *.cson nmap ;l :w:!clear; validate_cson.py "%" au BufNew,BufRead *.json nmap ;l :w:!clear; validate_json.py "%"; echo; check_json.sh "%" \| more -R au BufNew,BufRead *.ini nmap ;l :w:!clear; validate_ini.py "%"; validate_ini2.py "%" au BufNew,BufRead *.properties nmap ;l :w:!clear; validate_properties.py "%" au BufNew,BufRead *.ldif nmap ;l :w:!clear; validate_ldap_ldif.py "%" au BufNew,BufRead *.toml nmap ;l :w:!clear; validate_toml.py "%" au BufNew,BufRead *.xml nmap ;l :w:!clear; validate_xml.py "%" au BufNew,BufRead *.yml,*.yaml nmap ;l :w:!clear; validate_yaml.py "%" " more specific matches like pom.xml need to come after less specific matches like *.xml as last statement wins au BufNew,BufRead *pom.xml* nmap ;l :w:!clear; mvn validate -f "%" \| more -R au BufNew,BufRead *Makefile* nmap ;l :w:!clear; check_makefile.sh "%" \| more -R au BufNew,BufRead *build.gradle* nmap ;l :w:!clear; gradle -b "%" -m clean build \| more -R au BufNew,BufRead *build.sbt* nmap ;l :w:!clear; cd `dirname "%"` && echo q \| sbt reload "%" \| more -R au BufNew,BufRead *.travis.yml* nmap ;l :w:!clear; travis lint "%" \| more -R au BufNew,BufRead *Dockerfile* nmap ;l :w:!clear; hadolint "%" \| more -R endif " ============================================================================ " "nmap ;c :call Cformat() nmap ;c :,!center.py nmap ;e :,!center.py -s nmap ;d :r !date '+\%F \%T \%z (\%a, \%d \%b \%Y)'kJ nmap ;D :Done nmap ;f :,!fold -w 120 -s \| sed 's/[[:space:]]*$//' "nmap ;h :call Hr() nmap ;h :Hr " this inserts Hr literally "imap :Hr nmap ;j :JHr "nmap ;' :call Sq() " done automatically on write now "nmap ;' :call StripTrailingWhiteSpace() nmap ;' :w :!clear; git diff "%" nmap ;n :n nmap ;p :prev nmap ;q :q nmap ;r :call WriteRun() "nmap ;s :call ToggleSyntax() nmap ;s :,!sqlcase.pl nmap ;u :call HgGitU() nmap ;; :call HgGitU() nmap ;w :w "nmap ;x :x " ============================================================================ " function! ToggleSyntax() if exists("g:syntax_on") syntax off else syntax enable endif endfunction ":command Hr :normal i # ============================================================================ #lx :command Hr :normal a# 76a=a # ":function Hr() ":s/^/# ============================================================================ #/ "if b:current_syntax eq "sql" " ::normal a-- 74a=a -- "else ":normal a# 76a=a # "endif ":endfunction ":function Br() ":call Hr() ":endfunction :command Br :Hr "function JHr() " s,^,// ========================================================================== //, "endfunction ":command JHr :normal a// ========================================================================== //lx :command JHr :normal a// 74a=a // :command Done :normal 37a=a DONE 37a= ":function RemoveIPs() " : %s/\d\+\.\d\+\.\d\+\.\d\+//gc ":endfunction " ":function RemoveMacs() " : %s/\w\w:\w\w:\w\w:\w\w:\w\w:\w\w//gc ":endfunction " ":function RemoveDomains() " : %s/company1//gci " : %s/company2//gci ":endfunction function Scrub() ": call RemoveIPs() ": call RemoveMacs() ": call RemoveDomains() :%!anonymize.py --all endfunction " StripQuotes() function Sq() :s/["']//g endfunction function StripTrailingWhiteSpace() :%s/[[:space:]]*$// endfunction function WriteRun() :w :!./% " TODO: if .go then 'go run %' endfunction " ============================================================================ " " either works, requires expand() "let MYLOCALVIMRC = "~/.vimrc.local" "let MYLOCALVIMRC = "$HOME/.vimrc.local" " Function to source only if file exists { function! SourceIfExists(file) if filereadable(expand(a:file)) exe 'source' a:file endif endfunction " } call SourceIfExists("~/.vimrc.local") call SourceIfExists("~/.vim/colors.vim") if has('gui_running') call SourceIfExists("~/.gvimrc.local") endif