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
1
vote
1answer
26 views

Entering visual mode is selecting whole lines unexpectedly

I'm editing a small bash script: d=$1 year=$(date -d"$d" +%Y) month=$(date -d "$d" +%m) day=$(date -d "$d" +%d) hive -f /home/gavin_cameron/hive_queries/dc_player_daily_snapshot.hive -d ...
2
votes
3answers
60 views

How to indent or unindent lines in a block of text?

I use two spaces in my indentation of codes. What are the possible ways to indent or unindent a block of code?
1
vote
3answers
77 views

Selecting code chunk in Rmarkdown

I am writing an RMarkdown file, which is a document that is a hybrid of text and R code. Here is an example of what that document could look like: Here is an example of text within my Rmarkdown file. ...
0
votes
1answer
35 views

Is there a way to determine whether the current / last visual block selection is non-rectangular?

One can create non-rectangular Visual-Block selections using C-v$ on files with lines of non-equal length. Is it possible to programmatically determine whether the last Visual Block selection was non-...
0
votes
3answers
72 views

Is it possible to yank a column of text in vim without visual block mode?

Consider the following text file. 1 1 3 1 1 5 One can rank row 1 with the command y$ with the cursor on row 1, column 1. However, to yank the first column, the only way I know is to <C-v>3jy. ...
1
vote
2answers
53 views

Is it possible to perform a visual block selection programmatically using line and column numbers?

I've looked around in :help V but haven't found anything of this sort, but was wondering if there's a function I can call from vimscript that would visually select a region based on (row, column) ...
0
votes
0answers
16 views

Is it possible to get the line and column numbers of the corners of a visual block mode selection in Vimscript?

Suppose I select a block of text using visual block mode and I want to perform some operation on the lines surrounding it. For example, I want to surround it with a box of # characters. Note that this ...
5
votes
3answers
202 views

Visual Block Mode edit with sequential number [duplicate]

Suppose I'd like to create a list - "1" - "2" - "3" what Is the smartest way to create such? My attempt would be to i- "1"ESCyypp to get - "1" - "1" - "1" and then jump to the second line's 1 ...
1
vote
5answers
75 views

How to write on multiple places at once

I'm familiar with vertical blocks, and I often ctrl+v down down down shift+I foobar esc to write foobar in various locations at once. This is useful if I want to replace <td> to <th> in a ...
0
votes
3answers
69 views

What's the simplest way to select the longest non blank vertical column in visual block wise mode? [duplicate]

assume you you have some text like this: <-------unknown area <-------blank lines .....0.....<-------dot represent unknown character .....1..... .....*.....<-------...
0
votes
1answer
148 views

Jump to bottom of block in Visual Block mode

I have some code that looks similar to this: [ (Text), (Text), (Text), ], I want to edit the lines that say "Text" by using Visual Block mode. I can type ctrl-v on the first "T" and ...
0
votes
0answers
69 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/...
1
vote
1answer
71 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 ...
1
vote
2answers
296 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 ...
0
votes
1answer
31 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 ...
2
votes
1answer
48 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.
2
votes
1answer
191 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 ...
0
votes
3answers
49 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?
1
vote
2answers
106 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 ...
2
votes
1answer
105 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 ...
2
votes
3answers
774 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
1answer
44 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
2k 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
651 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
47 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 ...
3
votes
2answers
365 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
80 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
1k 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
52 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
486 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
445 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
86 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
26 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 ...
2
votes
2answers
93 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 ...
10
votes
5answers
5k 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 ...
11
votes
3answers
4k 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
378 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
166 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
586 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 ...
2
votes
1answer
37 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
130 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
520 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-...
4
votes
1answer
241 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
34 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
52 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
701 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
502 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
53 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
199 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
1k 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 ...