1

When I do Vi{y to select inside a { block and yank it, it doesn't paste how I expect.

I noticed that after V (which puts me into VISUAL-LINE mode), the i{ object takes me into VISUAL mode.

Here's a gif:

enter image description here

I wanted the paste p to put the text underneath where my cursor was, as if I had yanked some text while in VISUAL-LINE mode.

If I start visual mode with shift-V, I want object motions like i{ to keep me inside of that mode.

1
  • @klaus "this won't happen by default" — I don't think I changed my defaults Apr 21, 2019 at 3:39

2 Answers 2

1
i}                          *v_i}* *i}* *i{*
i{                          *v_iB* *v_i{* *iB*
iB          "inner Block", select [count] Blocks, from "[count] [{"
            to the matching '}', excluding the '{' and '}' (see
            |[{|).
            When used in Visual mode it is made characterwise.

You can use getregtype() to check register type.

Vi{ will change visual mode to v, you can hit V again to return to V.

As long as lines of { and } don't belong to lines of i}, yi} will result in V type register, you should use yi} in your case.

4
  • you're right yi{ works, but why doesn't Vi{ work the same way. I find this frustrating Apr 21, 2019 at 3:40
  • i{ in Visual mode switch current Visual mode to characterwise.
    – dedowsdi
    Apr 21, 2019 at 3:41
  • @theonlygusti, Vi{ doesn't work cause there is no such thing as Vi{.
    – 3N4N
    Apr 21, 2019 at 3:47
  • @klaus is there a way to make it a thing? Apr 24, 2019 at 23:34
1

See :h intro for more details

Vim has seven BASIC modes:

  • Normal mode
  • Visual mode
  • Select mode
  • Insert mode
  • Command-line mode
  • Cmdline mode
  • Ex mode
  • Terminal mode

There are six ADDITIONAL modes. These are variants of the BASIC modes:

  • Operator-pending mode
  • Replace mode
  • Virtual Replace mode
  • Insert Normal mode
  • Insert Visual mode
  • Insert Select mode

As you can see, there is no mode called visual-line-mode that you talked about in your question. There are just three kinds of visual-mode, none of which are modes themselves:

  • Characterwise visual (see `:h characterwise-visual)
  • Linewise visual (see `:h linewise-visual)
  • Blockwise visual (see `:h blockwise-visual)

Read :h visual for more details.

If you look through :h text-object, you will see that the text objects you're talking about, i.e. i{ are not acceptable for linewise-visual style of visual mode. Because, text-objects are supposed to work with visual-mode and after an operator, see :h text-objects. That's why Vim intelligently changes the type of visual mode you were in, because it makes sense. But of course, you're in complete control with just one more keystroke.

Suggestion: Use vi{ to visually select the content inside the curly braces and press V to start visual line mode over the already selected lines. This is the default way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.