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
2
votes
2answers
95 views

Visual block. Some right-end selections seem impossible

I want to use visual block mode (ctl-v) to select all the comments but none of the code: a = 1 // short comment b = 2 // this one is a longer comment c = 3 // ...
3
votes
1answer
405 views

Vim “gq” command doesn't recognize Haskell-style comments

I have a Haskell file on VIM with a Haskell-style comment block: When I select that comment block on visual mode... And press gq, I expected VIM to format my comment to something like: But instead, ...
1
vote
1answer
43 views

Selecting text in more than one column without selecting both lines? [closed]

Is it possible to selecting text in more than one column without selecting both lines in VIM?
-1
votes
1answer
122 views

Visual block - actions like in normal mode (jump to/find character) [duplicate]

Is it possible in visual-block-mode to use find next character? Example: 1: select " in visual-block-mode: code(|"|abcd").anotherCode() code(|"|abcde").anotherCode() code(|"|abcdef").anotherCode() ...
2
votes
1answer
141 views

:'<,'> 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 :...
3
votes
1answer
2k views

Visual select single column from cursor to last line with text in column

There are already a lot of similar questions to this. Jump to last line, but stay in the same column How to go to the end of the file in vim while preserving the current column under the cursor? How ...
4
votes
2answers
188 views

Why are new lines under commented lines automatically commented too? [duplicate]

I will frequently use visual mode and the "norm" command to quickly comment out several lines. Let's say this is my text (line numbers added for clarity): 1. #include <iostream> 2. using ...
8
votes
2answers
5k views

Is there a command to enter Visual Block mode?

I've set up a bunch of key mappings that would cause many Vim users to cringe. Now I am unable to get into Visual Block mode using Ctrl-V (Ctrl-Q isn't mapped, but it doesn't work). Is there any ...
8
votes
3answers
2k views

How to simply remove braces

One of my friend told me that I can use the trick below to remove a pair of curly brackets. Put the cursor inside the curly bracket pair you want to remove. y i { to yank the text in braces , then v ...
5
votes
2answers
935 views

How to prevent “echo” output from being overwritten when leaving visual mode?

I am using gvim 7.4 on Windows (32 bit) and using the wc word-counting macro :WC by jcline. When I manually set a range and run the macro, e.g., :'a,.WC<CR>, I get the expected counted XXX ...
2
votes
6answers
203 views

Easiest way to delete e.printStackTrace();

I have the following: e.printStackTrace(); with the block cursor over the semicolon, what is the easiest way to delete that and end up with the cursor where the first e is? So dd for deleting the ...
6
votes
2answers
1k views

Insert a text selected via visual block

I'm facing a behavior that I find unatural when trying to paste a block of text selected with visual block mode (<C-v>): I can't insert it between two lines without messing with the already ...
6
votes
3answers
909 views

How do I switch between the command-line history and file panes?

When using the command-line history window, I'd like to go back to the file I use it on to see what I'm working with. When revisualizing a block of code (gv), the cursor will go to the top after ...
14
votes
1answer
7k views

Fold selected lines

How can I fold and unfold lines selected in visual mode? Lets say I have three paragraphs and I want to fold the first or last two into one line: Test ==== Lorem Ipsum es simplemente el texto de ...
2
votes
1answer
76 views

Is there any way to prevent a line from wrapping around while in visual mode?

If I am using visual block mode to append to a block of text and number of characters exceeds 80, then the line snaps and text is not appended to rest of the block. I want to find a way such that line ...
3
votes
3answers
3k views

Run macro over a visual selection with line movements

I can find an answer to a similar problem here, however although I can get that example to function I can't get what I want to do to work. Here is the example text to be edited, a partial section of ...
6
votes
2answers
2k views

How to programmatically visually select a text block?

Is there a way to select a text block (e.g. a first word "TODO:") programmatically (with some commands or functions from a script)? Not simply highlight, like with a search, but visually select like ...
4
votes
1answer
443 views

How to resume previous multiple cursors?

I'm using multiple cursors plugin. I'm trying to do the same thing as the second example in their github page. Just trying to add double quote around each of the weekday: mon tue wed thu fri sat ...
11
votes
4answers
3k views

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 ...
15
votes
2answers
9k views

How to partially replace text in a selected text-block?

Not easy to find a nice title for my problem. I'm aware of inserting in front of a text-block: Ctrl-v select lines I type text ESC Now I would like to do this but also with replacing a part in my ...
4
votes
2answers
571 views

Vertically rotate visual block

How would one vertically rotate a visual block of text? For example given this: h e l l o Select those characters in visual block and rotate them once: o h e l l As you see, every character is ...
2
votes
1answer
149 views

How do you get which “side” of the visual mode selection the cursor is on in vimscript?

I'm writing some vimscript and would like to preserve the cursor position after a yank occurs in visual mode. Ths issue is that I can't find any way to get the cursor position while in visual mode. ...
2
votes
4answers
1k views

How can I surround the lines inside the html tag object?

I have the following piece of HTML: <div> <section> </section> </div> I would like to wrap the 2 section tags in a single article like so: <div> <article> ...
33
votes
2answers
27k views

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 ...
37
votes
4answers
10k views

How to replace only within visual selection?

How does one get vim to replace a character within the visual selection only and not elsewhere on the line? Example: Line: int arr[] = { 00 01 02 03 04 05 05 /* ... lots more like this*/}; Visual ...
7
votes
1answer
279 views

Can visual select mode be integrated with the Unix selection clipboard?

Is it possible to configure vim (obviously with :set mouse=a) and/or gvim such that the visual selection modes automatically integrate with X's selection buffer? I am aware of how to setup the copy ...
28
votes
7answers
8k views

Faster way to move a block of text

Here's how I usually copy a block of text or code: Select the block with Visual mode (V) and delete it with d; or if it's just a single line, just use dd. Go to where I want the text to be, I am too ...
9
votes
1answer
249 views

How can I easily get the length of a piece of text?

I sometimes want to check the length of a piece of text, for example in this example: str = 'Hello, world!' if len(str) == 13: print('Hello back to you!') I would like to know the length of the ...
45
votes
1answer
5k views

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 ...
37
votes
11answers
4k views

How to comment out a set of lines which are selected in visual mode?

How do I comment out multiple in visual mode selected lines? How do I make it language specific? For example, if the first 4 lines are selected: def foo(a,b): for each in (a,b): print ...
15
votes
3answers
1k views

How do I visually select the block of text I just pasted in Vim?

I usually need to move/copy code snippets between my source files. After I paste a block of text, I usually need to apply some operation to that block such as reindenting them with =. Is there a way ...

1 2 3 4
5