0

I'm particularly interested in what the presenter, Damian Conway, in this talk is doing as he selects the end of visual-block to effortlessly add quotes.

In particular - what is happening around 36:57

enter image description here

and around 37:02 mark as he adds these quotes?

enter image description here

I gather he is making use of the DragVisuals which he authored to yank/duplicate the blocks of text. But it's the wizadry (IMO) he applies to the second block to wrap it in quotes, is not part of DragVisuals, and that part is really what I would like to decipher.

The vertical blue bar looks like a CursorColumn being activated but it's also doing something in addition to pasting text at the beginnging and end around it.

I've looked high-and-low and I reckon he's making use of another/custom plugin (but what?) but any insights into what is happening here would greatly help as I've come back to this over the years always wanting to adopt the same.

Note: I am aware of many other ways to accomplish the same outcome, using :'<,'>s/$/'/ or :'<,'>norm A' or A' in Visual Block mode, etc. I am not asking how to wrap blocks of texts with quotes but rather - what is happening in this video.

2 Answers 2

2

There is absolutely no wizardry or plugin involved, just pretty basic vimming, explained in chapter 10 of the user manual: :help 10.5.

It goes like this:

  • he is in visual-block mode,
  • he presses $ to tell Vim that the selected area extends horizontally to the end of each line in the area,
  • he presses A,<Esc> to append a comma to the selected text of each line, effectively appending it to each line.

The demo is (intentionally, IMO) confusing because:

  • :help 'showmode' is either disabled or overwritten so it is hard to tell in what mode he is, which makes it hard to figure out what comes from his plugin and what is native,
  • :help 'virtualedit' is likely set to all, which allows him to move the cursor freely after the actual EOL and makes the behavior of visual-block mode quite perplexing,
  • :help 'cursorcolumn' adds unnecessary noise.
1

I believe you could do: Ctrl-v$A"Esc

When in Visual-Block mode you can escape the mode with I or A to have the chance to insert something at the start or at the end of each line of the block respectively.

The block are usually rectangular with the exception of the blocks construct with the $ move that end with the end of each lines.

It is using these non rectangular visual block that you can add something at the end of each lines.

Your Answer

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

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