Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [visual-mode]

Visual mode is a flexible and easy way to select a piece of text for an operator.

0
votes
3answers
61 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
43 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
29 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
22 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
59 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
60 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
28 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
348 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
23 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
29 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
27 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
24 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
50 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
29 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
53 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
37 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
59 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
98 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
79 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
60 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 ...
3
votes
2answers
119 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
47 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.
3
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
80 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
202 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
65 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 ...
1
vote
1answer
91 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
77 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
47 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
76 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
96 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
101 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
113 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
235 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
79 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
129 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
72 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 ...
1
vote
2answers
281 views

How to change highlighted text?

I write using LaTeX a lot for scientific writing. I often need to modify some text that includes numbers and units like: 4.2 cm into: \SI{4.2}{cm} to be properly typeset by LaTeX. Of course, the ...
1
vote
2answers
516 views

How do I add text before and after the visual selection?

Suppose I’ve selected some text in visual mode. How do I insert a certain piece of text at the beginning of the selection and a different piece of text at the end? (I’m only concerned with “normal” ...
2
votes
1answer
53 views

Key binding to select the current paragraph

I'm using the following key binding to visually select the current paragraph. nnoremap <leader>v }kV{j Is works as follows: } Move below the current paragraph. k Move one line up. V Start ...
0
votes
1answer
323 views

How to yank word from all selected lines in visual mode?

In the middle of a line, Press v and select multiple lines. How to yank the word at current cursor from all selected lines and add spaces if the word is shorter than the longest one to make copied ...
0
votes
1answer
46 views

sublimetext vintage mode, vs VIM trying to find a substitute for a shortcut key [closed]

So in vim usually I press v j j j > esc then gv to reselect so that I can indent a couple of lines. How can we reselect in VI?
0
votes
1answer
69 views

Is it possible to do not expand the Visual-mode selection with ScrollWheelUp/Down?

When I select some text in Visual mode (either with keyboard or mouse), and I scroll the mouse wheel up/down, the visual mode expands the selection in up/down direction according to the mouse ...
1
vote
2answers
355 views

How can I visually select a regex match?

Sometimes I just want to see whether a regex is matching the right stuff. If I could cause Vim to visually select the matching text, it would be one way to do this. Is there a method for doing this?
0
votes
1answer
45 views

Replicate normal mode function in visual mode

I had the following mapping to go to the 1st non blank character of a line nnoremap M ^ I then decided that if I was already at the 1st non blank character I wanted M to take me to the absolute 1st ...
1
vote
1answer
90 views

What is Lang-Arg in vim?

I was seeing the docs in :help map-mode where I saw that map! works for Insert and Command-line modes while lmap works on Insert, Command-line, Lang-Arg But I've never heard of Lang-Arg mode. Can you ...