summaryrefslogtreecommitdiffstats
path: root/.vimrc
blob: d0e4c178dd4407bf78a7ac2687f44f027586691e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
" bnewbold's .vimrc
" circa 2006-2010

" enable plugins
:filetype plugin on

if has('syntax') && (&t_Co > 2)
    syntax on
endif

set history=50
set wildmode=list:longest,full
set showmode
set showcmd
set shiftwidth=2
set tabstop=2
autocmd FileType * set tabstop=2|set shiftwidth=2
autocmd FileType python set tabstop=4|set shiftwidth=4
set expandtab
set shiftround
set autoindent
set hidden          " allows modified buffers to be hidden

" vtreeexplore
let treeExplVertical=1
let treeExplWinSize=30
let treeExplDirSort=1
let treeExplNoList=0
"nmap <F2> :VTreeExplore<cr>
nmap <F2> :Explore<cr>
"let g:buftabs_in_statusline=1
"let g:buftabs_only_basename=1
"let g:buftabs_active_highlight_group="Visual"

" a more readbly vertical split
hi VertSplit cterm=none ctermfg=LightGray term=none gui=none

" firefox style ctrl-tabbing with buffers; doesn't work in xterm
noremap <C-tab> :bprev<CR> 
noremap <C-S-tab> :bnext<CR> 
" needed for in xterm with remaping... ugh.
nmap <Esc>[27;6;9~ :bprev<CR> 
nmap <Esc>[27;5;9~ :bnext<CR>
map <Esc>[27;6;9~ :bprev<CR>
map <Esc>[27;5;9~ :bnext<CR>

" and for tabbing around
nmap <C-left> :tabN<CR>
nmap <C-right> :tabn<CR>
map <C-left> :tabN<CR>
map <C-right> :tabn<CR>

" and between windows
noremap <A-h> <C-w>h<CR>
noremap <A-j> <C-w>j<CR>
noremap <A-k> <C-w>k<CR>
noremap <A-l> <C-w>l<CR>

" Searching stuff
set incsearch
set ignorecase
set smartcase

" this allows the arrow keys to do screen lines instead of file lines
" (srapped)
noremap <Up> gk
noremap <Down> gj

autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class

" for Project Fortress
au BufNewFile,BufRead *.fsi,*.fss set ft=fortress

" for previewing reStructured text (.rst) in firefox
:command! Rst :!rst2html.py "%" > /tmp/rstprev.html && firefox file:///tmp/rstprev.html
:nnoremap <C-p><C-r> :Rst<CR>

cnoremap <C-A>  <Home>
cnoremap <C-E>  <End>
cnoremap <C-K>  <C-E><C-U>
cnoremap <C-F>  <Right>
cnoremap <C-B>  <Left>

" for encrypted files
set backupskip+=*.gpg
augroup encrypted
    au!
    " First make sure nothing is written to ~/.viminfo while editing
    " an encrypted file.
    autocmd BufReadPre,FileReadPre      *.gpg set viminfo=
    " We don't want a swap file, as it writes unencrypted data to disk
    autocmd BufReadPre,FileReadPre      *.gpg set noswapfile
    " Switch to binary mode to read the encrypted file
    autocmd BufReadPre,FileReadPre      *.gpg set bin
    autocmd BufReadPre,FileReadPre      *.gpg let ch_save = &ch|set ch=2
    autocmd BufReadPre,FileReadPre      *.gpg let shsave=&sh
    autocmd BufReadPre,FileReadPre      *.gpg let &sh='sh'
    autocmd BufReadPre,FileReadPre      *.gpg let ch_save = &ch|set ch=2
    autocmd BufReadPost,FileReadPost    *.gpg '[,']!gpg --decrypt --default-recipient-self 2> /dev/null
    autocmd BufReadPost,FileReadPost    *.gpg let &sh=shsave
    " Switch to normal mode for editing
    autocmd BufReadPost,FileReadPost    *.gpg set nobin
    autocmd BufReadPost,FileReadPost    *.gpg let &ch = ch_save|unlet ch_save
    autocmd BufReadPost,FileReadPost    *.gpg execute ":doautocmd BufReadPost " . expand("%:r")
    " Convert all text to encrypted text before writing
    autocmd BufWritePre,FileWritePre    *.gpg set bin
    autocmd BufWritePre,FileWritePre    *.gpg let shsave=&sh
    autocmd BufWritePre,FileWritePre    *.gpg let &sh='sh'
    autocmd BufWritePre,FileWritePre    *.gpg '[,']!gpg -q -c 2>/dev/null
    autocmd BufWritePre,FileWritePre    *.gpg let &sh=shsave
    " Undo the encryption so we are back in the normal text, directly
    " after the file has been written.
    autocmd BufWritePost,FileWritePost  *.gpg silent u
    autocmd BufWritePost,FileWritePost  *.gpg set nobin
augroup END