git & less/vim

Todd Zullinger tmz at pobox.com
Fri May 29 16:55:15 UTC 2009


Brian Ericson wrote:
> Anyone know how to get git working properly with less and vim?
> Specifically:
>
> * less does not "clear" (revert) the screen properly after commands
> like "git log" and "git diff"
[...]
> Both of these work properly in Gentoo (and vim -- but not less --
> works properly in Ubuntu), but it's not obvious to me what's
> different between the distros to account for the differing
> behavior...

The difference is likely that Fedora is shipping a more recent version
of git than Ubuntu and upstream git has seen a few changes regarding
the pager handling.

Check out the core.pager setting in the git-config manpage.  You can
set this a number of ways, using the LESS or GIT_PAGER environment
variables, or the core.pager config setting.  By default, git pass the
options FSRX to less.  The -X option is what prevents less from
clearing the screen, but using -F also causes this in my testing
(which I found confusing...).

If it were me, I'd set the LESS variable and exclude FX, e.g:

    export LESS="-RS"

(See the less man page for the options you might want to set.
    
If you use GIT_PAGER or the core.pager setting, you will have to use
slightly odd syntax to override the LESS environment var that git will
set, e.g.:

    export GIT_PAGER='less -+$LESS -RS'

or

    git config --global core.pager 'less -+$LESS -RS'

This is described in the git-config manpage.

> * vim isn't using the git extensions/file types for commands like "git
> commit"

On F-10, this should "Just Work" as vim-7.2 has the needed syntax
files included.  Is your EDITOR var set to vim?

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some of the narrowest minds are found in the fattest heads.
    -- Anonymous

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 542 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20090529/ea43c142/attachment-0001.sig>


More information about the fedora-list mailing list