Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Visual block mode enables users to copy and paste rectangular text. This mode is useful whenever a particular text is pasted to be pasted in every part of a rectangular text.

0
votes
0answers
14 views

Also apply changes to empty lines when doing visual block edits?

Often I comment-out a block of code using block editing. I know there are tools for doing this (e.g., NERD Commenter), but I sometimes need/prefer to do it my own way. However, when I use insert ('I')...
0
votes
1answer
22 views

Delete from end of line in visual block mode

If i've got the code hello hellllo hello i can insert code before or after all of the lines by using I or A in visual block mode, respectively. How can I delete the last x characters? I'm aware ...
1
vote
1answer
91 views

Why does ^C behave differently from ESC when exiting visual block substitution?

I've started using ^C instead of ESC in vim because of its position on the keyboard and better responsiveness. It mostly behaves the same except when exiting visual block replacements, hoping someone ...
2
votes
3answers
316 views

Add a block of text to end of lines

Not sure if this one is possible, but say I have a file with two blocks of text, in this case English words and their French translations. eg: vivre aimer étudier to live to like to study Now I ...
0
votes
0answers
24 views

Set nostartofline when in visual block mode

Is there a way to set nostartofline when entering visual block mode and restoring to whatever status startofline had when leaving visual block mode?
0
votes
1answer
36 views

Move to last line leave cursor in place [duplicate]

I know I can move to the last line of the file using G but that will move cursor to the first column. When in visual block mode I would like to extend the selection to the last line without moving ...
2
votes
2answers
312 views

What does it mean to set clipboard=unnamed?

Today I was trying to copy and paste multiple lines in visual block mode and found this excellent answer on StackOverflow showing how to do it. Below is a gif of what I was trying to accomplish: ...
1
vote
1answer
204 views

What does <C-V>?<Space><CR> do?

What does C-V ? space CR do? Can someone explain that key by key? I know C-V is visual block mode, but the ? ? How does that work? Imagine this, with the cursor on the first line, first char: ...
1
vote
1answer
35 views

replacing character in a visual block selection replaces the wrong character?

In visual selection mode, accessed with ctrl-v, I can replace the character I want (say Z to be replaced by A) within my selection by typing : followed by s/Z/A. This is extremely useful. Here is a ...
1
vote
2answers
176 views

The meaning of "= in Vim

I was solving a problem on Vimgolf (you can take a look at this) where I stumbled upon this solution. djgJ.V"=[<C-R><C-A>]<CR>pZZ Could you please walk me through the meaning of ...
0
votes
1answer
64 views

how to accept count for visual block ctrl+a remap?

I have created a vmap but I can't figure out how to apply a count to it. In this case, the mapping is on <C-a> and 4<C-a> is an example of a command with a count failing to be applied. We ...
3
votes
1answer
457 views

Deleting and inserting in a single visual block selection

I'm trying to understand how the visual-block mode deals with Backspace and Delete, and if it is possible to vertically select a column of text, delete some characters, then insert new ones in a ...
0
votes
1answer
46 views

How can I move the cursor in block mode (without changing the block)?

When a visual block is created, the block itself is highlighted, but the cursor is highlighted differently, green in my terminal. If I want the block to stay the same but move just the location of ...
6
votes
1answer
205 views

Replace all occurrences in visual block selection but NOT all occurrences on line

I'm trying to figure out how to do a search and replace on a visual block selection that will replace all occurrences in the visual block selection without replacing all occurrences on the line. What ...
1
vote
3answers
363 views

simple map to right align text selection within visual block?

This should be easy but it seems to be a blind spot in vim. I'm looking for a short one line mapping, let's say to <leader>r, to right-align text inside a visual block selection. For example, ...
2
votes
1answer
73 views

how to write command to save selected text?

I want to save selected text in vim. I use command :'<,'>w! ~/save.txt. How to write a short command instead of it, or mapping it to key mappings.
1
vote
0answers
24 views

Yanking a visual block with word wrap enabled is shifted

Say I have a file with the following contents (on a single line): Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed augue ligula, venenatis et orci non, convallis congue nunc. Nam eleifend ...
3
votes
2answers
51 views

How do I quote tabulated columns?

Currently, I'm using Vim Surround to make quoting easy on Multiple whole-lines Visual blocks Individual words However, it doesn't seem to make the job easy on columns, for example. Take this ...
2
votes
5answers
1k views

How can I insert text at the end of a group of lines?

Let's say I had a block of text... Lorem ipsum Lorem ipsum dolor Lorem ipsum dolor sit Lorem ipsum dolor sit amet ...and I wanted to insert a . at the end of each line. What would the best approach ...
10
votes
2answers
2k views

Visual select from cursor to next empty line?

How does one select from the current line to the next empty line? I'm aware of SHIFT+V but then I have to either jump to the next empty line or press the down key a bunch of times. I know how to do ...
10
votes
2answers
288 views

How to paste visual block starting with another line

It took me very long time to realize that putting (pasting) something with p or P which visual-block selects with ctrl+v and yanked (copied) with y, preserves the manner before, so that, when the ...
0
votes
2answers
159 views

Remove current (block) selection

Is it possible to delete the current visual block selection and all other occurences from the current buffer?
0
votes
4answers
328 views

How to quickly replace a single character in a word search, but only for a block of code in Fakevim?

3rd block of code needs to go from ipt1 to ipt4 4th block of code needs to go from ipt1 to ipt5 Because it is only 3 selections, creating a macro is probably slower than manually, but doing it ...
3
votes
1answer
32 views

extra newlines when pasting altered string in visual block mode

Suppose I have an open buffer containing the following text 1111111111 1 1 1 222222 1 1 2 2 1 1 2 33 2 1 1 2 33 2 1 1 2 33 2 1 1 2 2 1 1 222222 1 1 1 1111111111 I can visually ...
6
votes
1answer
112 views

What does [count]v and [count]V do? How is it useful?

I am confused about how the start visual commands work when you pass them a count. I checked the help page but I am still confused. [count]V Start Visual mode linewise. ...
10
votes
1answer
307 views

Sorting a column without altering other columns

I was recently aware of the filtering ! technique, and I love it. Unfortunately, I am not able to use it in a visual-block mode. Hope some experts here would help me out. Basically, I want to in-...
5
votes
1answer
232 views

Is there a way in Vim to draw the visual area of the same size as the last visual selection, but at a new cursor position?

After I visually select the following area And press Esc and move this position I want to be able to select the same shape in this manner If there is no generic and direct way to do this, any tips ...
0
votes
1answer
31 views

Visual block append does not seem to work with Inside Paragraph (ip)

If I select several lines in visual block mode and then append it works, for example: <C-v>jjj$A;<ESC> will append a semicolon to 4 lines. However if select a paragraph it does not work. ...
2
votes
2answers
44 views

Incrementing File Names

I'm hoping to create a .cl script to run in IRAF. I have a list of spectra on which I want to run dispcor. I was wondering if there's an easy way to paste the output file names with incrementing ...
7
votes
1answer
376 views

Paste visual block selection on its own lines

I'm not really sure how to describe what I'd like to do. Basically I'd like to use visual block mode to select a region of text and then paste it "as a collection of lines" rather than as a rectangle. ...
2
votes
2answers
443 views

How to keep Vim from exiting Visual Mode due to mouse clicks while mouse=a?

Currently when I click somewhere in the terminal with mouse=a enabled, Vim exits visual mode. How can I force Vim to remain in Visual mode, and thereby use mouse clicks (not drags) to create a ...
2
votes
1answer
46 views

Edit width-limited comment blocks faster

Take any long comment in paragraph form: 1 // This is a comment that is really long because it is describing something 2 // worth being verbose about, possibly at the beginning of the program (...
8
votes
2answers
142 views

How I force [count]<C-x> to leave leading zeros?

Context I use vifm as my file manager (that's off topic here, i know, but keep reading) which allows me to edit filenames inside a vim buffer. One issue i found myself annoyed at are numbered files ...
3
votes
3answers
993 views

How do you change the last n characters for a range of lines?

Generally you can select a visual block for the first n characters of a range of lines, and just press c, insert characters, and press Esc to have it apply to all. However, this method is rarely ...
5
votes
4answers
880 views

Add constant integer to visually selected numbers

I have a file like the following : two different files were yanked one after another, and the numbers subsequently don't match anymore. ... 46 atom 142 option 47 atom 143 ...
2
votes
3answers
152 views

Visual block yank to end of line

I found a vim tip a while back recommending swapping visual and visual block mode (http://howivim.com/2016/damian-conway/) For the most part this is really useful. I frequently find myself wanting to ...
9
votes
1answer
905 views

Visual block insert new line

I work a lot with visual block mode, which I find really useful for quick changes across a lot of lines. But something I'm struggling to do is inserting a newline like so: Selection is noted as []: ...
0
votes
1answer
449 views

How to paste a text block in visual block mode?

I want to paste text which spans across multiple lines and is rectangular. For example, a rectangular box representing a device topology diagram. +-------+ | | | | ...
4
votes
1answer
258 views

Visual block editing: map i

How to map i to start editing on visual block mode? I want the same behavior for <shift>-i and i.
3
votes
1answer
107 views

Can I select and edit specific positions in lines while in visual block mode?

say for example, I have this text: <div class="test1"></div> <span class="highlight"></span> <nav class="tester"></nav> <aside class="wrapper"></aside> ...
3
votes
2answers
76 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 // ...
6
votes
2answers
2k 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 ...
6
votes
2answers
894 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 ...
4
votes
2answers
295 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 ...