]> code.delx.au - dotfiles/blob - .vimrc
50b58979cc87855297a352f3e9ff2e0464b29030
[dotfiles] / .vimrc
1 set nocompatible
2 set backspace=indent,eol,start
3
4
5 set backup
6 set backupdir=~/tmp/vimbak
7 set backupcopy=yes
8 silent exec "!mkdir -p ~/tmp/vimbak"
9 silent exec "!find ~/tmp/vimbak -type f -mtime +3 -delete"
10
11
12 syntax on
13 filetype plugin indent on
14
15 " restore position when opening files
16 autocmd BufReadPost *
17 \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
18 \ | exe "normal! g`\""
19 \ | endif
20
21 " don't automatically continue comments on new lines
22 autocmd BufNewFile,BufRead * setlocal formatoptions-=r
23
24
25 " xterm mouse
26 set mouse=a
27
28 " xterm titles
29 set title
30 set t_ts=\e]0;
31 set t_fs=\a
32
33
34 " show useful things on the status line
35 set showmode
36 set showcmd
37 set ruler
38
39 " display as much as possible of the last line, instead of @
40 set display+=lastline
41
42 " matching brackets
43 set showmatch
44
45 " auto-complete should work like bash
46 set wildmode=longest,list
47
48 " show one extra line when scrolling
49 set scrolloff=1
50
51 " decent searching
52 set incsearch
53 set ignorecase
54 set smartcase
55 set hlsearch
56
57
58 " decent indentation
59 set autoindent
60 set copyindent
61 set shiftround
62
63 " spaces over tabs
64 set expandtab
65 set tabstop=8
66 set softtabstop=4
67 set shiftwidth=4
68
69 " single indent for line continuations
70 set cinoptions=+1s
71 set cinoptions=(1s
72 let g:pyindent_open_paren = &sw
73 let g:pyindent_continue = &sw
74 let g:vim_indent_cont = &sw
75
76 " don't allow syntax/sh.vim to change my iskeyword setting
77 let g:sh_noisk=1
78
79 " single space after full stop
80 set nojoinspaces
81
82 " disable octal
83 set nrformats-=octal
84
85
86 nmap <C-n> :next<CR>
87 nmap <C-p> :prev<CR>
88
89 nmap <C-l> :nohlsearch<CR>:redraw!<CR>
90
91 command SudoWrite call SudoWriteFunction()
92
93 map <F8> :call ToggleSpelling()<CR>
94 imap <F8> <C-o>:call ToggleSpelling()<CR>
95 map <F9> :call InvShow()<CR>
96 imap <F9> <C-o>:call InvShow()<CR>
97 map <F10> :call WrapToggle()<CR>
98 imap <F10> <C-o>:call WrapToggle()<CR>
99 map <F11> :call PasteToggle()<CR>
100 imap <F11> <C-o>:call PasteToggle()<CR>
101
102
103 function ToggleSpelling()
104 if !exists("s:spell_check") || s:spell_check == 0
105 echo "Spell check on"
106 let s:spell_check = 1
107 setlocal spell spelllang=en_au
108 else
109 echo "Spell check off"
110 let s:spell_check = 0
111 setlocal spell spelllang=
112 endif
113 endfunction
114
115 function WrapToggle()
116 if &wrap
117 set nowrap
118 echo "Word wrap off"
119 else
120 set wrap
121 echo "Word wrap on"
122 endif
123 endfunction
124
125 function InvShow()
126 if &list
127 echo "Invisible characters off"
128 set nolist
129 else
130 echo "Invisible characters on"
131 set listchars=tab:.\ ,trail:!
132 set list
133 endif
134 endfunction
135
136 function SudoWriteFunction()
137 :w !sudo tee %
138 :e!
139 endfunction
140
141 function PasteToggle()
142 if &paste
143 set nopaste
144 echo "Paste mode disabled"
145 else
146 set paste
147 echo "Paste mode enabled"
148 endif
149 endfunction
150
151
152 " typos
153 command WQA :wqa
154 command WqA :wqa
155 command WQa :wqa
156 command Wqa :wqa
157 command WA :wa
158 command Wa :wa
159 command WQ :wq
160 command Wq :wq
161 command W :w
162 command Wn :wn
163 command WN :wn
164 command Wp :wp
165 command WP :wp
166 command QA :qa
167 command Qa :qa
168 command Q :q
169