X-Git-Url: https://code.delx.au/dotfiles/blobdiff_plain/1254fd30fd1ab11c09a132bb3a68b77c925c75fa..9aa30f1959d3a31427d0db425d7bd47641c1829d:/.vimrc diff --git a/.vimrc b/.vimrc index 5da7d0f..50b5897 100644 --- a/.vimrc +++ b/.vimrc @@ -1,20 +1,169 @@ -" Don't try to be like vi set nocompatible +set backspace=indent,eol,start -" Backspace should work across lines -set bs=2 -" Make vim aware of filetypes -filetype plugin on +set backup +set backupdir=~/tmp/vimbak +set backupcopy=yes +silent exec "!mkdir -p ~/tmp/vimbak" +silent exec "!find ~/tmp/vimbak -type f -mtime +3 -delete" -" Read files from ~/.vim -source ~/.vim/backup.vim -source ~/.vim/state.vim -source ~/.vim/display.vim -source ~/.vim/mouse.vim -source ~/.vim/indent.vim -source ~/.vim/search.vim -source ~/.vim/abbrsout.vim -source ~/.vim/commands.vim +syntax on +filetype plugin indent on + +" restore position when opening files +autocmd BufReadPost * + \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit' + \ | exe "normal! g`\"" + \ | endif + +" don't automatically continue comments on new lines +autocmd BufNewFile,BufRead * setlocal formatoptions-=r + + +" xterm mouse +set mouse=a + +" xterm titles +set title +set t_ts=]0; +set t_fs= + + +" show useful things on the status line +set showmode +set showcmd +set ruler + +" display as much as possible of the last line, instead of @ +set display+=lastline + +" matching brackets +set showmatch + +" auto-complete should work like bash +set wildmode=longest,list + +" show one extra line when scrolling +set scrolloff=1 + +" decent searching +set incsearch +set ignorecase +set smartcase +set hlsearch + + +" decent indentation +set autoindent +set copyindent +set shiftround + +" spaces over tabs +set expandtab +set tabstop=8 +set softtabstop=4 +set shiftwidth=4 + +" single indent for line continuations +set cinoptions=+1s +set cinoptions=(1s +let g:pyindent_open_paren = &sw +let g:pyindent_continue = &sw +let g:vim_indent_cont = &sw + +" don't allow syntax/sh.vim to change my iskeyword setting +let g:sh_noisk=1 + +" single space after full stop +set nojoinspaces + +" disable octal +set nrformats-=octal + + +nmap :next +nmap :prev + +nmap :nohlsearch:redraw! + +command SudoWrite call SudoWriteFunction() + +map :call ToggleSpelling() +imap :call ToggleSpelling() +map :call InvShow() +imap :call InvShow() +map :call WrapToggle() +imap :call WrapToggle() +map :call PasteToggle() +imap :call PasteToggle() + + +function ToggleSpelling() + if !exists("s:spell_check") || s:spell_check == 0 + echo "Spell check on" + let s:spell_check = 1 + setlocal spell spelllang=en_au + else + echo "Spell check off" + let s:spell_check = 0 + setlocal spell spelllang= + endif +endfunction + +function WrapToggle() + if &wrap + set nowrap + echo "Word wrap off" + else + set wrap + echo "Word wrap on" + endif +endfunction + +function InvShow() + if &list + echo "Invisible characters off" + set nolist + else + echo "Invisible characters on" + set listchars=tab:.\ ,trail:! + set list + endif +endfunction + +function SudoWriteFunction() + :w !sudo tee % + :e! +endfunction + +function PasteToggle() + if &paste + set nopaste + echo "Paste mode disabled" + else + set paste + echo "Paste mode enabled" + endif +endfunction + + +" typos +command WQA :wqa +command WqA :wqa +command WQa :wqa +command Wqa :wqa +command WA :wa +command Wa :wa +command WQ :wq +command Wq :wq +command W :w +command Wn :wn +command WN :wn +command Wp :wp +command WP :wp +command QA :qa +command Qa :qa +command Q :q