Multi-line git commit message in VSCode

When compiling files using VSCode Git integration, is there a way to write a multi-line commit message, or am I limited to just one line?

VSCode currently works great in intermediate files. But it looks like I still have to write most of my messages from the terminal.

+12
source share
3 answers

With the release of 0.5.0, we now support multi-line messages. Just press Enter to add new lines.

enter image description here

+15
source

While Benjamin Pasero's answer is definitely viable, do you really want to create non-trivial commit messages in this empty text box embedded in the sidebar? Instead, I would rather write my commit messages on the VS Code tab, opening the editor in full force.

Tune

  1. Set the default VS Code terminal to Git Bash (optional and applicable only when using Windows), adding something like the following to the VS Code settings. In fact, just do it via the GUI as indicated in this answer . (Note that you can execute cmd or powershell from this terminal and bash to return.)

     "terminal.integrated.shell.windows": "C:\\ProgramFiles\\Git\\bin\\bash.exe" 
  2. Set the default Git editor to VS Code, either by selecting VS Code as the default editor during the installation of Git, or by adding something like the following to your global .gitconfig file. See this question for more details.

     [core] editor = 'C:\\Users\\your user dir\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe' --wait 
  3. Install VS Code for a more enjoyable commits experience with extensions like Rewrap , Code Spell Checker , MetaGo etc., as well as with language settings like:

     "[git-commit]": { "editor.rulers": [72, 50], "editor.wordWrap": "off" } 

using

  1. If the VS Code terminal is not yet visible, press ctrl + ' to call it.

  2. Use it to execute git commit -a or something else.

  3. A new tab will appear in VS Code, where you can enter your message about the commit.

  4. When you are finished, save and close this tab to complete the commit, or close the tab without saving to cancel it. You can press ctrl + ' again to hide the terminal.

Action shot

vs code commit

Regarding the use of Rewrap with multiple rulers:

Just press Alt + q several times to move to each line in turn. Then the selected ruler is remembered for this document until the end of the session. It cycles through the rulers in the order they appear in the settings; so if you have the most commonly used ruler, you probably want to put it first.

See the documentation for more details.

+2
source

In my situation: using VS code on Windows, but running Git projects using LF line endings. (my personal Git config: core.autocrlf=input )

Requires default line alignment VS Code:

 "files.eol": "\n" 

in settings.

0
source

All Articles