Skip to main content

Questions tagged [visual-mode]

Visual mode is a flexible and easy way to select a piece of text for an operator.

Filter by
Sorted by
Tagged with
0 votes
2 answers
56 views

Any default command to swap the selection text

I’m quite noob in Neovim, not sure if it has builtin feature of key command to swap the selection text with its " (clipboard) register. So anyone kind enough to clarify or laborate ?
user17227456's user avatar
0 votes
1 answer
51 views

Vim visual block copy don't paste in KDE konsole

Selecting by visual line mode and copying (V and y) in vim in rxvt-unicode or in gnome-terminal and pasting in another tab of that terminal with Shift + Insert works well. But trying to do the same ...
pevik's user avatar
  • 109
0 votes
1 answer
88 views

Why do I need to type ggVVG to select all, instead of just ggVG? [closed]

Sometimes, ggVG does not work to select text. It will move the cursor to the top, but not select the text. This happens seemingly randomly. I have figured out if I type ggVVG it will work as expected. ...
BigMistake's user avatar
1 vote
1 answer
34 views

v_g_ctrl-g in neovim does not work

I am trying to find out the word count in selected text in neovim. For some reason, g_ctrl-g works perfectly fine in normal mode, but when I try it in visual mode after selecting some text, nothing ...
K G's user avatar
  • 113
0 votes
1 answer
22 views

Why do text objects move the cursor to the end in Visual mode, but in the beginning in Operator-pending mode?

As far as I can tell, selection in Visual mode using most text objects results in the cursor being placed at the end of the text object region, whether that's linewise or characterwise. However, using ...
shadowtalker's user avatar
0 votes
1 answer
61 views

Vim to drag current selected multi lines up

How do we have neovim to drag up current selected multi lines as vim.api.nvim_set_keymap('x', 'I', ":m '<-2<CR>", { noremap = true, silent = true }) or: vim.api.nvim_set_keymap('x',...
user17227456's user avatar
1 vote
1 answer
64 views

Paste in front or after in visual-block mode?

I can enter visual-block mode using <C-v>, move down a couple of rows by pressing j several times, then paste some content from the registry via pressing p or P. However, the pasting will ...
athos's user avatar
  • 323
0 votes
2 answers
42 views

Select current Line from normal mode without changing cursor position AND without selecting the new line character at the end

What I am asking about can be done using multiple ways but none of them fully achieves what I want. For an instance : 0vg_ selects the current line without the new line character at the end but ...
pic810's user avatar
  • 1
0 votes
2 answers
31 views

How to use register expression with visual selection?

I have this key map in my Vim configuration: nmap <leader>rn :%s/\<<C-r><C-w>\>/ But for this code from php I have a problem. $text=$home_intro['text']; Because, if cursor is ...
serii 's user avatar
  • 91
1 vote
1 answer
96 views

How can I accept a range in a Lua user command?

I want to optionally accept a range in a user-defined function: vim.api.nvim_create_user_command('Pizzafy', function(args) if args.range > 0 then -- visual mode, I think ...
Sasgorilla's user avatar
0 votes
1 answer
27 views

Can the dot operator expand to the outer brackets if an inner pair was mistakenly highlighted during 'vib' (visualize inner brackets)?

( 2. can dot highlight this too? ( 1. 'vib' HERE selects this inner text ))
chapel's user avatar
  • 11
0 votes
0 answers
32 views

How to undo expanding selection in Vim? [duplicate]

I have this code snippet: await sendtemplateemail({ recipient: invite.recipient_primary_email, templateid: 'd-******', templatedata: { inviteurl: `${process.env....
abbood's user avatar
  • 743
0 votes
2 answers
92 views

How do I switch modes inside a user-defined lua function?

I want to write a command to do the following: Make a visual selection. Call a command on the visual selection. By way of example, I'd like to call vat to visually select around the current tag, and ...
Sasgorilla's user avatar
0 votes
1 answer
59 views

How can expand and contract visual selection from a tag block?

Say I have hierarchical markup like this: <div id="level_1"> <div id="level_2"> <div id="level_3"> watermelon </div> </div>...
Sasgorilla's user avatar
0 votes
1 answer
36 views

Keybinding to quickly update (aka prettify) React indentation

This is an example of the original code <Text fontWeight="bold" size="lg" color="turquoise.500">Use Search V2 Beta</Text> and I want a keyboard shortcut (say ...
abbood's user avatar
  • 743
0 votes
1 answer
56 views

keybindings that change mode: cannot use keybindings on the new mode

I have defined the following keybindings: local opts = { noremap = true } local ll = "<leader>i" opts["desc"] = "Send visual lines" vim.keymap.set("v", ...
robertspierre's user avatar
2 votes
3 answers
183 views

Best way to keybind subsequent substitutions in visual mode

I need a keybinding that, given some text selected in visual mode (line visual mode, block visual mode, or whatever): Add > _ before the text Add _ after the text In case of empty lines, > ...
robertspierre's user avatar
4 votes
1 answer
416 views

Why does `yW` yank until the end of the WORD, but `W` move to the next one?

My confusion started with realizing, that yW yanks a different region, then what vW selects, but I found this that explains about selection. But then I realized, that while yW will yank until the end ...
fbence's user avatar
  • 707
2 votes
1 answer
66 views

Replace only inside visual selection (\%V) by default

I would like to always use \%V bounds when replacing inside visual selection. How can I make that behaviour default? I'm currently using this keymap to achieve that, but I was wondering if there is a ...
Rizhiy's user avatar
  • 153
1 vote
1 answer
59 views

Search and replace text in visual range but not entire line [duplicate]

I want to search and replace within a visual range just as was answered in this SO post, which uses :'<,'>. But I don't want this to take place on an entire line, only within the selected subset ...
N. Syiemlieh's user avatar
2 votes
1 answer
843 views

How to add a keymap for a visual mode plugin command and pass it the visually-selected range?

I have the linediff.vim plugin installed. Its main command :Linediff only works for visual mode, to which I'd like to add a keymap for this command. I'm using Neovim's Lua API, so I tried this: vim....
Jethro Cao's user avatar
0 votes
1 answer
120 views

Pipe visual region to external command, not whole line

I have a keybinding nmap <leader>c :w ! wc<CR>, I wanted to expand it to work with visual regions (not just the whole file). I did so by creating vmap <leader>c :w ! wc<CR>, ...
Le-Kat's user avatar
  • 3
2 votes
2 answers
222 views

How to wrap my visual selection with brackets using vnoremap?

Suppose, I want to wrap a single word with braces in normal mode using keyboard map (say <F5>), I could add the following mapping :nnoremap <F5> i{<Esc>ea}<Esc> But, now I ...
Taimoor Zaeem's user avatar
1 vote
2 answers
166 views

Why variables related to visual mode start with two uppercase letters in Vim source code?

In Vim sources, a lot of variables related to visual mode start with two uppercase letters: EXTERN bool VIsual_active INIT(= false); EXTERN bool VIsual_select INIT(= false); EXTERN int ...
Feedforward's user avatar
0 votes
2 answers
164 views

Cannot get block-wise visual selections in vimscript?

I am searching for how to get visual selection in vimscript. And I found this: https://stackoverflow.com/a/61486601/4438921, it is great, but the only issue is that, in block-wise visual mode, I ...
linrongbin's user avatar
1 vote
1 answer
78 views

How to yank while in visual mode without showing message?

When I'm in visual mode and I yank the selection (which has at least 3 lines), messages like these are shown: 4 lines yanked block of 4 lines yanked How can I suppress this so it won't appear in :...
Steve Ward's user avatar
1 vote
1 answer
77 views

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

To delete multiple lines, I highlight a line with Shift v. And then go down a few lines and press d. When I do this, Vim deletes the selected lines and the line directly below it. I am not sure what ...
Vinn's user avatar
  • 791
1 vote
1 answer
52 views

Make operator that doesn't change gv

I'm trying to redefine my inner and outer line text objects so that they don't change gv. First I had onoremap <silent> il :<C-u>normal! $v^<CR> I changed it based on Using visual ...
minseong's user avatar
  • 2,393
0 votes
0 answers
54 views

What's controlling Vim paste behaviour?

What's controlling Vim paste behaviour via Vim over ssh using putty with right-click paste set to Linux host? To start we have: VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Mar 27 2023 00:00:00) ...
chipfall's user avatar
  • 103
-1 votes
1 answer
56 views

find first non-blank column in visual selection

If I select all of these lines in linewise-visual mode hi there how do you do How can I get the column number of the first non-blank character from the left? I.e. the minimum ...
minseong's user avatar
  • 2,393
1 vote
5 answers
626 views

Yank lines without leading whitespace

If I have code like this: const treeData = { name: "Parent", children: [ { name: "Child 1", children: [ { name: "Grandchild 1" ...
minseong's user avatar
  • 2,393
1 vote
2 answers
845 views

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

In this clip, From visual mode here after selecting im.g.mat I trigger my vnoremap <m-/> y:%s/<c-r>0//g<left><left> bind. The purpose of this bind is to initiate a global file ...
Steven Lu's user avatar
  • 2,281
1 vote
2 answers
47 views

Why my visual selection buffer contains ^@

I am writing a function to reformat a visual selection: function! FormatText() range " Calling this function has ended visual mode, so it must be started " again before the selection can ...
Konstantin Glukhov's user avatar
0 votes
1 answer
397 views

How to visually highlight text between these tags?

I'm new to Vim and trying to create a book how practical applications of Vim key bindings to R and Quarto based workflows. Using R with Quarto we will typically encourage two code blocks: ```{r} #| ...
alejandro_hagan's user avatar
0 votes
1 answer
79 views

Copying non-consecutive selected lines in visual mode

Basically I want to select and copy a bunch of non-sequential lines (some lines only partially) from different locations of a code, in a way that each yanked line is appended to clipboard register so ...
Puya's user avatar
  • 15
1 vote
1 answer
49 views

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

1. Why doesn't this work? If my text file is: aaa test bbbb test test bbbb test test bbbb test I can yank aaa, select bbbb in visual mode, and type "0p, to replace it with aaa, with the idea of ...
Zantier's user avatar
  • 111
1 vote
1 answer
273 views

:normal o in visual mode WORKS

In my environment, invoking :normal in Visual mode does Visual mode command. " A map for calling command without quitting visual mode " It gets the cursor to the other side of selection ...
Dugesia7's user avatar
0 votes
2 answers
57 views

Selecting and manipulating around visual blocks

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 ...
shalomb's user avatar
  • 101
2 votes
3 answers
86 views

Run colon command on a movement / text object?

When I substitute text within a paragraph, I've always visually selected (e.g. vap), then :s/ .... How to do this without the visual selection? More generally, how to apply a colon command on a ...
Ana's user avatar
  • 141
2 votes
0 answers
402 views

How to configure cursor shape in visual, visual block modes?

I configure cursor shape in normal, insert, and replace modes with the following in my vimrc let &t_SI = "\<Esc>]50;CursorShape=2\x7" let &t_SR = "\<Esc>]50;...
Aaron Parisi's user avatar
1 vote
1 answer
44 views

select until repeatedly

Is there a way to repeat the "select until" operation? For example: f(a, g(b)) If I want to select f(a, g(b)). I would like to: go to f then do vf) which will select f(a, g(b) and then do ...
lo tolmencre's user avatar
1 vote
2 answers
1k views

Select entire function call or extend selection

I have the following situation a lot, where I always end up having to yank two things in a row: For example, I want to yank a function call: func(a, b) Okay, here I can go to f and press vf). But ...
lo tolmencre's user avatar
2 votes
1 answer
132 views

Comment out just-pasted text?

In vim, I would like to operate on the block of text I just pasted. How? For example, I select a block of text using shift-V, yank and then paste it somewhere. I would then like to comment that text ...
Ana's user avatar
  • 23
1 vote
1 answer
265 views

Sort from current column from visual selection

I am trying to write a :sort wrapper that sorts from current column. command! -bang -range=% -nargs=* Sortc exe '<line1>,<line2>sort<bang> <args> /\%' .. virtcol('.') .. 'v/' ...
balki's user avatar
  • 365
1 vote
1 answer
391 views

How can I prevent Vim from exiting visual mode?

If I enter visual mode, select some text, then run a command or press a keybinding, it will exit visual mode afterward because it assumes I am done. But sometimes I want to do multiple things with ...
Amarakon's user avatar
  • 271
1 vote
1 answer
248 views

Mapping snippet trigger in visual mode

I'm using the UltiSnips plugin. When selecting text, you can press the trigger key to enter Insert mode, and the deleted text can then be used in a subsequent snippet. The snippet I'm using is as ...
Alex867's user avatar
  • 43
3 votes
2 answers
957 views

Detecting the Enter and Leave of Visual mode event

Are there any events similar to InsertEnter and InsertLeave that I could use for visual mode? Looking through the helpfiles, I did not fine any. If not, how would I be able to detect if Vim enters or ...
unrealapex's user avatar
6 votes
2 answers
5k views

What does g CTRL-A really do?

Today I had that old feeling of wonder on how powerful VIM is: I needed a number sequence in the start of some fields and discovered the power of g CTRL-A. So as I always do when I discover something ...
Nelson Teixeira's user avatar
2 votes
1 answer
66 views

Different replace patterns depending on visual/visual line mode

I've written some customizations in my .vimrc that I would like to further improve and refine. In particular, for some key combinations, I'm doing text substitutions, like this: vmap <C-S-w> :s/\...
Jonas Mechtheim's user avatar
0 votes
1 answer
1k views

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

Let's say I have some text: ipsum ipsum dolor ipsum dolor sit I want to add the word "Lorem" in front of each line. Loremipsum Loremipsum dolor Loremipsum dolor sit I can do this by: ...
Amarakon's user avatar
  • 271

1
2 3 4 5
7