如何打开一个文件并(通过 vim
的命令行参数)将光标移动到第一行的末尾,然后进入追加模式?具体来说,我正在使用 git prepare-commit-message
钩子(Hook)将标记添加到提交消息中,因此我准备好的提交消息将如下所示:
[SOMETAG]
# ^--- I want to position the cursor here, and enter insert mode
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# ...
本质上,带有尾随空格的字符串 [SOMETAG] "
被插入到提交消息中,我希望 Vim 的行为与我打开文件并点击 完全一样A
移动以开始附加到文档的第一行。
最佳答案
读取文件后使用-c
命令:
vim foo -c 'star!'
我认为您不能将特定的编辑器设置为仅用于 git-commit
,hook 也不会影响您对编辑器的选择。
关于git - 如何打开文件并将光标移动到第一行的末尾?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6998169/