Questions tagged [visual-mode]

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

Using Visual mode consists of three parts:

  1. Mark the start of the text with v, V or <CTRL-V>. The character under the cursor will be used as the start.
  2. Move to the end of the text. The text from the start of the Visual mode up to and including the character under the cursor is highlighted.
  3. Type an operator command. The highlighted characters will be operated upon.

Full documentation: visual vimdoc

304 questions
58
votes
1 answer

Expand a visual selection in the other direction

Sometimes I have selected a visual selection with, for example, Vjjjjj, only to realize later that I should have started the selection one line higher. However, pressing k simply decreases the lower range of the selection rather than moving the…
Doorknob
  • 15,237
  • 3
  • 48
  • 70
39
votes
2 answers

How to block replace code in visual mode?

I have a list of items where I want to replace the first two characters: a) item 1 b) item 2 c) item 3 What is the fastest way to make this: * item 1 * item 2 * item 3 I have an approach with visual mode (Ctr-v, jjj, but need to do two replace…
poseid
  • 493
  • 1
  • 4
  • 6
13
votes
4 answers

How to achieve selection different length of texts on different lines?

assume I have following texts: aaa-dd-e: "aaa", bb-x: "bb", c-9: "c" I want to do selection like below: aaa-dd-e: "aaa", bb-x: "bb", c-9: "c" I tried using c-v to create a visual block, but after I create selection on the first column and I press…
Aaron Shen
  • 2,519
  • 3
  • 24
  • 37
11
votes
2 answers

Is there a way to reselect the last visual shape, rather than the last actual selection, starting at the current cursor position?

I know that gv reselects the last visual selection. This is great and I use it frequently. But sometimes I want to do something related but different: from the current cursor position, select a block in the same shape as the prior visual selection,…
Philip
  • 301
  • 2
  • 8
6
votes
1 answer

Expand visual selection to inner curly braces

Let's say I have this piece of code (cursor/selection is represented by []): [f]unction a() { // ... } If I want to select the function declaration and the curly braces (and of course the content) I can do Vj%, which select the first line, goes…
nobe4
  • 16,033
  • 4
  • 48
  • 81
4
votes
1 answer

Vim ^V Visual Block mode not working

I am running Vim version 8.0.563 on Solaris and when I run Vim, the CtrlV block selection works as expected, I type ^V and move the cursor and a block of text is highlighted by columns. So far, so good. Meanwhile, for another user running Vim from…
user1683793
  • 141
  • 1
  • 1
  • 3
3
votes
1 answer

Can I edit visually selected text in a different buffer?

I often use vim via terminal wrapper (e.g. gnome-terminal --disable-factory --command='vim /tmp/firefox12345.txt') to edit a textarea on websites, e.g. when writing this question. Whenever I put in a block of code I wonder if I can…
cprn
  • 143
  • 7
3
votes
1 answer

Displaying the number of lines you have selected in Visual Mode?

Is there a command to display a count of the number of lines you have selected in Visual Mode in VIM?
leeand00
  • 3,555
  • 5
  • 24
  • 40
3
votes
2 answers

Move cursor to end of visual block

When in visual block mode is there a way to cause to the cursor to switch to the end/beginning of the block? For example, in Excel this functionality is performed by the "." key. If the person has a block of cells selecting, then pressing the period…
Tyler Durden
  • 2,091
  • 2
  • 23
  • 42
3
votes
0 answers

Keep function "keyword = arguments" together when reformatting across multiple lines using "gq"?

One thing I find myself doing often is using visual mode to select a block containing a long function definition containing one or more keyword arguments, and then using gq to reformat the code across multiple lines. some_function <-…
3
votes
2 answers

past yanked content in rectangular selection with vim8

I have some long text on Yank var e.g. "Hello all how are you ?" I have a rectangular selection between abc and ABC /a llC-vjj a A b B C C And I want to past my long text without having to type it To get this: a Hello all how are you ? A b Hello…
user3313834
  • 189
  • 4
3
votes
1 answer

How to select text character by character with shift and directions?

I would like to know how I can select text character by character, in visual mode, using a combination of shift+direction without using the mouse. Actually, with Shit + Left/Right gvim selects the text word by word. For example, in the following…
xyx
  • 464
  • 3
  • 11
2
votes
2 answers

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 ), I could add the following mapping :nnoremap i{ea} But, now I want to extend this for visual mode, where I can select some text and wrap…
2
votes
1 answer

:'<,'> Vs :'>,'>, what do these range arrows in vi visual mode mean?

I am trying to copy the selected text from vim into system clipboard. In visual mode, i pressed :, and the command prompt string changed as, :'<,'> Running :'<,'> !tee >(xsel -b) added :'<,'> into the current buffer which is not the desired…
Saravana
  • 123
  • 5
2
votes
3 answers

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 movement / text object like ap?
Ana
  • 141
  • 4
1
2 3