Created
June 28, 2020 00:18
-
-
Save jacoby/1a67aa9166d62ef5ee210813001961ee to your computer and use it in GitHub Desktop.
Dave's .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
" Dave Jacoby - 2011-02-13 | |
" | |
" A key to .vimrc happiness is to have an alias like | |
" alias vimrc="vi ~/.vimrc" | |
" in your .alias file or .bashrc or whatever, so, should you have | |
" a tweak to add or disable, you just go in and tweak it. Just | |
" a little pessimization removal | |
" | |
" Also, it is good to have the long version of settings in your | |
" configuration, so you have the best chance of reading and | |
" understanding what it does. "se nu" is less understandable than | |
" "set numbers" | |
" double-quotes are comments | |
"" http://mislav.uniqpath.com/2011/12/vim-revisited/ | |
set nocompatible " choose no compatibility with legacy vi | |
syntax enable " enable syntax highlighting | |
"colorscheme nature | |
colorscheme ironman | |
set encoding=utf-8 | |
set report=0 " always display count of lines | |
" yanked or deleted | |
set showcmd " display incomplete commands | |
filetype plugin on " load file type plugins + indentation | |
filetype indent on " load file type plugins + indentation | |
"" Whitespace | |
set nowrap " don't wrap lines | |
set tabstop=4 shiftwidth=4 " a tab is two spaces (or set this to 4) | |
set expandtab " use spaces, not tabs (optional) | |
set backspace=indent,eol,start " backspace through everything in insert mode | |
"" Searching | |
set hlsearch " highlight matches | |
set incsearch " incremental searching | |
set ignorecase " searches are case insensitive... | |
set smartcase " ... unless they contain at least one capital letter | |
filetype on " determines what file type a file is | |
filetype plugin on " loads plugin for detected file type | |
set wildmode=list:longest,list:full | |
"" Turn off backups | |
set nobackup | |
set nowb | |
set noswapfile | |
set autoread " watch for file changes from other editors | |
set autowrite " writes to the current buffer automatically | |
set backspace=2 " make backspace work like others | |
set complete+=k~/.vim_extras/installed_perl_modules | |
set confirm " confirm rather than error if file not saved | |
set history=700 " number of lines of history VIM remembers | |
set incsearch " turn on incremental searches | |
set nohlsearch " turn off search highlighting | |
set iskeyword+=: | |
set magic " use regular expressions | |
set showmatch " show matching brackets | |
set mat=5 " 10ths of second blink when matching brackets | |
"set mouse=a " allow mouse integration | |
set noerrorbells " no auditory indication of error | |
set novisualbell " no visual indication of error | |
set scrolloff=5 " cursor is five rows from edge of screen | |
set sidescrolloff=5 " cursor is five columns from edge of screen | |
set tags=tags;/ | |
set cmdheight=2 " add second line for commands at bottom | |
"PBP-suggested VIM additions | |
"set autoindent | |
set background=dark | |
set backspace=indent,eol,start | |
set expandtab | |
set ffs=unix,mac,dos | |
set matchpairs+=<:> | |
set number " show line numbers | |
set ruler " show current position | |
set shiftround | |
set shiftwidth=4 | |
set smartindent | |
set smarttab | |
set tabstop=4 | |
" ENFORCE 80 column width | |
"set textwidth=78 | |
"set colorcolumn=79 | |
highlight ColorColumn ctermbg=red | |
"call matchadd('ColorColumn', '\%79v', 100) | |
syntax on | |
" --------- --------- --------- --------- --------- --------- | |
" taken from Damian Conway's OSCon 2013 vim talk | |
"====[ Swap : and ; to make colon commands easier to type ]====== | |
" nnoremap ; : | |
" nnoremap : ; | |
" This rewires n and N to do the highlighing... | |
nnoremap <silent> n n:call HLNext(0.4)<cr> | |
nnoremap <silent> N N:call HLNext(0.4)<cr> | |
" EITHER blink the line containing the match... | |
" function! HLNext (blinktime) | |
" set invcursorline | |
" redraw | |
" exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm' | |
" set invcursorline | |
" redraw | |
" endfunction | |
" OR ELSE briefly hide everything except the match... | |
function! HLNext (blinktime) | |
highlight BlackOnBlack ctermfg=black ctermbg=black | |
let [bufnum, lnum, col, off] = getpos('.') | |
let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/)) | |
let hide_pat = '\%<'.lnum.'l.' | |
\ . '\|' | |
\ . '\%'.lnum.'l\%<'.col.'v.' | |
\ . '\|' | |
\ . '\%'.lnum.'l\%>'.(col+matchlen-1).'v.' | |
\ . '\|' | |
\ . '\%>'.lnum.'l.' | |
let ring = matchadd('BlackOnBlack', hide_pat, 101) | |
redraw | |
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm' | |
call matchdelete(ring) | |
redraw | |
endfunction | |
"====[ Open any file with a pre-existing swapfile in readonly mode "]========= | |
augroup NoSimultaneousEdits | |
autocmd! | |
autocmd SwapExists * let v:swapchoice = 'o' | |
autocmd SwapExists * echomsg ErrorMsg | |
autocmd SwapExists * echo 'Duplicate edit session (readonly)' | |
autocmd SwapExists * echohl None | |
autocmd SwapExists * sleep 2 | |
augroup END | |
" moving blocks with the dragvisuals.vim plugin | |
vmap <expr> <S-LEFT> DVB_Drag('left') | |
vmap <expr> <S-RIGHT> DVB_Drag('right') | |
vmap <expr> <S-DOWN> DVB_Drag('down') | |
vmap <expr> <S-UP> DVB_Drag('up') | |
" ctags | |
"set tags+=tags;$HOME | |
" --------- --------- --------- --------- --------- --------- | |
" mapped commands | |
"Insert Date | |
imap <silent> <C-D><C-D> <C-R>=strftime("%e %b %Y")<CR> | |
"Insert Time | |
imap <silent> <C-T><C-T> <C-R>=strftime("%l:%M %p")<CR> | |
map ,pt <Esc>:%! perltidy -q <CR> | |
"map ,ff :call g:Jsbeautify() "jsbeautifier | |
"Mamchenkov-suggested VIM additions | |
"set list | |
"map <F3> :Tlist<CR> | |
" Use perl compiler for all *.pl and *.pm files. | |
"autocmd BufNewFile,BufRead *.p? compiler perl | |
if has("autocmd") | |
"autocmd FileTYpe perl match ErrorMsg '\%>80v.\+' " highlight long lines | |
"autocmd BufEnter *.pl :%s/\s\+$//e | |
"autocmd BufEnter *.pl :%s/[ \t\r]\+$//e | |
autocmd BufRead *.pl,*t set filetype=perl | |
autocmd BufWritePost *.pl !chmod +x % | |
"autocmd BufWritePre *.pl :%s/\s\+$//e | |
endif | |
" VIMscript | |
function! ToggleSyntax() "Toggle Syntax Highlighting | |
if exists("g:syntax_on") | |
syntax off "Not 'syntax clear' (which does something else) | |
else | |
syntax enable "Not 'syntax on' (which overrides colorscheme) | |
endif | |
endfunction | |
nmap <silent> ;s :call ToggleSyntax()<CR> | |
nmap j gj | |
nmap k gk | |
let vimrplugin_screenplugin = 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment