git - 如何打开文件并将光标移动到第一行的末尾?

标签 git vim

如何打开一个文件并(通过 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/

相关文章:

Git 与 Dropbox 问题

Vim:空格分隔的数字列表

vim - 如何使 emmet.vim 插件工作?

git - Gstatus 改变了 vim-fugitive 中的行为

javascript - 如何在 Vim 中内容辅助 Ruby 或 JavaScript?

git - 补丁在 Git 中是如何工作的?

python - 无法使用 gitpython 创建/添加新分支到 git repo

php - GIT - Web 开发工作流程/部署

git - 如何提交没有更改和新消息?

vim - Windows 7 PowerShell 在每个字符之间插入 ^@ - 如何防止?