Stack Exchange Network

Stack Exchange network consists of 174 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.

2
votes
1answer
67 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
68 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
70 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
42 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
104 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
42 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.
1
vote
1answer
55 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
55 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
35 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
150 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
35 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
36 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
50 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
69 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
51 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
49 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
46 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
132 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
60 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
126 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 ...
0
votes
0answers
36 views

gx doesn't work on visually selected text

I have a link to a pdf file in my vim which contains spaces. I'm trying to open it with external app. While with gf I can visually select the text (e.g. a b.pdf) and open the pdf as a text file but ...
1
vote
1answer
65 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
102 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 ...
0
votes
0answers
25 views

Visual mode - select text from the first character of the line with Home key

In my vimrc file I use the following setup to map the HOME key to jump before the first character of the line: :set keymodel=startsel,stopsel :noremap <silent> <Home> ^ :vnoremap <...
0
votes
0answers
54 views

Visual selection and replacement in multiple lines to perform DIFFERENT edits in vim

How can I select different portions of multiple non-contiguous lines and replace them with the different text? Example: Let's say my buffer looks like this: Roses are reed, Violets aree blue, yellow ...
0
votes
2answers
242 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” ...
1
vote
1answer
41 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 ...
1
vote
2answers
73 views

How to select/delete/yank the contents of only the current fold?

When using foldmethod=marker, how do you select or reference exactly the contents of the current fold? I want to swap the order of two folds. If they were paragraphs, I would do dap { p. However, I ...
0
votes
1answer
220 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
39 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
44 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
154 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
29 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
69 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 ...
2
votes
1answer
61 views

Linux gvim visual mode cursor - avoid newline selection

When I enter in visual-mode and I want to delete a block of text before the newline character (only visible if selected/highlighted in visual-mode), I accidentally always select the newline character ...
0
votes
1answer
47 views

Writing text to multiple lines in different locations of the text file

One feature useful to me is Ctr-V column visual mode. This way I can avoid typing lines nearly the same multiple times. Is there a way in vim I can do this over a range like 5,14,22,.. so that the ...
0
votes
2answers
123 views

Linux gvim - toggle/retain insert-select mode while Shift key is pressed

I noticed using evim that when I press Shift key plus any direction key (so <S-Up>, <S-Down> etc., the editor automatically switches to insert-select mode, letting me select the text block ...
1
vote
1answer
170 views

How to select text character by character with shift and directions?

I would like to know how I can select text character by character, in visual mode, using a combination of shift+direction without using the mouse. Actually, with Shit + Left/Right gvim selects the ...
1
vote
1answer
51 views

reset count for `v`

According to :help v a count of 1 provided to v will select the same number of characters as the previous selection, but starting from the current cursor (see full help below). When there was no ...
1
vote
2answers
99 views

Select a backtick-delimited block, rather than an inline string?

I'm editing some Javascript in which the following is common: var foo = ` a bunch of text and stuff `; And I'd like to quickly be able to select the entire block between the backticks, like I ...
1
vote
1answer
480 views

get string from visual selection [duplicate]

Having some text selected in visual mode, I need some way of turning it into a string that can be used in an expression. I have tried this function! VisualSelection() normal! `<""y`> ...
1
vote
0answers
56 views

Vim operation - creating a new text object selector for entire file [duplicate]

You can do dap, or vap, etc to select a paragraph. I want to be able to select/yank/delete the entire file. One way to do this would be to have: vnoremap af ggoG$ nnoremap yaf ggVGy nnoremap daf ...
1
vote
2answers
238 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 ...
3
votes
2answers
121 views

Highlight everything inside (, [, and { and expand outwards

Suppose I have a line of text of the form (123[456{789}abc]def) and the cursor is inside the curly braces. In sublime text, we can use ctrl-shift-m repeatedly to jump to highlighting 789, {789}, 456{...
2
votes
2answers
121 views

Help to implement script that toggle single and double quotes

I have following function! s:get_visual_selection() let [line_start, column_start] = getpos("'<")[1:2] let [line_end, column_end] = getpos("'>")[1:2] let lines = getline(line_start, ...
6
votes
1answer
300 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
397 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, ...
4
votes
3answers
148 views

How to decrease markdown header level in visual mode without a plugin?

I have a file like this: # Heading A ### Heading B1 lorem ipsum ### Heading B2 lorem ipsum and I want to reduce the header levels of B1 and B2 to look like this: # Heading A ## Heading B1 ...
2
votes
1answer
80 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.