git 提交期间固定光标位置

Xed cursor position during git commit

我一直在使用 xed 来编写我的提交消息。 xed 记住每个文件的最后光标位置。 由于文件 .git/COMMIT_EDITMSG 被每个提交消息重复使用,因此 xed 打开时光标位于我提交上一次提交时所在的位置。 必须手动将光标重新定位回第一行是一个 PITA。

[X]:我希望光标所在的位置。

[Y]: 光标所在位置

[X]

# Please enter the commit [Y] message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch develop
# Your branch is up to date with 'origin/develop'.
#

可以告诉xed在某一行打开。 在 .gitconfig 中,只需替换

[core]
  editor = xed

来自

[core]
  editor = xed +1

xed +lineNumber 告诉 xed 在第 lineNumber 行打开文件。

+1 告诉它在第一行打开文件。