Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use vim as 'git show' editor?

Tags:

git

vim

all as described in How do I use vim as 'git log' editor? doesn't work for git show . I use often

git show HEAD

ctrl+z 

ps 

  PID TTY          TIME CMD
 7083 pts/8    00:00:06 bash
31758 pts/8    00:00:00 git
31759 pts/8    00:00:00 less
31762 pts/8    00:00:00 ps

Update I found the solution :

git config --global pager.color false
git config --global pager.show 'vim -R -'

Even better (2021-02-05)

git config --global core.pager 'vim -R -'

https://stackoverflow.com/a/16666055/778517

like image 697
Sérgio Avatar asked Jan 20 '15 14:01

Sérgio


People also ask

Can I use Vim with git?

Git command works in the command line interface. The vim plugin named fugitive plugin is developed by Tim pope which is used to work with the git tool without terminating the editor. So, vim and git can work together by using the fugitive plugin.

What editor does git use?

On Windows, if you use Git Bash the default editor will be Vim. Vim is another text editor, like nano or notepad.

What is Vim editor?

What is Vim? Vim is a text editor for Unix that comes with Linux, BSD, and macOS. It is known to be fast and powerful, partly because it is a small program that can run in a terminal (although it has a graphical interface). It is mainly because it can be managed entirely without menus or a mouse with a keyboard.


3 Answers

You can use the following command:

PAGER='vim -' git -c color.ui=false show
like image 171
manzur Avatar answered Oct 04 '22 07:10

manzur


Here is a Twitter post to solve that problem.

https://twitter.com/oliviergay/status/179692941063888896

Using git show with vim and syntax highlighting: vimgitshow() { git show "$1" | vim - "+set filetype=${1##*.}"; }

like image 41
René Höhle Avatar answered Oct 04 '22 08:10

René Höhle


This worked for me:

git config --global pager.show "vim -c '%sm/\\e.\\{-}m//g' -c 'set ft=diff' +1 -"

Crazy vim args found here: https://stackoverflow.com/a/17015531/610634

like image 23
Coeffect Avatar answered Oct 04 '22 06:10

Coeffect