-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc.after
170 lines (145 loc) · 5.64 KB
/
.vimrc.after
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
162
163
164
165
166
167
168
169
170
" settings for ruby textobjects (vim-textobj-rubyblock)
set mouse=a
set nocompatible " must be set before iskeyword since it resets iskeyword
runtime macros/matchit.vim
if has("autocmd")
filetype indent plugin on
endif
filetype plugin indent on
" color options
if $VIM_DARK == '1'
set background=dark
color solarized
else
set background=light
color github
endif
hi Normal ctermbg=NONE
let g:solarized_visibility='high'
let g:solarized_contrast='high'
set relativenumber
" paste from clipboard
set clipboard=unnamed
" Reloads the file when it's changed
set autoread
" Make terminal Vim trigger autoread more often.
au WinEnter,BufWinEnter,CursorHold * checktime
" TODO it does not reload directly when swithching terminal tabs or tmux screens/panes
" Automatically save changes before switching buffer with some
" commands, like :cnfile.
set autowrite
" Show partially typed command sequences.
set showcmd
" Minimal number of lines to always show above/below the caret.
set scrolloff=3
" Soft wrap.Soft
set wrap
" Let - be a valid keyword character
set iskeyword+=-
" Add a visual line after the 80 character breakpoint
set colorcolumn=81
" Toggle paste
set pastetoggle=<leader>p
"Open the focused split, when splitting the window, to the right and
"to the bottom instead of to left and top
set splitbelow
set splitright
" Little hack to fix the split/scroll problem (scrolls down on split)
tabnew
bwipeout
" resize current buffer by +/- 5
nnoremap <C-w><left> :vertical resize -5<cr>
nnoremap <C-w><up> :resize +5<cr>
nnoremap <C-w><down> :resize -5<cr>
nnoremap <C-w><right> :vertical resize +5<cr>
"Strip all trailing whitespace <del>before writing to the buffer</del>
"on leader mapping
fun! <SID>StripTrailingWhitespacesAndConvertTabsToSpaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
%s/\t/ /ge
call cursor(l, c)
endfun
map <leader>stw :call <SID>StripTrailingWhitespacesAndConvertTabsToSpaces()<CR>
"" More mappings
"map double j to escape in insert mode, to save finger travel distance.
imap jj <Esc>
nnoremap <space> za
" map ctrl-s to enter in command line mode
cnoremap <C-S> <cr>
"map ctrl-s to save
noremap <silent> <C-S> :update<CR>
vnoremap <silent> <C-S> <C-C>:update<CR>
inoremap <silent> <C-S> <esc>:update<CR>
" leader+d to create the directory in which the file is created
map <Leader>d :!mkdir %:p:h<CR>
"Ctrl-O exits insert mode for just one command i think that i prefer to exit
"insert mode on ctrl-s but i keep this comment here if i change my mind
map <Leader>rr :CtrlPClearAllCaches<CR>
" map <Leader>nr :NERDTree<CR><C-W><C-P>
"rails.vim mappings
map <Leader>rc :Rcontroller<CR>
map <Leader>rv :Rview<CR>
map <Leader>rm :Rmodel<CR>
map <Leader>rrr :Rrefresh<CR>
map <Leader>ri :Rinitializer<CR>
"config/routes.rb when no args is given
" Vimux bindings
" Prompt for a command to run
map <Leader>rp :VimuxPromptCommand<CR>
" Run last command executed by RunVimTmuxCommand
map <Leader>rl :VimuxRunLastCommand<CR>
" Inspect runner pane
"disabled since i want that binding for rails.vim
"map <Leader>ri :InspectVimTmuxRunne
" Close all other tmux panes in current window
map <Leader>rx :VimuxCloseRunner
" Interrupt any command running in the runner pane
map <Leader>rs :VimuxInterruptRunner
" Run tests: current file, current test, current context
" map <Leader>t :call VimuxRunCommand("bin/rspec spec")<CR>
" using vroom as a test runner mostly (it caches the name of the
" last run spec file, so that you can run it from any file),
" but i keep these shortcuts to be able to run context test if I'll feel the
" need for that sometime.
" map <Leader>tt :RunAllRubyTests<CR>
map <Leader>ft :RunRubyFocusedTest<CR>
map <Leader>ct :RunRubyFocusedContext<CR>
" send "echo <test command>" to a named pipe (test-command) that runs that
" command so that one can run the tests in another window on the other screen
" (gary bernhardts idea destroy all software, running tests asynchronously)
map <leader>t :w\|:silent exec "!echo 'clear && ./bin/rspec --format documentation %' > test-commands"\|redraw!<CR>
" Ack search for the word under the cursor
map <Leader>a yiw:Ack <C-r>0<CR>
"Some nice commands from github.com/r00k/dotfiles
"''''''''''''''''''''''''''''''''''''''''''''''''
" Don't wait so long for the next keypress (particularly in ambigious Leader
" situations.
set timeoutlen=650 "default 1000
"Reload .vimrc and do bundle install (changed to work with my janus config)
nmap <Leader>bi :source ~/.vimrc.before<cr>:PluginInstall<cr>
" Search for visually selected text (in visual mode)
" Search for selected text, forwards or backwards.
vnoremap <silent> * :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> # :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
" tab settings (the defaults is almost perfect)
"autocmd Filetype javascript setlocal ts=2 sw=2 sts=2 expandtab
autocmd Filetype html setlocal ts=2 sw=2 sts=2 expandtab
" Some file name extensions has to have some special treatment
autocmd BufRead,BufNewFile *.hbs\.erb set filetype=html.handlebars
" Evaluate ruby code with seeing-is-beliveing
nmap <buffer> <F5> <Plug>(seeing-is-believing-run)
xmap <buffer> <F5> <Plug>(seeing-is-believing-run)
imap <buffer> <F5> <Plug>(seeing-is-believing-run)
nmap <buffer> <F4> <Plug>(seeing-is-believing-mark)
xmap <buffer> <F4> <Plug>(seeing-is-believing-mark)
imap <buffer> <F4> <Plug>(seeing-is-believing-mark)