0

Ok, this was previously a question about Vim until I learned it was particular to the Visual Studio plugin ViEmu.

In ViEmu, 'v' puts the highlighter cursor between the previous character and the current one, such that walking backward leaves the letter that was under cursor when 'v' was pushed unselected. This is particularly annoying when trying to use visual mode from the end of the line. Is there a key that is to 'v' as 'a' vs. 'i' and 'p' vs 'P'.

Here's an example:

I have the following text with my cursor sitting over the trailing s of the word dances.

The fat yellow dog dances

and I wish to to change it to:

The quick brown fox jumps

I'd like to enter visual mode with the highlighter positioned to the right of the s in dances. That way, as I use shift+f to search backward to say the f in fat I select everything. Using v->shift+f->f will highlight everything but the s in dances which is annoying.

DubiousPusher
  • 1,132
  • 2
  • 8
  • 19
  • 2
    Can you provide a small example of what you mean? It's not a 100% clear to me ... – glts Oct 17 '13 at 19:02
  • `v` has no direction: without a motion or a text-object, the cursor stays put. It's up to you to give it a motion that goes to the left (`^`, for example) or to the right (`3w`, for example). Since it has no direction why do you ask for a way to revert it? Or is it that you want to start visual selection on the character before/after the cursor? What would be the point? – romainl Oct 17 '13 at 19:22
  • What you're describing is already standard Vim behaviour. You have probably set `'selection'` to exclusive. Do `:set selection&`, then `vFf` should work as you expect. – glts Oct 17 '13 at 19:56
  • @romainl Oh you're right. I'm using a visual studio with a vim emulator called ViEmu. In ViEmu the v puts the selection cursor between the current letter and the one before it and then you select from there. (After using v, l will select the character your cursor was just on whereas h will select the one before.) – DubiousPusher Oct 17 '13 at 20:04
  • 1
    @DubiousPusher That changes everything. ViEmu is not Vim, far from it! – glts Oct 17 '13 at 20:06
  • Funny thing, I want to create exactly this functionality you are trying to avoid in real vim, so that the selection starts on the letter to the left when I move the cursor to the left, and not the letter it was on. The reason being because I have mapped commands to start selection while in INSERT mode in gVim, and as you know, the cursor is an I (not a block), so I'd like it to behave like modern editors in that regard (the cursor marks between letters, not over a letter). – trusktr Oct 28 '13 at 02:45

1 Answers1

1

If we think about how a change made with an operator, say d3e, is different from the same change made using Visual mode, v3ed, we find that the distinctive element in Visual mode is that of interactivity.

In Visual mode it is natural to start selecting and then steadily honing in on the target area: Instead of v3ed I might as well use veeed or veeeebbed or v4ebbed. Or maybe after vee I realise I need to include stuff that comes before my selection, thus o, bb, and finally d.

The point is, when using

  • operators, we need to be precise: operator plus target – a hole-in-one shot;
  • Visual mode, we are free to employ the full array of Vim's motions to describe our target area, whatever shape it may be, and there's no pressure to be precise or hit the mark immediately.

In case you often need to start Visual mode just after the current cursor position (or you have another similar use case), you can always create a custom mapping. Here are some ideas:

:nnoremap <Leader>v <Space>v
:nnoremap <Leader>v $hv
:nnoremap <Leader>v $F;v
glts
  • 21,808
  • 12
  • 73
  • 94
  • This unfortunately doesn't handle my problem since v, always puts the highlighter before the letter under the cursor. So what I need for your suggestion to work is to be able to move 1 past the last character in the line. – DubiousPusher Oct 17 '13 at 19:59
  • 1
    @DubiousPusher Then try `:nnoremap v vo`. – glts Oct 17 '13 at 20:04
  • Works perfect. Can't believe I didn't know about 'o' in visual mode before. – DubiousPusher Oct 17 '13 at 20:12