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
0
votes
1answer
44 views

viw breaks when i is remapped

I have the following in my init.vim (neovim): nnoremap i k nnoremap j h nnoremap k j xnoremap i k xnoremap j h xnoremap k j nnoremap h i nnoremap H I I find this arrow key-like configuration much ...
0
votes
1answer
26 views

'visual inner word' on single space does not grow selection

In visual mode, the iw text object 'grows' with repeated presses of iw, ie., viwiwiw... will 'grow' to select multiple inner words. However, this 'growing' behaviour is not seen when the cursor is ...
4
votes
1answer
74 views

Cursor Column in Visual Selection

What is the correct way get the column of the cursor after a visual selection was made? As a simple example, consider the following command. It takes a range and I am trying to obtain the column to ...
3
votes
0answers
28 views

Keep function “keyword = arguments” together when reformatting across multiple lines using “gq”?

One thing I find myself doing often is using visual mode to select a block containing a long function definition containing one or more keyword arguments, and then using gq to reformat the code across ...
4
votes
1answer
36 views

gq in visual mode indents just first two lines of enumeration

Some markdown as an example. I select the following paragraph in visual mode and press gq. The result is: - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor ...
2
votes
1answer
28 views

How to go back after accidentally hitting H in visual mode?

While selecting in visual mode I often accidentally hit H or L instead of h or l due to having used Shift for some previous command (like e.g. V to start selection by line) and not yet released it ...
2
votes
2answers
74 views

Using visual selection or register for search and replace

Is there a way to use a register or visual selection for search and replace? I have some longer sequence of words that are used repeatedly in my script. I want to replace them all but want to avoid ...
2
votes
1answer
43 views

Write text under the cursor to new file and delete it form current file

I have this in my vimrc: " Export text under the cursor noremap <leader>e :w! >><Space> This allows me to select text using visual mode, press leader e, type a file name, and ...
1
vote
1answer
77 views

How to paste yanked text over visual selection?

Yanked text with y, then v select some text, paste with p, but nothing happens.
1
vote
2answers
39 views

remove extra (^@) from visual selection

I'm writing a function to execute an external command using visual selection. I've noticed that if by mistake the entire line is selected, including the new line char the extra ^@ character makes the ...
2
votes
3answers
104 views

How to repeat the last : command for a visual selection instead of whole buffer?

Say I've done the command: :g/^.\{1,50\}$/m$ To move all lines with 50 or less characters to the bottom of the file. Then I realise I actually didn't want to do that for the whole file, but for ...
6
votes
4answers
599 views

How to run a substitute command on only a certain part of the line

I have the following line in my code: INCORRECT_EMAIL_MOBILE_COMBINATION("incorrect_email_mobile_combination"); When I try to substitute the underscores, with spaces, in visual mode (using :'<...
1
vote
1answer
24 views

How do I map multiple replace commands in visual mode

I'm trying to edit my init.vim to allow quick, custom retabbing with one key. My current attempt is as follows (the replace text in the last command is a tab character inputted in insert mode): ...
1
vote
1answer
28 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 ...
0
votes
0answers
40 views

How to start insert-mode completion from select mode using Vimscript?

I have some text selected in select mode. I want to delete it and start insert-mode completion. When I type these keystrokes into Vim it works perfectly: gvc<C-X><C-U> gv switches to ...
3
votes
2answers
55 views

Why is this appearing to select wrong number of lines?

First, I typed 2V to select two lines, and y to yank them. Then I typed 3V, and instead of selecting 3 lines, Vim selects 6 lines. Next I typed 4V and Vim selected 8 lines. It seems that 3 or 4 in the ...
0
votes
1answer
22 views

How do I move to the beginning of a visual block from a vimscript function?

Suppose i have several lines of text: line1 line1 line2 line2 line3 line3 I want to create a vimscript function that has the following result: <itemizedlist> <listitem><para>line1 ...
0
votes
1answer
38 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
0answers
97 views

Visual block mode insert/append not working in vim on RHEL/CentOS?

I was trying to append some text to multiple lines in vi on a RHEL 6 system, however I could not get it to work. I press Control + V to get into visual block mode, select the lines I need, but when I ...
0
votes
0answers
19 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
256 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 ...
0
votes
3answers
178 views

Move selected text to the right

Say I have a line 1234text5678, where I have selected text in visual mode. I would like to have a command <Shift>+, that moves text to the right one character and selects text again. I.e. the ...
1
vote
2answers
52 views

Replacement in visual mode

I wrote a function for selecting a text region and replacing in it certain predefined characters: fun! Tstrepl() range s/\%Va/\="\u2227"/ge " 'a' to '∧' s/\%Vb/\="\u2228"/ge " 'b' to '∨' ...
1
vote
2answers
59 views

visual line mode is ended by inner block motion

When I do Vi{y to select inside a { block and yank it, it doesn't paste how I expect. I noticed that after V (which puts me into VISUAL-LINE mode), the i{ object takes me into VISUAL mode. Here's a ...
1
vote
0answers
38 views

How to use visual mode in python/dyn?

Vim documentation states how to run command and normal mode commands (source): vim.command(str) python-command Executes the vim (ex-mode) command str. ...
1
vote
5answers
148 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 ...
2
votes
2answers
69 views

past yanked content in rectangular selection

I have some long text on Yank var e.g. "Hello all how are you ?" I have a rectangular selection between abc and ABC /a llC-vjj a A b B C C And I want to past my long text without having to type it
0
votes
2answers
34 views

Pass character-wise visual selection to an external command

I want to VISUAL select a piece of text character-wise and pass it to an external command. For example I want to select only the URL from the the text below abcde www.google.com abcde and open it ...
7
votes
2answers
395 views

How to source a part of a file

I can source a file, e.g. my vimrc with :so % or :so <filename>. But what do I do when I need to source only part of a file. I want some way to visually select a portion of the file with :h v ...
0
votes
0answers
28 views

How to stop Vim changing color of the empty space on its own?

I didn't know what is the best title for this question. This problem is annoying me so much. I'm on Windows 7 and using nvim-qt. When I search for a word in the project or for example open NERDTree ...
0
votes
0answers
51 views

For VIM in visual selection mode, how can I simultaneously apply multiple macros via cli to the selection?

The case for applying a single macro is already obvious and well documented, but what of multiple macros? Is such acceptable? :'<,'>norm! @a @b @c... If it is, what's the limit, if any, to the ...
0
votes
1answer
48 views

How to expand selection to containing block?

I'm trying to re-do the C-w selection shortcut in Jetbrains's IDE. Is there a way to select visually the whole containing block ? for now, i use nnoremap <C-w> <Esc>viw vnoremap <C-w&...
2
votes
0answers
30 views

Do operator ranges/movements/textobjects always overwrite the last visual selection? workaround?

In vim, when I operate on a textobject from a plugin, say the 'inner indent' typed ii from kana/vim-textobj-indent, my last visual selection ('>, '<) is reset to where the operator worked on. ...
0
votes
0answers
25 views

Select characters in Visual mode (works differently than Normal mode)

I'm trying to understand the difference in character counting between Normal and Visual modes. Roses are red, Violets are blue, Sugar is sweet, And so are you. The task is to copy everything from ...
0
votes
1answer
66 views

May I have a Vim session report its “Mode” in its “Window Title”?

Clarification of the moving parts First, let me clarify what I mean by "Window Title", and what I expect to achieve On Windows OS, GUI programs will have three attributes: its Window Title texts, ...
1
vote
0answers
41 views

How to stop vim from automatically displaying latex formatting?

I have a latex file I am editing in vim. Something annoying that I'm running into is that vim seems to auto display things that I am typesetting in math mode. Here is an example. Say I write the ...
4
votes
1answer
97 views

How to visually select based on indentation?

If someone is editing the following javascript file: let foo = true if (foo) { let bar = 42 // moooooore code... } You can use vi{ anywhere on the line with let bar to select let bar = 42 and ...
-1
votes
1answer
29 views

how to move to the end of a string / beginning of string for a macro

i want to write a makro and need to know how i can move to the end and to the beginning of a string, respektively i want to visually select the link so that i can surround it with brackets. my line ...
0
votes
0answers
45 views

Why does not Vi buffer operation "n (double quote) work in Vim?

I have read from a book that, vi allows the following commands: "ayy, which means yank the current line into buffer named a. "dP, which means paste the content in buffer named d before the cursor. ...
1
vote
1answer
78 views

Vim: Replace visual selection without overwriting the unnamed register

How do I replace a visual selection with some register content without overwriting the unnamed ("") register by the visual selection? The question https://stackoverflow.com/questions/3837772/vim-...
2
votes
1answer
76 views

How can I quickly replace multiple selections one after another?

To format text in LaTeX you need to surround it with curly brackets, e.g. \emph{} to render it emphasized. I often need to add commands like that to selected text fragments, nothing that could be ...
1
vote
3answers
151 views

Surround part of line with comment /* .. */ [duplicate]

Is it possible to surround a selected part of a line with /* and */? start COMMENT ME end start /*COMMENT ME*/ end
0
votes
1answer
97 views

in function how to stop visual mode and how to run a mapping

Assume I am inside a function and currently in visual mode (mode() returns v or V or "\<c-v>", such as when you run vmap-expr) How can I quit the visual mode? Should I call feedkeys("\<esc&...
1
vote
3answers
95 views

What is the easiest way to select multiple words in visual mode?

If I have the cursor placed on "word1" and wanted to select "word1 word2 word3" (i.e. with no trailing space after "word3") what is the easiest command? word1 word2 word3 word4 I am currently using ...
5
votes
2answers
166 views

Why can't I paste commands into vi?

I've been using vi for 40 years. A week ago I upgraded; Disaster struck! The upgrade was to VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 4 2018 23:38:28) I run this on xterm under Cygwin (...
2
votes
1answer
53 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
66 views

Is there a text object or motion for non-comment lines are not separated from comment lines by blank lines? E.g., in git commit messages

Consider the text A B # C # D Is there a text object or motion that will select lines A and B if the cursor is on either, but not select lines C and D? ap or ip with the cursor on any of those four ...
1
vote
3answers
116 views

Quoting blocks but ignoring whitespace

Let's say I have Foo BAR Baz Quxxx Foo Baar Asd Duxxxxx Bar Foo Baazzz Kuxx Baz I would ideally like to be to highlight the first, second, or third column. Then I would ...
2
votes
2answers
41 views

How can I visual select a ruby module?

Assuming I have the following: My::Cool::Klass.call(args) Cool::Klass.call(args) Is there anyway I can visually select either the My::Cool::Klass or the Cool::Klass with a quick command? Note: ...
2
votes
1answer
277 views

How to find why esc doesn't work right away in visual mode?

When I press <Esc> in visual mode, I don't immediately return to normal mode (the selection persists). I think that is because I have a mapping defined in visual mode shat starts from <Esc>...