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
1
vote
1answer
19 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
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 ...
0
votes
0answers
31 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
48 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
18 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
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
0answers
28 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
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 ...
0
votes
3answers
98 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
45 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
52 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
27 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
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 ...
2
votes
2answers
67 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
30 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
1answer
360 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
24 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
42 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
31 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
27 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
23 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
57 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
34 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
67 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
27 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
38 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
64 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
75 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
112 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
83 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
65 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 ...
4
votes
2answers
146 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
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
65 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
96 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
38 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
212 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>...
1
vote
2answers
90 views

How to select a block in visual mode and delete this block and immediately enter insert mode?

for one single word, the job is quite easy: we just do a 'cw' what if I select a certain text and I want to replace this block with one word? obviously I can do a 'x' and then 'i', is there a one ...
2
votes
1answer
129 views

getpos(“.”) in visual mode equals getpos(“v”)

I uses neovim 0.3.1 only. I define the following function and map to do a test for getpos in visual mode: function! show_position() echo getpos("'<") getpos("'>") getpos(".") getpos("v") ...
1
vote
2answers
90 views

iedit behaviour in Vim?

For Emacs there is idedit. It Allows you to select some text, then hit one button, which automatically select all other occurrences of the selected text in the current buffer. Then you can edit the ...
2
votes
1answer
48 views

In visual mode, how can I select to either the next section or the end of the file?

I'm having trouble selecting sections in a file in a visual mode macro to separately perform some action on each section. Here's an example file: [insert introduction here] ... .... ------ section .....
0
votes
1answer
82 views

Is it possible to return to normal mode in the middle of a vim command?

By simply calling :(range)g/bob/norm Axxx I can add xxx to the to the end of all lines in range containing bob. Is there a way to return to normal mode after having used A/I/a/i to enter insert mode, ...
1
vote
2answers
114 views

Expand the visual selection independently of the cursor position

I would like to add, say, the next three characters to the current visual selection. For example: Do not select. Select from here. Select this too. Select until there. Do not select. If bold ...
1
vote
1answer
115 views

Stay in visual mode when in command mode and pressing escape

Suppose we do the following steps: Visually select something Type :some stuff press escape when we do the last step, the command mode is exited but also we are left in normal mode - not visual mode....
2
votes
1answer
170 views

Move Selected Lines in Visual Line Mode

Once in visual line mode I'm looking for a way to move the selected area up and down in the file. Note I'm not looking to actually modify the content of the file in any way just moved the shaded (...
3
votes
1answer
309 views

How do I start overwriting visually selected text without c

I would like to start overwriting immediately visually selected text without any additional keystrokes such as c. I am looking something similar to normal text editor where you can straightaway ...
2
votes
1answer
91 views

Convert a search and replace to a function

Given this search and replace expression, which works fine on one or multiple visually selected lines: :'<,'>s/\v.{-}(`.{-}`).{-}(\\'.{-}\\').*/$this->execSQL('DELETE FROM \1 WHERE id = \2;')...
6
votes
4answers
132 views

How can I delimit sentences by carriage return?

I write screenplays with fountain. Dialogue syntax looks like this: THE TERMINATOR Hasta la vista. Baby. I would like to be able to select the sentence: Hasta la vista., without also selecting THE ...
1
vote
1answer
76 views

remove automatic '<,'> when hitting colon in visual mode

This problem started because I want to run a command in visual mode with :silent! '<,'> command here however if I do a mapping vnoremap ,a :silent! '<,'> command here then in vim runs ...