lonious
lonious

Reputation: 696

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

I've read quite a few posts/documentations about Vim's visual block feature (such as prepend not working), however, I'm still not able to apply a visual block prepend operation to multiple lines when I'm using Vim called from a Git Bash terminal. If I'm using Windows' cmd or Windows Power Shell it works just fine.

To be clear, from inside a vim buffer that was created via the Git Bash version 2.16.windows.1 environment, I follow the following steps:

  1. Hit CTRL+V (the result is the text 'VISUAL BLOCK' displayed at the bottom)
  2. Highlight multiple lines (just the first character of each line)
  3. Hit SHIFT+I (the result is 'INSERT' being displayed at the bottom)
  4. Type the '#' character (result is '#' being written to the first/original line)
  5. Hit ESC (The result is that I'm put back into normal mode)

Note that only one line received a prefix character. If I follow the same steps from cmd or powershell the prefix character is applied to all lines selected.

Is there a workaround to this? Is this a known Vim bug? Or is Git somehow interfering with Vim features?

Upvotes: 0

Views: 1052

Answers (1)

Rafe H
Rafe H

Reputation: 124

It seems like the vim that you are using is the one that came installed with git-bash, since vim works like you'd expect from within powershell and cmd prompt.

Follow the steps here to see if changing the vim version to your own makes the visual block prepend feature work. https://superuser.com/questions/423532/how-do-i-use-installed-vim-in-git-bash-instead-of-the-one-that-came-with-git

From top answer by '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

I hope this helps!

Upvotes: 1

Related Questions