Questions tagged [visual-block]

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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
215 views

Blockwise pasting from "+ register not working

UPDATE: I run an X server (XQuartz 2.7.11) on MacOS, which I forward via ssh to any Linux machine I use. The problem seems to be that under XQuartz, the "+ register does not support blockwise yanking/...
Anders Lundstedt's user avatar
1 vote
1 answer
120 views

How can I stagger text in vim?

Given the following text: 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 How can each line be shifted left/right an amount related to their line number? Desired outputs: 1 2 3 4 5 1 2 3 4 5 ...
user1717828's user avatar
8 votes
3 answers
7k views

Visual Block Mode: How to insert text to multiple lines after line ending?

Below example, first line is shorter than the other lines. I want to insert \ to all lines at the highlighted place. If I press CtrlC, jjj(select all lines) , Shifti, \, only first line changed. How ...
Fisher's user avatar
  • 1,022
0 votes
1 answer
133 views

Bind visual mode 'I' and 'A' to always use visual block mode before inserting

Is there a way to bind I and A in visual mode and visual line mode to switch the selected region to a visual block selection with the same boundaries? I'd like to be able to use visual line mode to ...
Greg Nisbet's user avatar
  • 1,755
2 votes
1 answer
220 views

How to visual select everything within a pair of fold markers

Are there simple tweaks that I can visual select everything with in a pair of fold markers? Just like what vi" will do for a pair of double quotes. Preferably vi plus some other keys.
hzh's user avatar
  • 195
7 votes
1 answer
3k views

vmap and visual block: how do I write a function to operate once for the entire block?

I'm trying to write a simple function that wraps a visual selection of lines with Markdown ``` lines. Here's what I currently have: function! MarkCodeBlock() " Add Markdown code-block delimiters ...
Steve Hollasch's user avatar
0 votes
3 answers
730 views

How do I insert a single space into the same column of a group of lines?

For example, I wish to change 1 1 2 3 5 8 13 to 1 1 2 3 5 8 13 Where this is not necessarily at the start of the line. How can I do this?
extremeaxe5's user avatar
2 votes
2 answers
2k 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 ...
user642832's user avatar
2 votes
1 answer
122 views

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

I've started using CTRL+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. I am ...
Lombard's user avatar
  • 253
6 votes
3 answers
3k 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 ...
port5432's user avatar
  • 175
0 votes
1 answer
55 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 ...
JohnDoe's user avatar
  • 363
7 votes
2 answers
18k 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: ...
Guilherme's user avatar
  • 173
1 vote
1 answer
2k 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: ...
mike's user avatar
  • 929
1 vote
1 answer
68 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 ...
calocedrus's user avatar
3 votes
2 answers
686 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 ...
reFORtEM's user avatar
  • 133
0 votes
1 answer
168 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 ...
kevinlawler's user avatar
8 votes
1 answer
5k 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 ...
Ryan Bell's user avatar
0 votes
1 answer
171 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 ...
Tyler Durden's user avatar
  • 2,041
7 votes
1 answer
993 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 ...
user avatar
1 vote
3 answers
797 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, ...
kevinlawler's user avatar
3 votes
1 answer
194 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.
linrongbin's user avatar
1 vote
0 answers
40 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 ...
sudo make install's user avatar
2 votes
2 answers
296 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 ...
Evan Carroll's user avatar
  • 1,016
56 votes
5 answers
47k 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 ...
vim.ryan's user avatar
  • 661
15 votes
3 answers
10k 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 ...
leeand00's user avatar
  • 3,345
12 votes
2 answers
1k 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 ...
Violapterin's user avatar
0 votes
2 answers
187 views

Remove current (block) selection

Is it possible to delete the current visual block selection and all other occurences from the current buffer?
criztovyl's user avatar
  • 151
0 votes
4 answers
837 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 ...
Anon's user avatar
  • 835
2 votes
1 answer
62 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 ...
rampion's user avatar
  • 201
7 votes
1 answer
357 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. ...
wefwefa3's user avatar
  • 1,113
10 votes
1 answer
1k 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-...
Loves Probability's user avatar
4 votes
1 answer
295 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 ...
vimKoans44's user avatar
0 votes
1 answer
46 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. ...
Tyler Durden's user avatar
  • 2,041
2 votes
2 answers
159 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 ...
catclark's user avatar
16 votes
1 answer
1k views

Paste visual block selection on its own lines [duplicate]

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. ...
Greg Nisbet's user avatar
  • 1,755
2 votes
2 answers
988 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 ...
Luke Davis's user avatar
  • 1,327
2 votes
1 answer
146 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 (...
user1717828's user avatar
8 votes
2 answers
932 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 ...
grochmal's user avatar
  • 1,636
5 votes
4 answers
3k 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 ...
Anon's user avatar
  • 835
8 votes
4 answers
3k 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 ...
Feffe's user avatar
  • 1,739
2 votes
3 answers
690 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 ...
Greg Nisbet's user avatar
  • 1,755
13 votes
1 answer
3k 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 []: ...
nobe4's user avatar
  • 15.7k
1 vote
1 answer
2k 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. +-------+ | | | | ...
SibiCoder's user avatar
  • 3,222
5 votes
1 answer
1k 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.
adelarsq's user avatar
  • 584
3 votes
1 answer
1k 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> ...
the_velour_fog's user avatar
2 votes
2 answers
107 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 // ...
user251764's user avatar
10 votes
2 answers
9k 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 ...
Dan's user avatar
  • 445
6 votes
3 answers
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 ...
statox's user avatar
  • 48.5k
4 votes
2 answers
850 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 ...
user avatar

1
2