1

I use vim as a pager with vimpager and a script to change between pager and full vim mode.

But pressing i, a, etc change the mode while paging, which I want to prevent from happening.

I tried map i <Nop> and it works, but then I cannot restore the original behaviour, when switching to full vim mode.

2
  • From the vimpager github page: "To use a different vimrc with vimpager, put your settings into a ~/.vimpagerrc or ~/.vim/vimpagerrc or a file pointed to by the VIMPAGER_RC environment variable." Does it work to put your map commands there ?
    – B.G.
    Commented Apr 3, 2017 at 13:49
  • I haven't tried it yet. I put the map commands after HideCursorInLessMode() and RestoreCursor() in ~/.vimrc, which should work the same as the alternative rc files you mention.
    – 1.61803
    Commented Apr 3, 2017 at 15:10

1 Answer 1

1

For my configuration for using Vim as a MANPAGER, I set nomodifiable. With that, Vim doesn't allow me to enter an editing mode:

E21: Cannot make changes, 'modifiable' is off

This doesn't block visual mode, of course, which makes it all the more convenient.

4
  • Thanks, but I meant all modes. I have mouse enabled, so selecting text changes the mode. I wouldn't mind mapping the relevant key bindings to <Nop>, but I still couldn't figure out how to get the original behaviour back.
    – 1.61803
    Commented Apr 3, 2017 at 18:10
  • @1.61803 what do you mean by "switching to full Vim mode" here?
    – muru
    Commented Apr 4, 2017 at 0:31
  • You can toggle vimpager's default less mode with ,v to what I called 'full vim mode', that is as if you opened a file with vim foobar.
    – 1.61803
    Commented Apr 4, 2017 at 7:01
  • I tried nomodifiable in the script I referenced above, but then I'm not able to restore the normal behaviour with modifiable (in the function RestoreCursor()). Vim documentation doesn't say much about this option neither. Could you check that up?
    – 1.61803
    Commented Apr 7, 2017 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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