4

Looking at the documentation I found this piece:

a}                          *v_a}* *a}* *a{*
a{                          *v_aB* *v_a{* *aB*
aB          "a Block", select [count] Blocks, from "[count] [{" to
            the matching '}', including the '{' and '}' (see
            |[{|).
            When used in Visual mode it is made characterwise.

The part interesting here is

When used in Visual mode it is made characterwise.

It's the behavior for all the i/a text objects (except for p)

Do you know why is the visual selection changed ?

Why can't you select a block linewise? (e.g. Va{ will jump back to characterwise).

  • Why can't you select a block linewise? Not an answer to 'why' but you can easily select a block in linewise mode: viB to select the block and then V will switch from characterwise to linewise. – statox Jan 13 '17 at 14:22
  • 1
    @statox But that's just it, using VaB still doesn't use linewise. It switches it back to characterwise. – Tumbler41 Jan 13 '17 at 16:04
  • 1
    @Tumbler41 yeah V has to be pressed after vaB to switch to lineswise, but that's not a perfect solution clearly – statox Jan 15 '17 at 16:42
  • @statox Ah, I didn't know you could do that. Thanks for the clarification. – Tumbler41 Jan 17 '17 at 20:49
2

From my observation: Because there isn't a linewise version of di{. In the same vein, there isn't a characterwise version of dip. Not to mention that Viw would seemingly do nothing if iw didn't cause it to become characterwise.

As far as I can tell, text objects are basically macros for selecting text. When you use an operator command, the text is "selected" before being operated on. In visual mode, the text objects simply become visible.

It seems reasonable that using text objects in visual mode would replace the selection since they can't be used to extend the selection. That is, if you selected a few characters then press i{, the initial selection is lost since it would otherwise not be "text that's between two curly braces".

For example:

if (1) {
   // <- start selection in here
}

// <- end the selection here and press `i{`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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