Skip to content

Instantly share code, notes, and snippets.

@andlrc
Created May 2, 2023 17:28
Show Gist options
  • Select an option

  • Save andlrc/cf2058329ab12413c23b11c78bd80c8c to your computer and use it in GitHub Desktop.

Select an option

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>
@Konfekt
Copy link

Konfekt commented Sep 15, 2025

Maybe of interest; I think it's from @romainl

@romainl
Copy link

romainl commented Sep 15, 2025

@Konfekt Yeah, it looks like a variant of https://github.com/romainl/vim-qlist or of the original gist: https://gist.github.com/romainl/3c7ee68125f822ec550c.

FWIW, I have another gist with a different and more generic approach to the problem solved by this gist: https://gist.github.com/romainl/047aca21e338df7ccf771f96858edb86.

@Konfekt
Copy link

Konfekt commented Sep 15, 2025

Thank you, yes, that must have been it. Maybe upstream vim-qlist as an option to make something much more useful out of :i/dlist and accompanying mappings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment