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