开发者

How can I open a file and move the cursor to the end of the first line?

开发者 https://www.devze.com 2023-03-27 07:59 出处:网络
How can I open a file and (via a command line argument to vim) move the cursor to the end of the first line, and enter append mode? Specifically, I\'m using a git 开发者_JS百科prepare-commit-message h

How can I open a file and (via a command line argument to vim) move the cursor to the end of the first line, and enter append mode? Specifically, I'm using a git 开发者_JS百科prepare-commit-message hook to prepend a tag to a commit message, so my prepared commit message will look like this:

[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.
# ...

Essentially, the string "[SOMETAG] " with a trailing space is being inserted into the commit message, and I want Vim to behave exactly like I'd opened the file and hit A to move to begin appending to the first line in the document.


Use -c to give a command after the file is read:

vim foo -c 'star!'

I don’t think you can set a specific editor to be used only for git-commit, nor can a hook influence your choice of editor.

0

精彩评论

暂无评论...
验证码 换一张
取 消