I am trying to make a habit of never leaving my gvim, not even for executing commands in the terminal. This works fine with :!<command>
. However if this command wants to open default editor (vim) it ironically does not work from gvim (it works from command line vim). Example:
:!git commit
error: Terminal is dumb, but EDITOR unset
Please supply the message using either -m or -F option.
I can run:
:!git commit -m "message"
But I like the vim window when I am inspecting files and write commit messages. Is it possible to make the commit window appear in gvim as with command line vim?
As an alternative to shelling out using :!
command, you may want to try Tim Pope's Fugitive plugin. Quote from documentation:
I'm not going to lie to you; fugitive.vim may very well be the best Git wrapper of all time.
Once installed you can simply run the :Gcommit
command and the commit buffer will be opened up.
Over at Drew Neil's Vimcasts he a series on using Fugitive that is worth a look:
:Gcommit
Git commit checks for the environment value $EDITOR
in order to decide which editor it should to open to type the commit messages unless the messages has been specified using the -m
optin on the commandline.
Use:
:!EDITOR=vim git commit
This will set the $EDITOR
environment var to vim.
Further explanation:
(from man git-commit)
The editor used to edit the commit log message will be chosen from the GIT_EDITOR environment variable, the core.editor configuration variable, the VISUAL environment variable, or the EDITOR environment variable (in that order). See git-var(1) for details.
This means beside from setting environment values you can use git config
to specify the editor. (I would do so)
git config core.editor vim
If you once done so than git commit will not check the $EDITOR
env var anymore.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.