【问题标题】:How does git config --global --edit open vi in cmd.exegit config --global --edit 如何在cmd.exe中打开vi
【发布时间】:2023-03-10 06:16:01
【问题描述】:

我想知道的是如何使用git config --global --edit为其他文件打开的编辑器(vi?)。我看到 Git\bin 目录中有一个 vi“文件”,但就 windows 而言,它不是一个可运行的文件。

我可以通过使用 git config 命令打开编辑器然后使用 :e 打开其他文件来作弊,但肯定有一种方法可以在不使用该解决方法的情况下打开编辑器。

这都是为了在 Windows 7 和/或 8 上的 cmd.exe 中使用。

【问题讨论】:

  • 您可以通过 Git 附带的 bash shell 使用 vim。它开箱即用。

标签: windows git vi


【解决方案1】:

latest git-for-windows(如the 2.9 one)确实包括vim.exe

vonc@ D:\prgs\git\PortableGit-2.9.0-64-bit\usr\bin
> dir vi*
 Volume in drive D is data

 Directory of D:\prgs\git\PortableGit-2.9.0-64-bit\usr\bin

15/02/2016  19:12                25 vi
09/04/2016  07:08         2 335 971 vim.exe

vi 只是一个调用vim 的外壳包装器:

vonc@ D:\prgs\git\PortableGit-2.9.0-64-bit\usr\bin
> more vi
#!/bin/sh

exec vim "$@"

只要<path/to/2.9>/usr/bin 在你的%PATH% 中,你就可以在任何文件上调用vim(不管是在git repo 内部还是外部,都没有关系)。

【讨论】:

  • 我不知道我在看哪个目录,但它不是 /usr/bin。找到它,让它工作。非常感谢!
【解决方案2】:

https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration

core.editor 默认情况下,Git 使用您设置的任何内容作为默认文本编辑器($VISUAL 或 $EDITOR),否则会回退到 vi 编辑器来创建和编辑您的提交和标记消息。要将默认值更改为其他值,您可以使用 core.editor 设置:

$ git config --global core.editor emacs 现在,无论您的默认 shell 编辑器设置为什么,Git 都会启动 Emacs 来编辑消息。

Vi 教程?谷歌,或者只是关注网络上的众多之一,如http://www.tutorialspoint.com/unix/unix-vi-editor.htm

【讨论】:

    猜你喜欢
    • 2022-01-11
    • 1970-01-01
    • 1970-01-01
    • 2022-10-30
    • 1970-01-01
    • 1970-01-01
    • 2023-01-09
    • 1970-01-01
    • 2014-02-02
    相关资源
    最近更新 更多