I have this remap in my vimrc which makes the cooperation between vim and bash a lot easier:

function! LoadRegisters()
  let $y = @0
  let $r = @"

nnoremap <silent> : :call LoadRegisters()<enter>:

Basically I can just and use my internal registers in external commands without thinking about it. However, now, whenever I use the colon I'm confused because the colon doesn't appear at the bottom, well, because it's silent. Can I somehow make the function call silent, and then go unsilent again?

I don't know how to tag this...

  • I don't know if it would help, but you could try: nnoremap : @=LoadRegisters()<CR>: or nnoremap <expr> : LoadRegisters().':'. You would need to add the instruction return '' at the end of your function LoadRegisters(). – user9433424 Jan 25 '17 at 1:59

The LoadRegisters() function doesn't output anything, so you could remove the <silent>, which causes the last colon to be displayed immediately:

nnoremap : :call LoadRegisters()<enter>:

If for some reason you see any output from this function, you could try the :silent command on the function call:

nnoremap : :silent call LoadRegisters()<enter>:


The thing is that I see it being typed, whenever I use the colon

For some reason I only see the last colon. Maybe you have some configuration that changes the behavior; try testing it in vanilla Vim: vim -u NONE -U NONE -N -i NONE.

| improve this answer | |
  • The thing is that I see it being typed, whenever I use the colon, which I can live with, but if there's a way to avoid it, I'd like to do just that. Your second suggestion seems to help, but it's not perfect. – hgiesel Jan 23 '17 at 18:50
  • @hgiesel I included a suggestion in the answer. If that doesn't solve the issue: have you tried on both terminal and GUI (gVim)? Which Vim version? – mMontu Jan 24 '17 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.