forked from Xuyuanp/vimrc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmap.vim
73 lines (61 loc) · 1.74 KB
/
map.vim
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
" redefine leader key
let mapleader = ','
" Navigation between split windows {{{
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
nnoremap <Up> <C-w>+
nnoremap <Down> <C-w>-
nnoremap <Left> <C-w><
nnoremap <Right> <C-w>>
" }}}
" Mapping for tab management {{{
nnoremap <Leader>tc :tabc<CR>
nnoremap <Leader>tn :tabn<CR>
nnoremap <Leader>tp :tabp<CR>
nnoremap <Leader>te :tabe<CR>
" }}}
" Reselect visual block after indent/outdent {{{
vnoremap < <gv
vnoremap > >gv
" }}}
" Improve up/down movement on wrapped lines {{{
nnoremap j gj
nnoremap k gk
" }}}
" Clear search highlight
nnoremap <silent><Leader>/ :nohls<CR>
" Keep search pattern at the center of the screen {{{
nnoremap <silent>n nzz
nnoremap <silent>N Nzz
nnoremap <silent>* *zz
nnoremap <silent># #zz
nnoremap <silent>g* g*zz
" }}}
" Force saving files that require root permission
cmap w!! %!sudo tee > /dev/null %
" via: http://rails-bestpractices.com/posts/60-remove-trailing-whitespace
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line('.')
let c = col('.')
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
command! StripTrailingWhitespaces call <SID>StripTrailingWhitespaces()
nmap <silent><Leader><Space> :StripTrailingWhitespaces<CR>
" Stolen from Steve Losh vimrc: https://bitbucket.org/sjl/dotfiles/src/tip/vim/.vimrc
" Open a Quickfix window for the last search.
nnoremap <silent> <leader>q/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
" make ctrl-] center {{{
nnoremap <C-]> <C-]>zz
" }}}
" Auto close {{{
inoremap <C-c> <CR>}<Esc>O
" }}}