-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmap_option_highlighting_keys.vim
154 lines (123 loc) · 3.63 KB
/
map_option_highlighting_keys.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
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
" map_option_highlighting_keys.vim
"
" A temporary home for the Option+movement keys, while I turn the
" Shift+movement key script into a plugin.
"
"""
""" Option movement keys
"""
""" XXX: All the Option maps need to be reviewed for the
""" missing-last-character bug.
"""
"" Option+Left/Right
" Normal mode
"
nnoremap <M-Left> vh
nnoremap <M-Right> vl
" Insert mode
"
inoremap <M-Left> <C-O>vh
inoremap <M-Right> <C-O>vl
" Visual mode
"
xnoremap <M-Left> h
xnoremap <M-Right> l
" Select mode
"
snoremap <M-Left> <C-O>h
snoremap <M-Right> <C-O>l
"" Option+Up/Down
" Make option up/down enter Visual mode, then move
" up/down by a display line.
" Normal mode
"
" Enter Visual mode then move.
"
nnoremap <M-Down> vgj
nnoremap <M-Up> vgk
" Insert mode
"
imap <M-Up> <C-O><M-Up>
imap <M-Down> <C-O><M-Down>
" Visual mode
"
" Just stay in Visual mode.
"
xnoremap <M-Up> gk
xnoremap <M-Down> gj
" Select mode
"
" Option+Up/Down in Select mode enter Visual mode for one command, move the
" cursor one display line in the proper direction, then re-enter Select mode.
"
" XXX: Stay in Select mode, or switch to Visual mode?
"
snoremap <M-Down> <C-O>gj
snoremap <M-Up> <C-O>gk
"" Option+Home/End, Option+Command+Left/Right
" Normal mode
"
" Enter Visual mode then move.
"
nnoremap <expr> <M-Home> "v" . (&wrap ? "g0" : "0")
nnoremap <expr> <M-End> "v" . (&wrap ? "g$" : "$")
nmap <M-D-Left> <M-Home>
nmap <M-D-Right> <M-End>
" Insert mode
"
" Leave Insert mode for a single command, then trigger the Normal mode
" maps.
"
" This is essentially the same map as Insert-mode Shift+Home; it just leaves
" off the Control+G at the end, so we stay in Visual mode instead of returning
" to Select mode. See the notes above imap Shift+Home for an explanation of
" how it works.
"
" XXX: Factor out common code between this map and imap Shift+Home.
"
inoremap <expr> <M-Home> "<C-O>" . (&wrap ? "g0" : "0")
\ . "<C-O>v"
\ . virtcol('.') . "\|"
\ . "o"
imap <M-End> <C-O><M-End>
imap <M-D-Left> <C-O><M-Home>
imap <M-D-Right> <C-O><M-End>
" Visual mode
"
xnoremap <expr> <M-Home> &wrap ? "g0" : "0"
xnoremap <expr> <M-End> &wrap ? "g$" : "$"
xmap <M-D-Left> <M-Home>
xmap <M-D-Right> <M-End>
" Select mode
"
" Extend the selection to the start/end of the display line.
"
" Shift+Home/End in Select mode enter Visual mode for one command, move the
" cursor within the display line in the proper direction, then re-enter
" Select mode.
"
" XXX: These require that the corresponding Visual mode maps all be single
" commands. Might be better to not depend on the Normal mode maps.
"
smap <M-Home> <C-O><M-Home>
smap <M-End> <C-O><M-End>
smap <M-D-Left> <C-O><M-D-Left>
smap <M-D-Right> <C-O><M-D-Right>
"" Option+Up/Down
" Normal mode
"
nnoremap <M-D-Up> vgg
nnoremap <M-D-Down> vG
" Insert mode
"
imap <M-D-Up> <C-O><M-D-Up>
imap <M-D-Down> <C-O><M-D-Down>
" Visual mode
"
xnoremap <M-D-Up> gg
xnoremap <M-D-Down> G
" Select mode
"
smap <M-D-Up> <C-O><M-D-Up>
smap <M-D-Down> <C-O><M-D-Down>
" end map_option_highlighting_keys.vim