X-Git-Url: https://code.delx.au/dotfiles/blobdiff_plain/3bfb6a654b8e7b9f2d91d7d142daf65d9b33af6c..a21efa43c917f62d9ea1b15043aa64bf8b8d4ab4:/.vimrc diff --git a/.vimrc b/.vimrc index 70a119a..50b5897 100644 --- a/.vimrc +++ b/.vimrc @@ -1,21 +1,169 @@ -" Don't try to be like vi set nocompatible +set backspace=indent,eol,start -" Backspace should work across lines -set bs=2 - -" Read files from ~/.vim -source ~/.vim/state.vim -source ~/.vim/display.vim -source ~/.vim/indent.vim -source ~/.vim/macros.vim -source ~/.vim/commenter.vim -source ~/.vim/filetypes.vim -if !filereadable(expand("~/.vim/abbrsout.vim")) - !python ~/.vim/abbrs2vim.py -endif -source ~/.vim/abbrsout.vim -if filereadable(expand("~/.vim/local.vim")) - source ~/.vim/local.vim -endif + +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" + + +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