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-...
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 ...
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 ...
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 ...
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 ...
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 ...
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, ...
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 ...
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-...
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!
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
...
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.
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(...
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 ...
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 ...
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 (...
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 ...
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 ...
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 ...
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]....
1
vote
Accepted
select until repeatedly
You can do:
vf);
f) moves to the next parenthesis
; moves to the over next parenthesis
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 ...
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 <...
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.
...
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 ...
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 ...
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\_./[[&]]/
:...
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
...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
visual-mode × 288key-bindings × 33
cut-copy-paste × 33
vimscript × 31
visual-block × 28
cursor-motions × 20
replace × 18
substitute × 15
normal-mode × 14
neovim × 12
insert-mode × 11
command-line × 10
functions × 10
vimrc × 9
register × 9
selection × 8
indentation × 7
search × 6
cursor-movement × 6
formatting × 6
macro × 6
custom-text-object × 6
gvim × 5
autocmd × 5
comments × 5