8 votes
Accepted

Detecting the Enter and Leave of Visual mode event

September of last year, a new event was added: commit f1e8876fa2359b572d262772747405d3616db670 (tag: v8.2.3430) Author: =?UTF-8?q?Magnus=20Gro=C3=9F?= <magnus.gross@rwth-aachen.de> Date: 2021-...
3N4N's user avatar
  • 5,269
8 votes
Accepted

What does g CTRL-A really do?

But the question remains: what does g CTRL-A on normal mode does ? What's a memory profile ? Anyone knows ? This refers to this bit of code from src/feature.h: /* * MEM_PROFILE Debugging of ...
cjs's user avatar
  • 347
5 votes

What does g CTRL-A really do?

You're looking at the help for g_CTRL-A in normal mode, but when you're incrementing a list of numbers, you're in visual mode. I'm sorry; I don't know what a memory profile is exactly. It's related to ...
MDeBusk's user avatar
  • 363
4 votes
Accepted

Comment out just-pasted text?

Assuming gc is an operator, like in tpope/vim-commentary, you can use the :help '] motion: p gc'] Rationale: putting (not "pasting") text counts as a change, after a p or P, the cursor is ...
romainl's user avatar
  • 36.9k
3 votes
Accepted

How can I prevent Vim from exiting visual mode?

There is no in built vim option to leave it selected. However but there is a way to reselect quickly You can use gv to reselect the last selection. Or can use | to put multiple commands (For more ...
Mimic Mannan's user avatar
2 votes

Vim: Replace visual selection without overwriting the unnamed register

Finally! After years of us all dealing with Vim's bizarre (and undocumented (UPDATE: OK, OK, half-documented)) default behaviour of replacing the unnamed register even when you are pasting from it, P ...
Medlock Perlman's user avatar
2 votes
Accepted

Select entire function call or extend selection

For func(gunk(a, b)) with the cursor on the f of func, I would press y% or d%. The % command jumps between matching pairs (roughly; depending on configuration, optional plugins that ship with Vim, ...
D. Ben Knoble's user avatar
  • 23.9k
2 votes

Selecting and manipulating around visual blocks

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 ...
romainl's user avatar
  • 36.9k
2 votes

Yank lines without leading whitespace

I would use visual block mode to select text without leading whitespace. Go to the first line you want to yank (in your example the one with "children"). Press ^ to go to the first non-...
Friedrich's user avatar
  • 516
2 votes

Yank lines without leading whitespace

I would personally: Create a new buffer enew Paste using ]p (that correct the indent looking at the previous line indent Yank the text from there :2,$y Delete the buffer :bd!
Vivian De Smedt's user avatar
2 votes
Accepted

How to yank while in visual mode without showing message?

I believe this message is triggered when the number of lines you copy exceed the report setting that is set by default to 2 The following command should solve your problem: :set report=100000 ...
Vivian De Smedt's user avatar
1 vote
Accepted

Vim also deletes the line under the selected region -- why?

After experimenting with my .vimrc, it was this line: vnoremap jk <esc> When I pressed j in visual mode, it didn't visibally go down because it was waiting for the k.
Vinn's user avatar
  • 607
1 vote

How to grab visual selection for search, but apply the appropriate escapes?

I have had this function for years in my config: " return a representation of the selected text " suitable for use as a search pattern function! GetSelection(escape) let old_reg = getreg(...
romainl's user avatar
  • 36.9k
1 vote

Why my visual selection buffer contains ^@

Just in case someone else needs the solution I found with the help of contributors. The following function passes VIM visual selection to STDIN of the external program (sort) and replaces the current ...
Konstantin Glukhov's user avatar
1 vote
Accepted

Why my visual selection buffer contains ^@

Vim translates the new line (^J, "\n") into the null character (^@ that you can insert with Ctrl vx00) when moving the clipboard into a variable (@") The echom method output the ...
Vivian De Smedt's user avatar
1 vote
Accepted

How to visually highlight text between these tags?

The 'tag' concept in your question is called text-object in the Vim documentation. There are various text objects defined. Some standard text-object can be used to address part of your question (...
Vivian De Smedt's user avatar
1 vote

Why doesn't the dot command work after pasting in visual mode?

I don't remember a put in visual mode ever being repeatable with .. I guess not enough people complained about it. Recording a macro before doing the first put would be one workaround (assuming the ...
romainl's user avatar
  • 36.9k
1 vote

:normal o in visual mode WORKS

Actually, "normal" executes a sequence of keys. The point is that "cmd" (unlike "colon") suppresses mode switching and so it starts executing the sequence while still in ...
Matt's user avatar
  • 19.5k
1 vote

Selecting and manipulating around visual blocks

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 ...
Vivian De Smedt's user avatar
1 vote

Run colon command on a movement / text object?

Some (not all) text objects have corresponding marks. In this case, the equivalent is roughly :'{,'}substitute… See :help motion.txt or :help mark-motions for some of these. In general, :help [range]....
D. Ben Knoble's user avatar
  • 23.9k
1 vote
Accepted

select until repeatedly

You can do: vf); f) moves to the next parenthesis ; moves to the over next parenthesis
Vivian De Smedt's user avatar
1 vote

Select entire function call or extend selection

You can do: vf(%` f( moves the the first parenthesis % moves to the matching parenthesis Another way if your are at b and to follow your idea is: va(ob va( select (gunc(a, b)) o switch the cursor in ...
Vivian De Smedt's user avatar
1 vote
Accepted

Mapping snippet trigger in visual mode

The function to call would be UltiSnips#SaveLastVisualSelection(), as can be seen here, or by inspecting the output of :xnoremap <tab>. Modifying from your mapping, this would be vnoremap <...
husB's user avatar
  • 1,883
1 vote

Different replace patterns depending on visual/visual line mode

You can use the mode() function. It returns: v in visual mode and V in visual line mode. More information with: :help mode() mode([expr]) Return a string that indicates the current mode. ...
Vivian De Smedt's user avatar
1 vote
Accepted

How can I have multiple cursors while entering insert mode after Visual Block mode?

It is not possible in Vim without special customization. The vim-visual-multi plugin offers such functionality. For your use case once vim-visual-multi is installed. Use Ctrldown to select the part ...
Vivian De Smedt's user avatar
1 vote

Automatically highlight visual selection matches

I have made it work. Firstly, I found from Vim does not call functions correctly when wrapped in another function that "Vim doesn't like updating Screen too often" so redraw was necessary ...
lobelk's user avatar
  • 21
1 vote

How do I add text before and after the visual selection?

The caveat in @bdesham's answer is relatively straightforward to fix. Here is the full command, which works for all three visual modes: :lockmarks keeppatterns '<,'>s/\%V\_.*\%V\_./[[&]]/ :...
photon.engine's user avatar
1 vote

Quickly calculate the total of a column of numbers

ctrl-v for block select, select the column, paste below G p select the pasted text, press I, now you are in insert mode, type + press esc esc to escape. now each line has a + select it again press J ...
Vaisakh K M's user avatar
1 vote

Quickly calculate the total of a column of numbers

I just did it this way: thru the block selection copied all values, as a column to a new buffer quickly edited the text to construct a mathematical expression copy/pasted it to the default system ...
Dmitry Koroliov's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible