Vim 从 Git Bash 调用:视觉块前置未应用于所有行

Vim called from Git Bash: visual block prepend does not get applied to all lines

我已经阅读了很多 posts/documentations 关于 Vim 的视觉块功能(例如 prepend not working),但是,我仍然无法应用视觉当我使用从 Git Bash 终端 调用的 Vim 时,阻止将操作添加到多行 。如果我使用 Windows' cmd 或 Windows Power Shell 它工作得很好。

明确地说,在通过 Git Bash 版本 2.16.windows.1 环境创建的 vim 缓冲区中,我按照以下步骤操作:

  1. 按CTRL+V(结果是显示在底部的文字'VISUAL BLOCK')
  2. 突出显示多行(仅每行的第一个字符)
  3. 按下SHIFT+I(结果是'INSERT'显示在底部)
  4. 键入“#”字符(结果是“#”被写入 first/original 行)
  5. 按ESC(结果是我又回到了正常模式)

请注意,只有一行收到前缀字符。如果我从 cmd 或 powershell 中执行相同的步骤,前缀字符将应用于所有选定的行。

有解决办法吗?这是一个已知的 Vim 错误吗?还是 Git 以某种方式干扰了 Vim 功能?

您使用的 vim 似乎是随 git-bash 一起安装的那个,因为 vim 的工作方式与您期望的一样在 powershell 和 cmd 提示符下。

按照此处的步骤查看将 vim 版本更改为您自己的版本是否可以使视觉块前置功能起作用。 https://superuser.com/questions/423532/how-do-i-use-installed-vim-in-git-bash-instead-of-the-one-that-came-with-git

来自 'nevermind' 的最佳答案:

By default Git runs vim from Git\bin\vim. This is actually a script that contains path to the executable itself:

#!/bin/sh
exec /share/vim/vim73/vim "$@"

Therefore you can edit this file to point to your Git location.

The default editor can be overridden in Git\etc\gitconfig:

[core]
editor = path_to_your_editor

希望对您有所帮助!