Created
July 31, 2012 16:02
-
-
Save Frost/3218080 to your computer and use it in GitHub Desktop.
macro for jumping to a relative line in vim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " prompt user for a line to jump to. | |
| " accepts N, +N or -N as input. | |
| " -N will be equivalent of just typing N- | |
| " +N equals typing N+ or running :N | |
| function! JumpToRelativeLine() | |
| let linenumber = line('.') | |
| call inputsave() | |
| let line = input('go to line: ') | |
| call inputrestore() | |
| call setpos('.', [0,eval(linenumber + line),0,0]) | |
| endfunction | |
| " map <c-j> set relative line numbers, run the above function, and then reset line numbers. | |
| map <c-j> :set rnu<CR>:call JumpToRelativeLine()<CR>:set nu<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment