-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbindings.vim
More file actions
122 lines (100 loc) · 3.44 KB
/
bindings.vim
File metadata and controls
122 lines (100 loc) · 3.44 KB
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
" Stop remapping the leader key
let mapleader = ","
" Don't use Ex mode, use Q for formatting
map Q gq
"make Y consistent with C and D
nnoremap Y y$
" Ctrol-E to switch between 2 last buffers
nmap <C-E> :b#<CR>
" ,e to fast finding files. just type beginning of a name and hit TAB
nmap <leader>e :e **/
" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>
" Toggle spell checker
nmap <leader>sp :set spell!<CR>
"set completeopt=menuone,preview,longest
set completeopt=menuone,preview
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Custom bindings for increasing/decreasing the height and width of a buffer
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <leader>< :vertical res +10^M<CR>
nmap <leader>> :vertical res -10^M<CR>
" Toggle paste
set pastetoggle=<F12>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Custom bindings for moving lines around alah TextMate
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
vmap <C-K> [egv
vmap <C-J> ]egv
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 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>
" Pressing ESC can be quite a stretch
imap <c-c> <esc>
" Clear the search buffer when hitting return
function! MapCR()
nnoremap <cr> :nohlsearch<cr>
endfunction
call MapCR()
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Shortcuts
"
" Change Working Directory to that of the current file
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
cmap cwd lcd %:p:h
cmap cd. lcd %:p:h
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Format raw JSON string
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <leader>jt <Esc>:%!python -m json.tool<CR><Esc>:set filetype=json<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Automatically set syntax
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if did_filetype() " filetype already set..
finish " ..don't do these checks
endif
if getline(1) =~ '^#!.*\<mine\>'
setfiletype mine
elseif getline(1) =~? '\<drawing\>'
setfiletype drawing
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ARROW KEYS ARE UNACCEPTABLE
" Using these to get out of the habit of using the arrow keys
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Left> <Nop>
map <Right> <Nop>
map <Up> <Nop>
map <Down> <Nop>
cmap <Left> <Nop>
cmap <Right> <Nop>
cmap <Up> <Nop>
cmap <Down> <Nop>
" Reload my ctags for this project
"
" @TODO: Only do this when coding.
noremap <leader>ct :!ctags -R .<CR>
" Gitscribe
"
noremap <leader>gsa :Git scribe gen all<CR>
noremap <leader>gss :Git scribe gen site<CR>
noremap <leader>gsp :Git scribe gen pdf<CR>
" strip trailing whitespace
"autocmd BufWritePre,FileWritePre * call StripTrailingWhitespace()
function! StripTrailingWhitespace()
normal mz
normal Hmy
exec '%s/\s*$//g'
normal 'yz<cr>
normal `z
endfunction
nmap <silent> <Leader>sw :call StripTrailingWhitespace()<CR>