Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Quite some programs have commands that output with less(e.g. git blame filename). I would like to use my vim configuration(e.g. <C-j> instead of using Pg Down to go down a page) whenever less is used. How do I set this?

According to this thread and the less man page putting export EDITOR=vim and export VISUAL=vim in my ~/.baschrc should use vim for less but I don't see any change after reloading a terminal session and launching less (I can't use my page down hotkey for example).

share|improve this question
    
Your question is ambiguous. Do you want to use Vim in place of less, or do you somehow want your Vim configuration files to affect less's behavior? The former should be possible, but the latter isn't. –  Heptite Mar 30 '13 at 21:08
    
I wasn't sure if commands like git blame filename hardcoded the use of less or that they just passed output to the pager you are using. I just wanted to use my vim configuration when using a pager, wether its with less or not with less. –  Bentley4 Mar 30 '13 at 22:27
add comment

2 Answers

up vote 2 down vote accepted

The $EDITOR and $VISUAL variables define the editor to use (e.g. when you use the "edit" command inside less).

When programs run less, they run it as a pager, not as an editor – they're looking at the value of $PAGER.

Install vimpager, then:

export PAGER=vimpager
share|improve this answer
    
Awesome! Every time I launch vimpager though I get E21: Cannot make changes, 'modifiable' is off: retab Press ENTER or type command to continue. Any idea how I can set 'modifiable' to on or just simply stop displaying this message? –  Bentley4 Mar 30 '13 at 22:22
    
I've put :set modifiable in my vimrc and it keeps outputting the same message. –  Bentley4 Mar 30 '13 at 22:31
    
Nevermind, it worked after I commented out retab in my .vimrc. Don't know why though. –  Bentley4 Mar 30 '13 at 22:36
add comment

I am not sure what you are exactly after but there are a lot of vi-like key bindings to use with less in its original installation. At least it is so on my Ubuntu Jaunty box. But if you are missing some particular functionality, you can use lesskey program to reassign your key bindings. Running this program will create a file named .less under your home directory. It will be a text file that you can cat or vi or even less to see the contents.

Check the man pages of less (look for KEY BINDINGS) and/or lesskey command to accomplish what you are trying to accomplish.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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