Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " jump to byte offset
- " (http://vi.stackexchange.com/questions/3845/go-to-x-bytes-from-here)
- let s:last_jump_bytes = 0
- function! JumpToByte(byte_nr, mul)
- let crt_byte = line2byte(line('.')) + col('.') - 1
- if (a:byte_nr == 0)
- let dst_byte = crt_byte + a:mul * s:last_jump_bytes
- else
- let dst_byte = crt_byte + a:mul * a:byte_nr
- let s:last_jump_bytes = a:byte_nr
- endif
- let dst_byte = dst_byte > 1? dst_byte : 1
- execute "go " . dst_byte
- endfunction
- nnoremap <expr> <silent> GO ":<c-u>call JumpToByte(" . v:count . ",+1)<cr>"
- nnoremap <expr> <silent> Go ":<c-u>call JumpToByte(" . v:count . ",-1)<cr>"
- " for symmetry with 'gg', and .. G is now a prefix ^^^
- nnoremap GG G
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement