-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
138 lines (133 loc) · 5.63 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
let mapleader = ","
set ts=2
set bs=2
set shiftwidth=2
set number
set ruler
set columns=999
set lines=999
set nowrap
set cursorline
:colorscheme vividchalk
set noerrorbells
set laststatus=2
set backup
set backupdir=~/.vim/backups
set directory=~/.vim/tmp
set scrolloff=5 " keep at least 5 lines above/below
set sidescrolloff=5 " keep at least 5 lines left/right
" obvious custom mappings
command! Rfactories :Redit test/factories/factories.rb
command! RVfactories :RVedit test/factories/factories.rb
command! RTfactories :RTedit test/factories/factories.rb
command! Rschema :Redit db/schema.rb
command! RVschema :RVedit db/schema.rb
command! RTschema :RTedit db/schema.rb
command! Rstylesheet :Redit assets/stylesheets/applicaiton.css
command! RVstylesheet :RVedit assets/stylesheets/applicaiton.css
command! RTstylesheet :RTedit assets/stylesheets/applicaiton.css
set hlsearch " Continue to highlight searched phrases.
set incsearch " Highlight as you type your search.
set ignorecase smartcase " make searches case-sensitive only if they contain upper-case characters
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Update ctags when a file saves
" IF VIM GETS SLOW KILL THIS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
au BufWritePost *.rb,*.js silent! !ctags -R &
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Highlight the trailing whitespace on opening the buffer and leaving the insert mode.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
highlight ExtraWhitespace ctermbg=red guibg=red
au ColorScheme * highlight ExtraWhitespace guibg=red
au BufEnter * match ExtraWhitespace /\s\+$/
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * match ExtraWhiteSpace /\s\+$/
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Highlight text longer than X chars
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" :au BufWinEnter * let w:m1=matchadd('ErrorMsg', '\%<81v.\%>77v', -1) Don't
" like this now but the above highlight chars leading up to 80.
:au BufWinEnter * let w:m2=matchadd('Search', '\%>110v.\+', -1)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CUSTOM AUTOCMDS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
augroup vimrcEx
" Clear all autocmds in the group
autocmd!
autocmd FileType text setlocal textwidth=78
" Jump to last cursor position unless it's invalid or in an event handler
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
"for ruby, autoindent with two spaces, always expand tabs
autocmd FileType ruby,haml,eruby,yaml,html,javascript,sass,cucumber set ai sw=2 sts=2 et
autocmd! BufRead,BufNewFile *.sass setfiletype sass
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MISC KEY MAPS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Insert a hash rocket with <c-l>
imap <c-l> <space>=><space>
" Can't be bothered to understand ESC vs <c-c> in insert mode
imap <c-c> <esc>
" resize the vertical split easlier
nnoremap <silent> <c-p> 20<c-W>>
nnoremap <silent> <c-o> 20<c-W><
" Ack
nnoremap <leader>a :Ack -a
" space bar will center screen on current line
nmap <space> zz
" center the search next/search previous:
nmap n nzz
nmap N Nzz
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MULTIPURPOSE TAB KEY
" Indent if we're at the beginning of a line. Else, do completion.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" funkyness below as per tpope post to deal with pathogen load issues
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocp
call pathogen#infect()
syntax on
filetype plugin indent on
call pathogen#infect()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" below allows for indenting a file and puts cursor back where you were
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <silent> <F5> mmgg=G'm
imap <silent> <F5> <Esc> mmgg=G'm
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" preserve highlight in visual mode when indenting
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:vmap < <gv
:vmap > >gv
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" COMMAND-T TARGETS AND SETTINGS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>t :CommandTFlush<cr>\|:CommandT<cr>
map <leader>gv :CommandTFlush<cr>\|:CommandT app/views<cr>
map <leader>gc :CommandTFlush<cr>\|:CommandT app/controllers<cr>
map <leader>gm :CommandTFlush<cr>\|:CommandT app/models<cr>
map <leader>gh :CommandTFlush<cr>\|:CommandT app/helpers<cr>
map <leader>gl :CommandTFlush<cr>\|:CommandT lib<cr>
map <leader>gp :CommandTFlush<cr>\|:CommandT public<cr>
map <leader>gs :CommandTFlush<cr>\|:CommandT public/stylesheets<cr>
set wildignore+=vendor/** "global setting but used by CmdT
set wildignore+=db/migrate/**