-
Notifications
You must be signed in to change notification settings - Fork 3
/
.vimrc
161 lines (116 loc) · 5.66 KB
/
.vimrc
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
" prototype ~/.vimrc
"
" This tries to take Vim as close to common defaults as possible.
" explicity set nocompatible so it's always set, even if you're invoking
" like `vim -u this/vimrc file-to-edit`
set nocompatible
" to worry about:
filetype on " work around stupid osx bug
filetype off
filetype indent plugin on
syntax on
set encoding=utf-8 fileencodings= " use utf8 by default
set showcmd " show incomplete cmds down the bottom
set showmode " show current mode down the bottom
set report=0 " always report # of lines changed
set incsearch " find the next match as we type the search
set hlsearch " hilight searches by default
set nowrap " by default, dont wrap lines (see <leader>w)
set showmatch " briefly jump to matching }] when typing
" set nostartofline " don't jump to start of line as a side effect (i.e. <<)
set scrolloff=3 " lines to keep visible before and after cursor
set sidescrolloff=7 " columns to keep visible before and after cursor
set sidescroll=1 " continuous horizontal scroll rather than jumpy
set laststatus=2 " always display status line even if only one window is visible.
set updatetime=1000 " reduce updatetime so current tag in taglist is highlighted faster
set autoread " suppress warnings when git,etc. changes files on disk.
set autowrite " write buffers before invoking :make, :grep etc.
set nrformats=alpha,hex " C-A/C-X works on dec, hex, and chars (not octal so no leading 0 ambiguity)
set wildmode=list:longest "make cmdline tab completion similar to bash
set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
set wildignore=*.o,*.obj,*/tmp/*,*.so,*~ "stuff to ignore when tab completing
set backspace=indent,eol,start "allow backspacing over everything in insert mode
set history=1000 "store lots of :cmdline history
set hidden " allow buffers to go into the background without needing to save
let g:is_posix = 1 " vim's default is archaic bourne shell, bring it up to the 90s.
set visualbell " don't beep constantly, it's annoying.
set t_vb= " and don't flash the screen either (terminal anyway...
set guioptions-=T " hide gvim's toolbar by default
" see .gvimrc for font settings
" search for a tags file recursively from cwd to /
set tags=.tags,tags;/
" Store swapfiles in a single directory.
set directory=~/.vim/swap,~/tmp,/var/tmp/,tmp
set nonumber " no line numbers in terminal (limited real estate), overridden by gui
" indenting, languages
set expandtab " use spaces instead of tabstops
set smarttab " use shiftwidth when hitting tab instead of sts (?)
set autoindent " try to put the right amount of space at the beginning of a new line
set shiftwidth=2
set softtabstop=2
set splitbelow " when splitting, cursor should stay in bottom window
" autocmd FileType ruby setlocal shiftwidth=2 softtabstop=2
" include ! and ? in Ruby method names so you can hit ^] on a.empty?
" TODO: is this necessary anymore?
autocmd FileType ruby setlocal iskeyword+=!,?
" highlight rspec keywords properly
" modified from tpope and technicalpickles: https://gist.github.com/64635
" TODO: is this needed anymore?
autocmd BufRead *_spec.rb syn keyword rubyRspec describe context it specify it_should_behave_like before after setup subject its shared_examples_for shared_context let
highlight def link rubyRspec Function
" Make the escape key bigger, keyboards move it all over.
map <F1> <Esc>
imap <F1> <Esc>
" if you :e a file whose parent directories don't exist, run ":Mk."
command! Mk execute "!mkdir -p " . shellescape(expand('%:h'), 1)
" .md files are markdown, not Modula-2
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
let g:markdown_fenced_languages = ['ruby', 'vim', 'c', 'css', 'html', 'javascript', 'perl', 'python', 'yaml', 'sh']
" Vim "Mistakes":
" make ' jump to saved line & column rather than just line.
" http://items.sjbach.com/319/configuring-vim-right
nnoremap ' `
nnoremap ` '
" make Y yank to the end of the line (like C and D). Use yy to yank the entire line.
nmap Y y$
" don't complain on some obvious fat-fingers
nmap :W :w
nmap :W! :w!
nmap :Q :q
nmap :Q! :q!
nmap :Qa :qa
nmap :Wq! :wq!
nmap :WQ! :wq!
" mapping to make movements operate on 1 screen line in wrap mode
" http://stackoverflow.com/questions/4946421/vim-moving-with-hjkl-in-long-lines-screen-lines
function! ScreenMovement(movement)
if &wrap
return "g" . a:movement
else
return a:movement
endif
endfunction
onoremap <silent> <expr> j ScreenMovement("j")
onoremap <silent> <expr> k ScreenMovement("k")
onoremap <silent> <expr> 0 ScreenMovement("0")
onoremap <silent> <expr> ^ ScreenMovement("^")
onoremap <silent> <expr> $ ScreenMovement("$")
nnoremap <silent> <expr> j ScreenMovement("j")
nnoremap <silent> <expr> k ScreenMovement("k")
nnoremap <silent> <expr> 0 ScreenMovement("0")
nnoremap <silent> <expr> ^ ScreenMovement("^")
nnoremap <silent> <expr> $ ScreenMovement("$")
" Make the quickfix window wrap no matter the setting of nowrap
autocmd BufWinEnter * if &buftype == 'quickfix' | setl wrap | endif
" 'q' inside quickfix window closes it (like nerdtree, bufexplorer, etc)
autocmd BufWinEnter * if &buftype == 'quickfix' | map q :cclose<CR> | endif
" Select most recent paste with gV (i.e. gV=)
nmap gV `[v`]
runtime macros/matchit.vim " enable vim's built-in matchit script (make % bounce between tags, begin/end, etc)
" Random Personal Stuff:
" hitting :MP will make and program the firmware
command! MP make program
command! MPA make program DEBUGGING=always
command! MPP make program ENVIRONMENT=production
" some goddamn plugin is messing this up?
set textwidth=0