File tree Expand file tree Collapse file tree 1 file changed +26
-5
lines changed Expand file tree Collapse file tree 1 file changed +26
-5
lines changed Original file line number Diff line number Diff line change 252
252
noremap k gk
253
253
254
254
" Same for 0, home, end, etc
255
- noremap $ g$
256
- noremap <End> g<End>
257
- noremap 0 g0
258
- noremap <Home> g<Home>
259
- noremap ^ g^
255
+ function ! WrapRelativeMotion (key , ... )
256
+ let vis_sel= " "
257
+ if a: 0
258
+ let vis_sel= " gv"
259
+ endif
260
+ if &wrap
261
+ execute " normal!" vis_sel . " g" . a: key
262
+ else
263
+ execute " normal!" vis_sel . a: key
264
+ endif
265
+ endfunction
266
+
267
+ " Map g* keys in Normal, Operator-pending, and Visual+select (over written
268
+ " below) modes
269
+ noremap $ :call WrapRelativeMotion("$")<CR>
270
+ noremap <End> :call WrapRelativeMotion("$")<CR>
271
+ noremap 0 :call WrapRelativeMotion("0")<CR>
272
+ noremap <Home> :call WrapRelativeMotion("0")<CR>
273
+ noremap ^ :call WrapRelativeMotion("^")<CR>
274
+ " Over write the Visual+Select mode mappings to ensure correct mode is
275
+ " passed to WrapRelativeMotion
276
+ vnoremap $ :<C-U> call WrapRelativeMotion("$", 1)<CR>
277
+ vnoremap <End> :<C-U> call WrapRelativeMotion("$", 1)<CR>
278
+ vnoremap 0 :<C-U> call WrapRelativeMotion("0", 1)<CR>
279
+ vnoremap <Home> :<C-U> call WrapRelativeMotion("0", 1)<CR>
280
+ vnoremap ^ :<C-U> call WrapRelativeMotion("^", 1)<CR>
260
281
261
282
" The following two lines conflict with moving to top and
262
283
" bottom of the screen
You can’t perform that action at this time.
0 commit comments