Skip to content

Instantly share code, notes, and snippets.

@andlrc
Created May 2, 2023 17:28
Show Gist options
  • Save andlrc/cf2058329ab12413c23b11c78bd80c8c to your computer and use it in GitHub Desktop.
Save andlrc/cf2058329ab12413c23b11c78bd80c8c to your computer and use it in GitHub Desktop.
" di-prompt - Prompt for a number after using [I, [D, ]I and ]D
" Maintainer: Andreas Louv <andreas@louv.dk>
" Date: 01 Apr 2013
" List and jump to define and include
" \022\027 is ^R^W (Pasting word under cursor)
function! PromptAndExec(cmd)
let ans = input('Type number and <Enter> (empty cancels): ', '')
if ans =~# '^\s*$'
return
endif
silent execute 'normal! ' . printf(a:cmd, ans) . "\r"
endfunction
nnoremap [I [I:call PromptAndExec(":ijump! %d \022\027")<Cr>
nnoremap ]I ]I:call PromptAndExec(":+1,$ijump! %d \022\027")<Cr>
nnoremap [D [D:call PromptAndExec(":djump %d \022\027")<Cr>
nnoremap ]D ]D:call PromptAndExec(":+1,$djump %d \022\027")<Cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment