Skip to content
Fix Code Error

How do I make Git use the editor of my choice for commits?

March 13, 2021 by Code Error
Posted By: Anonymous

I would prefer to write my commit messages in Vim, but it is opening them in Emacs.

How do I configure Git to always use Vim? Note that I want to do this globally, not just for a single project.

Solution

If you want to set the editor only for Git, do either (you don’t need both):

  • Set core.editor in your Git config: git config --global core.editor "vim"
  • Set the GIT_EDITOR environment variable: export GIT_EDITOR=vim

If you want to set the editor for Git and also other programs, set the standardized VISUAL and EDITOR environment variables*:

export VISUAL=vim
export EDITOR="$VISUAL"

* Setting both is not necessarily needed, but some programs may not use the more-correct VISUAL. See VISUAL vs. EDITOR.


Some editors require a --wait flag, or they will open a blank page. For example:

  • Sublime Text (if correctly set up; or use the full path to the executable in place of subl):

    export VISUAL="subl --wait"

  • VS Code (after adding the shell command):

    export VISUAL="code --wait"

Answered By: Anonymous

Related Articles

  • How to properly do JSON API GET requests and assign…
  • Retrieve specific commit from a remote Git repository
  • Git Using Remote Branch
  • Checkout another branch when there are uncommitted…
  • git pull while not in a git directory
  • How do I make a Git commit in the past?
  • In plain English, what does "git reset" do?
  • What is your most productive shortcut with Vim?
  • How to modify existing, unpushed commit messages?
  • What's the difference between HEAD^ and HEAD~ in Git?
  • Git submodule head 'reference is not a tree' error
  • Squash the first two commits in Git?
  • Why does this Azure Resource Manager Template fail…
  • configure: error: C compiler cannot create executables
  • Set 4 Space Indent in Emacs in Text Mode
  • Azure Availability Zone ARM Config
  • How do I revert a Git repository to a previous commit?
  • Why do I have to "git push --set-upstream origin "?
  • How to use html template with vue.js
  • Is it safe to shallow clone with --depth 1, create…
  • The 'compilation' argument must be an instance of…
  • Why does git perform fast-forward merges by default?
  • Git workflow and rebase vs merge questions
  • Poll is adding multiple votes
  • How can I merge two commits into one if I already…
  • Python File Error: unpack requires a buffer of 16 bytes
  • How can I set up an editor to work with Git on Windows?
  • Difference between variable declaration syntaxes in…
  • How to cherry pick a range of commits and merge into…
  • How to parse JSON with XE2 dbxJSON
  • Setting up and using Meld as your git difftool and mergetool
  • How to revert multiple git commits?
  • Git submodule update
  • git lfs push to github failure on Ubuntu 18.04
  • Why do git fetch origin and git fetch : behave differently?
  • Cannot find control with name: formControlName in…
  • How to recover stashed uncommitted changes
  • How can I move HEAD back to a previous location?…
  • How do I set the conditional requirements and how do…
  • What is the scope of variables in JavaScript?
  • Various ways to remove local Git changes
  • Eclipse will not start and I haven't changed anything
  • How to use Git Revert
  • Differences between Emacs and Vim
  • How to pull in changes from skeleton sub-repository…
  • How can I reconcile detached HEAD with master/origin?
  • Git merge with force overwrite
  • How to prevent scrolling the whole page?
  • Laravel + Vue.js. Load more data when i click on the button
  • How do SO_REUSEADDR and SO_REUSEPORT differ?
  • Reimplementing html table with polymer not work
  • Scripting Required for Polymer Submenu/Pages Navigation?
  • Does "git fetch --tags" include "git fetch"?
  • How do I install a plugin for vim?
  • Move the most recent commit(s) to a new branch with Git
  • ExpressJS How to structure an application?
  • Logging best practices
  • NullpointerException error while working with…
  • How to retrieve a single file from a specific…
  • How to reverse apply a stash?
  • How To Edit Date and Time Picker Vuejs Vuetify From…
  • How to list branches that contain a given commit?
  • Finding what branch a Git commit came from
  • How to find the nearest parent of a Git branch?
  • Adding classes to a parent div on click
  • Start redis-server with config file
  • Why does Git say my master branch is "already up to…
  • SQLException: No suitable Driver Found for…
  • Search match multiple values in single field in…
  • Practical uses of git reset --soft?
  • Using enums in a spring entity
  • Unable to see color in vim after upgrade
  • Avoid creating new session on each axios request laravel
  • Rails rspec returns no examples found when…
  • "No such file or directory" error when executing a binary
  • Event Snippet for Google only shows one event while…
  • Maven does not find JUnit tests to run
  • How to track untracked content?
  • Simplest way to create Unix-like continuous pipeline…
  • When I'm testing a web app by JUnit and Mockito I…
  • mongodb group values by multiple fields
  • Windows git "warning: LF will be replaced by CRLF",…
  • What's the difference between .NET Core, .NET…
  • How do I use 'git reset --hard HEAD' to revert to a…
  • How to use Boost in Visual Studio 2010
  • Why does git say "Pull is not possible because you…
  • Aurelia Features globalResources (jspm)
  • How to configure Git post commit hook
  • How can i jump to another def from a def
  • In git, what is the difference between merge…
  • Polymer core-scaffold element not showing inside core-pages
  • What is a NullReferenceException, and how do I fix it?
  • How to recover a dropped stash in Git?
  • How do I undo the most recent local commits in Git?
  • Push git commits & tags simultaneously
  • Text Editor For Linux (Besides Vi)?
  • How to create the branch from specific commit in…
  • What are the undocumented features and limitations…
  • Git - Pushing code to two remotes
  • git status shows modifications, git checkout --…

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

String comparison in Python: is vs. ==

Next Post:

How do you get the index of the current iteration of a foreach loop?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error