Tip #137: automatically wrap left and right
tip karma |
Rating 5/4, Viewed by 1658
|
created: |
|
October 14, 2001 21:15 |
|
complexity: |
|
basic |
author: |
|
Brian Medley |
|
as of Vim: |
|
5.7 |
I hate it when I hit left (or h) and my screen flickers. I want it to go up to the next line. Ditto fir right (or l). Below are two functions / mappings to help with that. I'm pretty sure that if you remove the <silent>, then it will work in 5.x...
nnoremap <silent> <Left> :call WrapLeft()<cr>
nnoremap <silent> <Right> :call WrapRight()<cr>
nnoremap <silent> h :call WrapLeft()<cr>
nnoremap <silent> l :call WrapRight()<cr>
function! WrapLeft()
let col = col(".")
if 1 == col
" don't wrap if we're on the first line
if 1 == line(".")
return
endif
normal! k$
else
normal! h
endif
endfunction
function! WrapRight()
let col = col(".")
if 1 != col("$")
let col = col + 1
endif
if col("$") == col
" don't wrap if we're on the last line
if line("$") == line(".")
return
endif
normal! j1|
else
normal! l
endif
endfunction
<<Remapping Alt, Ctrl and Caps in Win2k |
Getting name of the function >>
Additional Notes
|