]> code.delx.au - dotfiles/blob - .vimrc
816546d5a2ce64fd3dc1929484f1d4d62b8400e6
[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 " filename (~/some/dir) (1 of 2) (hostname)
31 set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:p:~:h\")})%)%(\ %a%)\ (%{hostname()})
32 set t_ts=\e]0;
33 set t_fs=\a
34
35
36 " show useful things on the status line
37 set showmode
38 set showcmd
39 set ruler
40
41 " display as much as possible of the last line, instead of @
42 set display+=lastline
43
44 " matching brackets
45 set showmatch
46
47 " auto-complete should work like bash
48 set wildmode=longest,list
49
50 " show one extra line when scrolling
51 set scrolloff=1
52
53 " decent searching
54 set incsearch
55 set ignorecase
56 set smartcase
57 set hlsearch
58
59
60 " decent indentation
61 set autoindent
62 set copyindent
63 set shiftround
64
65 " spaces over tabs
66 set expandtab
67 set tabstop=8
68 set softtabstop=4
69 set shiftwidth=4
70
71 " single indent for line continuations
72 set cinoptions=+1s
73 set cinoptions=(1s
74 let g:pyindent_open_paren = &sw
75 let g:pyindent_continue = &sw
76 let g:vim_indent_cont = &sw
77
78 " don't allow syntax/sh.vim to change my iskeyword setting
79 let g:sh_noisk=1
80
81 " single space after full stop
82 set nojoinspaces
83
84 " disable octal
85 set nrformats-=octal
86
87
88 nmap <C-n> :next<CR>
89 nmap <C-p> :prev<CR>
90
91 nmap <C-l> :nohlsearch<CR>:redraw!<CR>
92
93 command SudoWrite call SudoWriteFunction()
94
95 map <F8> :call ToggleSpelling()<CR>
96 imap <F8> <C-o>:call ToggleSpelling()<CR>
97 map <F9> :call InvShow()<CR>
98 imap <F9> <C-o>:call InvShow()<CR>
99 map <F10> :call WrapToggle()<CR>
100 imap <F10> <C-o>:call WrapToggle()<CR>
101 map <F11> :call PasteToggle()<CR>
102 imap <F11> <C-o>:call PasteToggle()<CR>
103
104
105 function ToggleSpelling()
106 if !exists("s:spell_check") || s:spell_check == 0
107 echo "Spell check on"
108 let s:spell_check = 1
109 setlocal spell spelllang=en_au
110 else
111 echo "Spell check off"
112 let s:spell_check = 0
113 setlocal spell spelllang=
114 endif
115 endfunction
116
117 function WrapToggle()
118 if &wrap
119 set nowrap
120 echo "Word wrap off"
121 else
122 set wrap
123 echo "Word wrap on"
124 endif
125 endfunction
126
127 function InvShow()
128 if &list
129 echo "Invisible characters off"
130 set nolist
131 else
132 echo "Invisible characters on"
133 set listchars=tab:.\ ,trail:!
134 set list
135 endif
136 endfunction
137
138 function SudoWriteFunction()
139 :w !sudo tee %
140 :e!
141 endfunction
142
143 function PasteToggle()
144 if &paste
145 set nopaste
146 echo "Paste mode disabled"
147 else
148 set paste
149 echo "Paste mode enabled"
150 endif
151 endfunction
152
153
154 " typos
155 command WQA :wqa
156 command WqA :wqa
157 command WQa :wqa
158 command Wqa :wqa
159 command WA :wa
160 command Wa :wa
161 command WQ :wq
162 command Wq :wq
163 command W :w
164 command Wn :wn
165 command WN :wn
166 command Wp :wp
167 command WP :wp
168 command QA :qa
169 command Qa :qa
170 command Q :q
171