|
263 | 263 | noremap j gj
|
264 | 264 | noremap k gk
|
265 | 265 |
|
266 |
| - " Same for 0, home, end, etc |
267 |
| - function! WrapRelativeMotion(key, ...) |
268 |
| - let vis_sel="" |
269 |
| - if a:0 |
270 |
| - let vis_sel="gv" |
271 |
| - endif |
272 |
| - if &wrap |
273 |
| - execute "normal!" vis_sel . "g" . a:key |
274 |
| - else |
275 |
| - execute "normal!" vis_sel . a:key |
276 |
| - endif |
277 |
| - endfunction |
| 266 | + " End/Start of line motion keys act relative to row/wrap width in the |
| 267 | + " presence of `:set wrap`, and relative to line for `:set nowrap`. |
| 268 | + " Default vim behaviour is to act relative to text line in both cases |
| 269 | + " If you prefer the default behaviour, add the following to your |
| 270 | + " .vimrc.before.local file: |
| 271 | + " let g:spf13_no_wrapRelMotion = 1 |
| 272 | + if !exists('g:spf13_no_wrapRelMotion') |
| 273 | + " Same for 0, home, end, etc |
| 274 | + function! WrapRelativeMotion(key, ...) |
| 275 | + let vis_sel="" |
| 276 | + if a:0 |
| 277 | + let vis_sel="gv" |
| 278 | + endif |
| 279 | + if &wrap |
| 280 | + execute "normal!" vis_sel . "g" . a:key |
| 281 | + else |
| 282 | + execute "normal!" vis_sel . a:key |
| 283 | + endif |
| 284 | + endfunction |
278 | 285 |
|
279 |
| - " Map g* keys in Normal, Operator-pending, and Visual+select (over written |
280 |
| - " below) modes |
281 |
| - noremap $ :call WrapRelativeMotion("$")<CR> |
282 |
| - noremap <End> :call WrapRelativeMotion("$")<CR> |
283 |
| - noremap 0 :call WrapRelativeMotion("0")<CR> |
284 |
| - noremap <Home> :call WrapRelativeMotion("0")<CR> |
285 |
| - noremap ^ :call WrapRelativeMotion("^")<CR> |
286 |
| - " Over write the Visual+Select mode mappings to ensure correct mode is |
287 |
| - " passed to WrapRelativeMotion |
288 |
| - vnoremap $ :<C-U>call WrapRelativeMotion("$", 1)<CR> |
289 |
| - vnoremap <End> :<C-U>call WrapRelativeMotion("$", 1)<CR> |
290 |
| - vnoremap 0 :<C-U>call WrapRelativeMotion("0", 1)<CR> |
291 |
| - vnoremap <Home> :<C-U>call WrapRelativeMotion("0", 1)<CR> |
292 |
| - vnoremap ^ :<C-U>call WrapRelativeMotion("^", 1)<CR> |
| 286 | + " Map g* keys in Normal, Operator-pending, and Visual+select |
| 287 | + noremap $ :call WrapRelativeMotion("$")<CR> |
| 288 | + noremap <End> :call WrapRelativeMotion("$")<CR> |
| 289 | + noremap 0 :call WrapRelativeMotion("0")<CR> |
| 290 | + noremap <Home> :call WrapRelativeMotion("0")<CR> |
| 291 | + noremap ^ :call WrapRelativeMotion("^")<CR> |
| 292 | + " Overwrite the operator pending $/<End> mappings from above |
| 293 | + " to force inclusive motion with :execute normal! |
| 294 | + onoremap $ v:call WrapRelativeMotion("$")<CR> |
| 295 | + onoremap <End> v:call WrapRelativeMotion("$")<CR> |
| 296 | + " Overwrite the Visual+select mode mappings from above |
| 297 | + " to ensure the correct vis_sel flag is passed to function |
| 298 | + vnoremap $ :<C-U>call WrapRelativeMotion("$", 1)<CR> |
| 299 | + vnoremap <End> :<C-U>call WrapRelativeMotion("$", 1)<CR> |
| 300 | + vnoremap 0 :<C-U>call WrapRelativeMotion("0", 1)<CR> |
| 301 | + vnoremap <Home> :<C-U>call WrapRelativeMotion("0", 1)<CR> |
| 302 | + vnoremap ^ :<C-U>call WrapRelativeMotion("^", 1)<CR> |
| 303 | + endif |
293 | 304 |
|
294 | 305 | " The following two lines conflict with moving to top and
|
295 | 306 | " bottom of the screen
|
|
0 commit comments