Skip to main content

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
3 answers
75 views

Paste in visual block mode

I would like to copy some text at the beginning of several lines. What I have is: line 111 222 333 444 And what I want is: line line 111 line 222 line 333 line 444 I know that I can add line at ...
jeirual's user avatar
0 votes
2 answers
32 views

Visual Mode increasing numbers by 1

I have many rows with numbers, some rows are blank though: 1 some text 2 some text 7 some text some text 9 some text 11 some text some text 17 ...
athos's user avatar
  • 207
0 votes
1 answer
31 views

Yank across multiple lines with single line breaks

I can use the following to yank text inside of quotes across multiple lines, separate that text by a single new line, and be able to paste it characterwise. let @q = '' | *g/^/exe 'norm! "Qyi&...
Rob Mosher's user avatar
1 vote
0 answers
30 views

Searching for a visual block

Let say I have the following : .................... .###....#........... .###....#........... .###....#........... ............###..... ..........###....... ........###.#....... ..###.....#.....###. .....
M42's user avatar
  • 11
0 votes
1 answer
35 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
1 vote
1 answer
57 views

Pasting from system clipboard works bad in "Visual-block" mode?

For example: mode: Visual-block. In Gvim: Now, I want to paste the system clipboard, say "4", to the position, I tried "p", now it becomes (that's not what I want!): In Gvim: ...
Joey Ling's user avatar
1 vote
1 answer
148 views

How to skip a line when using visual block mode?

I want to add cursors to all lines except the third, is that achievable? 1 2 3 👈 skip this line 4 5
Wenfang Du's user avatar
0 votes
1 answer
483 views

Edit multiple lines and insert

Say I have a text file: abc abc abc I want to change it to this: adbc adbc adbc My current way of doing this is to move the cursor to the b in the first (or last) line, select the column of bs with ...
cheersmate's user avatar
0 votes
3 answers
209 views

Paste in visual block mode without deleting the character under vertically multiple cursor

When I want to paste some text after selecting vertically with <C-q> It is known that Vim/gVim will replace the character under the cursor. For example, below is shown the result after pasting ...
xyx's user avatar
  • 464
0 votes
2 answers
145 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
74 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
0 votes
2 answers
284 views

How to add an integer number to a specific column in Vim editor?

I'm needing to add 184 to multiple (but not all) columns in Vim editor. The following command only adds 184 to the very first column, even if the second or the third column is the only highlighted ...
Jakob Schanzer's user avatar
4 votes
2 answers
1k views

Replacing text with a visual block

Here is what I want to do. Consider the text abcvvxyz abcvvxyz 123456 123456 I would like to copy the v block and paste it over the 45 block to get the following: abcvvxyz abcvvxyz 123vv6 123vv6 ...
January's user avatar
  • 263
0 votes
1 answer
48 views

How to paste below, not to the right nor to the left

Question I think you see the problem... How can I paste directly below? Is there a way? Setup I have this table and I want to copy/yank the 3 × | in visual block mode and then paste it: | sign | ...
Bog's user avatar
  • 489
0 votes
2 answers
56 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
0 votes
4 answers
231 views

Replace every character on a visual selection with a register's character

I'll try to illustrate as clear as I can. Suppose I have the following text open in vim/nvim _________ | | | 9999 | | | --------- If select 9999 visually and then hit r8, this ...
Diwas10's user avatar
  • 115
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
  • 261
1 vote
1 answer
93 views

Replace arithmetic expression by their result

I am just trying to replace several arithmetic expressions inside a script file, which I cannot seem to find a simple solution for on the web. Adapting this answer did not do the trick. Suppose I have ...
winkmal's user avatar
  • 185
0 votes
0 answers
91 views

How can I highlight in visual block mode all text between two delimiters over multiple lines?

I have a tab-separated spreadsheet and I'd like to highlight in visual block mode by selecting a character, expanding the visual highlight region to the whole entry between the two tab characters, ...
Julius Hamilton's user avatar
5 votes
3 answers
235 views

Insert non-rectangular selection

I repeatedly have the following situation, and wonder how it can be handled better than I do it now. These lines must be merged /path;text /path;text /path;text with these: /subdir /longsubdir /...
atann's user avatar
  • 51
0 votes
0 answers
38 views

How to selectively append to end of line using visual block mode?

I am trying to use visual block mode to append a , to the end of root_dir, where [] is the cursor. lspconfig.html.setup{ root_dir = root_di[r] } lspconfig.cssls.setup{ root_dir = root_dir } I ...
John Winston's user avatar
1 vote
0 answers
268 views

Bulk file rename in Vim Visual Block Mode

I am using VIM Renamer plugin to bulk rename files, I want to replace E008_r5_Haz_Area_Class NAT GAS.pdf E009_r4_Haz_Area_Class.pdf E010_r4_Haz_Area_Class MP STEAM.pdf E011_r3_Haz_Area_Class.pdf ...
nirag's user avatar
  • 11
5 votes
2 answers
403 views

How to center a block without centering its contents

For a visual block selection, the :center command will centre the contents of the selection, not the block as a whole. Is there a way to centre the block as a whole without misaligning the contents? ...
user avatar
0 votes
2 answers
188 views

`set nrformats+=alpha` but only in visual block

I want to be able to increment letters but only in visual block mode. I don't want <C-a>/<C-x> to increment letters outside of visual block. This is for making incrementing lists from this:...
ChocolateOverflow's user avatar
5 votes
6 answers
1k views

Quickest way to put a single piece of text in multiple lines

Sometimes I have a bunch of lines, where there's a column clearly indicating some commonality between them, which in general doesn't go far beyond that column; this is an example, I think general ...
Enlico's user avatar
  • 2,224
3 votes
1 answer
47 views

Need a functionality behaving like Replace on text but for Pasting Blocks

One of my vim usages is to do sketches of topologies in networking I've found the script Draw it really really useful for that So I can draw things like this by pasting these boxes +------+ |ROUTER| ...
freddie_ventura's user avatar
0 votes
1 answer
32 views

Understanding interaction between visual, autoindent, and paste option

Let's start form this faulty C++ source file #include <vector> int main() { std::vector<std::vector<int>> v{ 1,2}, 9,3}, 4,2} }; } which ...
Enlico's user avatar
  • 2,224
0 votes
1 answer
771 views

How can I make backspace work in visual block mode?

I hit Ctrl-v3jShift-ixEscape, and x is correctly inserted on the current line and in the 3 lines below it in the same column. Good. I hit Ctrl-v3jShift-iBackspaceEscape a character is deleted only on ...
Enlico's user avatar
  • 2,224
4 votes
2 answers
11k views

VIM - How to select multiple lines that are not adjacent?

If you have the following text: line 1 line 2 line 3 You can hit CTRL+v on line 1 and hit j to select line 2. However, I want to select both line 1 and line 3, but not line 2. Or, select multiple ...
Dr-Bracket's user avatar
1 vote
1 answer
218 views

Yank visually selected text: Keep virtualedit & avoid left/right padding

I use Cygwin's vim & gvim. I used to be able to do as follows. Consider this file mk.bash, with no right-padding spaces: // mk.bash // ------- javac \ -classpath "/c/Program Files/MyJarFile....
user2153235's user avatar
2 votes
1 answer
82 views

bad comment behavior in cmake files

When I'm editing a cmake file in (neo)vim I'm getting bad behavior block inserting comment characters. Given this section of text install_license_file( PACKAGE tomcrypt TARGET ...
ryan0270's user avatar
  • 123
9 votes
3 answers
9k views

How can I add text to the end of words on each line?

I have a series of single-word codes on separate lines in a text file. I'd like to add a backquote ( ` ) to the beginning and end of each word. I know I can add a backquote to the beginning of each ...
Yehuda's user avatar
  • 275
3 votes
3 answers
832 views

Paste a block-copy into a single line

I need to restructure a markdown table, and for that, I wish there was a quick way to "join" lines from a multi-line cell. So with Vim, I would have to yank the block (Ctrl-v), and then ...
PlasmaBinturong's user avatar
0 votes
1 answer
421 views

How to delete and replace a block of text with spaces?

What I want to do I want to select a block of text in Vim, delete it, and replace the selected block with spaces. Example Suppose I have the following text: Lorem ipsum dolor sit amet, ...
jvriesem's user avatar
  • 131
0 votes
1 answer
92 views

Discrete Visual mode

A feature that I love in VSCode is to be able to use my mouse to click at multiple points in the screen and type with multiple cursors. I am aware that in Vim you can do the same in visual mode, but ...
justahuman's user avatar
1 vote
1 answer
5k views

In Windows 10, WSL 2, Windows Terminal, bash and VIM, how to avoid the conflict of <c-v>?

With the newly released Windows 10 update 2004, we can run native Windows Subsystem for Linux (WSL) 2 and install Ubuntu 20.04 on it. Then we can run native bash inside the latest Windows Terminal. ...
Kevin Wang's user avatar
2 votes
1 answer
161 views

Put cursor at arbitrary line and column

Normal, insert, and visual modes restrict cursor movements to locations occupied by some characters. They don't allow moving to the right from the end of line and down beyond end of file. For example:...
Anton Tarasenko's user avatar
2 votes
1 answer
2k views

Select text in block-wise visual mode on each line asynchronously

If I have text like this: cat = "john" leopard = "frank" tiger = "josh" and I want to select the first word of each line in block-wise visual mode, I want to be able to do something like this: put ...
WalksB's user avatar
  • 517
1 vote
1 answer
2k views

blockwise visual mode multi line prepend doesn't work for me [duplicate]

I'm using nVim v0.4.3 and I'm having trouble getting multiline inserts to work in visual blockwise mode. You can check this asciinema to see what I'm doing. https://asciinema.org/a/...
vvMINOvv's user avatar
  • 113
0 votes
1 answer
91 views

Search and replace visual block only? [duplicate]

How do I search and replace in a visual block only? '<,'>s/search/replace/ works on entire lines, not visual blocks only.
Geremia's user avatar
  • 966
1 vote
0 answers
44 views

Swap characters, vertically

Is there a handy way to do this? My input: # A # - B Desired output: # - A # B My current solution is xjphxkP, which seems like a lot of keystrokes. I realize I could record a macro, but it ...
bukzor's user avatar
  • 111
1 vote
2 answers
812 views

Inserting text at the beginning of all lines selected in visual line mode [duplicate]

I have selected a JS block such as following: function map(xs: string[], cb: Function) : string[] { const result: string[] = []; for(let i = 0; i++; i < xs.length) { result.push(cb(xs[i]));...
hyde's user avatar
  • 155
6 votes
1 answer
1k views

Paste a block in "replace" mode

This is best explained with an example: Start by block selecting some text: Yank and paste it somewhere else: Note that the existing x characters were pushed over to the side, rather than being ...
Jonah's user avatar
  • 753
3 votes
4 answers
770 views

Substitute figure by math

I have a file like this: 1 2 3 4 5 6 7 8 9 0 1 2 I want to change a block-wise visual selection area, e.g. 5 and 8. I want to substitute them by multiplying the figures by 0.7 and I want to ...
warem's user avatar
  • 141
6 votes
1 answer
2k views

Trailing characters error in a substitution command

Suddenly simple find&replace stopped working in one particular case. I'm selecting the code-block in visual-mode, so the final command looks like: '<,'>%s/someStuff/stuff/gI I get the ...
z0lupka's user avatar
  • 163
2 votes
1 answer
82 views

How does p really works as related to content put in registers?

I've read this question and answer already, however it could not solve my doubts. As far as my understanding is correct, p always has the same effect (putting the content of a register, by default ...
Enlico's user avatar
  • 2,224
1 vote
1 answer
283 views

Gradient color background for visual selections

In this video from Bisqwit, the selected line is colored by a gradient according to column number. Image is below. He implemented the gradient in a custom terminal emulator. Is there any way to ...
japreiss's user avatar
  • 151
3 votes
1 answer
272 views

Pasting modified register contents into Visual Block selection

Consider this mapping: vnoremap <leader>U ygv"=toupper(@@)<cr>p It will yank the current visual selection, select it back, and then put a modified version of it. In this case, uppercase ...
filbranden's user avatar
  • 29k
2 votes
1 answer
144 views

Is there a function for blockwise visual selection in Vimcript?

I have two text files including steps, one is the main-file which has the entire steps and the other one is a sub-file has only part of steps. As follows. [main-file] SeqMain.txt 0001 K1G554 1 1 ...
Weison Zhuang's user avatar
6 votes
2 answers
2k views

Jump *to* end of paragraph?

I often find I want to quickly select all the characters in an aligned column, something like this: this.p = obj.['propery']; this.prop = obj.['proper']; this.proper = obj.['...
gandalf3's user avatar
  • 267