Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [normal-mode]

Command mode is the initial mode. Vim calls this Normal mode. Not to be confused with command-line-mode, which is what you get after you press :, /, ?, or !

Filter by
Sorted by
Tagged with
0
votes
1answer
29 views

Vim command 0 goes to second column instead of first one

When I press 0 in Normal mode, the cursor goes to the second column and not the first one. This is not the normal behavior stated in vim's :help 0. I have tried disabling the remaps to move between ...
1
vote
1answer
32 views

Replay a vim macro until specified line number

Suppose caret is on the line 10 and I've recorded macros @d. I need to replay macros until line 25. If I know that macros move caret one line per execution, I can calculate that it should be executed ...
1
vote
1answer
74 views

Operator Modifier

I have been using vim mode for atom for quite a while, recently I've been trying to switch to nvim, but I can't seem to find a way to replicate the operator modifiers behaviour, which I've come to ...
1
vote
2answers
254 views

Unexpected behavior from cb command

One of the most basic editing commands is c<motion> to change text, e.g. cw - change word, c$ - change to end of line, cc - change entire line, c3l - change 3 characters to the right. My ...
1
vote
1answer
19 views

detecting insert-normal mode

I notice that when in insert, pressing <C-o> will take me to normal mode, but once I finish pressing a sequence of keys, I get taken back to insert mode. I find this very useful, but I want a ...
13
votes
1answer
7k views

How to use a variable in the expression of a 'normal' command?

How can one use a variable when executing something via normal! in vimscript? Example: function! MyFunction(someArg) normal! (a:someArg)l endfunction This should move the cursor someArg steps ...
4
votes
2answers
254 views

How to delete entire function definition (C style)

How can I delete the block int Test() { // } when my cursor is before int (or even better when it is anywhere on that line)? The shortest I could come up with is d<line>G where <line> ...
10
votes
6answers
1k views

Delete n lines skip 1 line script

I want to create a basic Vim script that simply deletes n lines, skips 1 line and repeats until the end of the document. I don't care about specific matches, I just want to delete the line. For ...
0
votes
1answer
39 views

Using <space> as prefix key in normal mode, cursor will advance one character itself

I put key mapping like this nnoremap <space>d "_d in my .vimrc, so I can delete text more comfortable. But when I in visual mode or visual block mode, the cursor will advance one more column, ...
6
votes
3answers
3k views

Math calculations in vim?

I saw someone insert the result of an equation in vim, but I don't remember how it was done. For example say I want to insert the result of 7*7? How do I insert the results of an equation?
1
vote
3answers
1k views

Paste with space inserted before text

Is there a command to paste (p) text with space inserted before that text like in join? I don't want to achieve that by mapping. Normally p pastes text right in the cursor's position in Normal Mode. ...
4
votes
1answer
145 views

How do I prevent the delay when mapping jj to <ESC> in insert mode?

I've recently mapped jj to <ESC> in insert mode for quick escaping. While everything is functional, I find the brief delay after typing j while it waits for a second input very distracting. Is ...
1
vote
1answer
55 views

Mapping using <Esc> writes “<Esc>” in insert mode rather than switching to normal mode

I have the following line in my .vimrc: inoremap kj <Esc> It had been working fine, ie it returned me to normal mode. But now it inserts the string "< Esc>" (I use the initial space here ...
1
vote
1answer
126 views

How to enter normal mode while in terminal buffer?

Recently I found out that vim has added the :terminal command which opens a terminal buffer within vim, however I see no way to enter normal mode so that I can move around and copy things. Neovim has ...
20
votes
9answers
15k views

How to insert a newline without leaving normal mode

I wonder if I can insert a new line without leaving normal mode. For example, I have two lines: this is line one this is line two And the cursor is on line one. Now I want a new line between line ...
1
vote
1answer
186 views

Backspace functionality in normal mode

I'm trying to allow using backspace in normal mode. My best attempt is adding the following to my vimrc: nnoremap <BS> i<BS><ESC>l. This works great except for two situations: I'm ...
0
votes
2answers
34 views

Return cursor to an initial position after pasting text from a function

in my plugin, i am joining XML tags together depending on a mapping a use. It also uses so i can make XML snippets repetitive. After inserting the text into a buffer, i would like the cursor to ...
1
vote
1answer
60 views

Repeat last normal command

Well, there is ; to repeat the last move in some cases. There is the . to repeat last change. But if I just did za or @a, is there a way to repeat it? I guess such a mechanism should ignore plain ...
2
votes
0answers
20 views

Different behavior when selecting quote blocks vs. selecting parentheses blocks [duplicate]

When I have a line of code such as: result = function(myVar); then I can delete the text "myVar" with the command di( only if my cursor is already positioned inside the parentheses. However, when I'...
0
votes
0answers
111 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 ...
3
votes
2answers
104 views

Jumping to one character past the search

I understand that f jumps to the first matching character, and t jumps to one character just before the first matching character For example, given the string VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, I ...
0
votes
0answers
69 views

Don’t start in insert mode when opening a shell script

How can I prevent vi from starting in insert mode when opening a "test.sh"-like file with the vi-plugin "bash-support" v4.3 ? When I vim test.sh it opens in insert mode When I vim .vimrc it opens in ...
2
votes
2answers
159 views

How to remap repeating commands i.e. <number><command>?

By default, vim lets you type 5G (5 then shift + g) to go to line 5. Instead, I don't want to have to press the shift key. Pressing <S-g> does something different than just 5<S-g>. How can ...
0
votes
1answer
110 views

How to replace a word with spaces

Suppose I have the following text: This is a test of the emergency broadcast system What I want to do is delete the word "test" and replace it with four spaces: This is a of the emergency ...
0
votes
1answer
26 views

Running previous run command that was run in normal mode using colon

Recently I had to compile a latex file a few times, :!pdflatex filename.tex did the trick. But is there a way in normal mode to repeat commands like these which are in the recent history,but used ...
1
vote
1answer
83 views

<Alt> to enter normal mode on Windows

I'm new to vim, and I find using <Esc> to enter normal mode to be slow. I'm on Windows. I seldom use the <Alt> keys (left and right) when I'm editing text. It should be convenient to use &...
1
vote
1answer
21 views

how to add a word two lines above certain word in multiples places

my text look like this in several places of the file: FDE PW91k XCNADD PBE ::FULLGRID END END eor and I want to introduce a word two lines above "eor" word throughout. I have tried :,.-2/eor/...
3
votes
1answer
98 views

Parsing a valid normal-mode command (possibly with regex)? (for Vim-like Word add-in)

I am writing a VBA routine so I can use normal-mode commands in Microsoft Word. (Yes, I am! Edit And here you go!) I am only going to support the d, c, and y operators initially, and only char/word/...
2
votes
1answer
26 views

':norm dtxdty' works different than '0dtxdty', what's happening?

On line ay, 0dtxdty deletes the a (as I would expect), but :norm dtxdty does nothing, norm! and exec don't change it. I wanted to use it as part of a command to align as explained here, but to two ...
0
votes
1answer
70 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, ...
2
votes
1answer
77 views

Why are two <cr> characters required when executing this highlighting toggle command?

I use this keymapping toggle to highlighting on and off, but when I originally found it, the author did not list two <cr> at the end of the command. I found that if I didn't have two <cr> ...
7
votes
1answer
1k views

What is the meaning of 'g'?

Note: this question has two sort of answers on StackOverflow but I thought perhaps a better answer would come from here, and, if not, at least it will be documented where it should be: What are the ...
5
votes
4answers
205 views

Delete with search motion in normal command

I am attempting to delete from start of line until string foo. In normal mode, 0d/foo accomplishes this. Now, I would like to do this for every line in my buffer. Reading documentation and SO it ...
2
votes
2answers
578 views

vimscript: how to get selected text in a register in normal mode? [duplicate]

I am trying to get the mouse selected text in a register in normal mode. If the selection is a substring, only the selection should be copied, not the complete word. Currently the script has: normal!...
0
votes
0answers
46 views

How to get the same message and error behavior as normal `n` when calling `normal n` in function

I wrote a vimscript function that prevents the cursor from changing its location on the screen when I press n: function! my_n() let l:start=line("w0") let end = line("w$") let cursor = ...
5
votes
2answers
178 views

Change text between two $ symbols

If there is some text between quotations, such as "x = 5" I can type ci" in normal mode to delete the text inside the quotations and switch to insert mode. I often want to perform this same action ...
4
votes
1answer
124 views

Motion to jump back one level of indentation, not including blank lines

I've been authoring a lot of F# in Vim lately. Like Python it is pretty strictly indentation-based. However, unlike Python mode for Vim, it does not appear that the standard F# Vim plugin supports any ...
0
votes
0answers
24 views

How to show “/foobar match 1 of ” or “E486: Pattern not found: foobar” in commandline when calling `normal! n` in function [duplicate]

I'm calling normal! n in a vimscript function. If there is a match, I don't get the message /foobar match 1 of 3 in the commandline. If there is no match, my commandline shortly flickers up and down ...
0
votes
0answers
18 views

Multiline search like with f and F [duplicate]

I'm using vim for C programming and I have a question about jumping to the next/previous character. I can use f or F to jump to the next or previous character correspondingly. But this does not work ...
10
votes
2answers
567 views

How do I flip characters or words like emacs' transpose?

On bash's readline in emacs mode, I recently discovered the transpose functionality, giving me the opportunity to quickly fix a typo like dc dir to cd dir by pressing CTRL+T on the c character. ...
20
votes
4answers
2k views

Simplest way to delete a “composite” word?

Apologies if "composite" is not the technical term. I mean the following: Hi, I-am-a-composite-word and we are not I would like to delete only the composite word. In command mode, if I move the ...
0
votes
1answer
44 views

Remap Enter in command history edit window only

I currently have <Enter> mapped to :nohlsearch in normal mode. This allows me to leave search highlighting on for all new searches, but easily turn it off when it (soon after usually) becomes a ...
0
votes
1answer
73 views

How to make this work in insert/edit mode too?

I want to switch between tabs, but this works only in command mode. Is it possible to make this work in edit (insert?) mode too? noremap <C-k> :tabprevious<CR> noremap <C-l> :...
-1
votes
1answer
478 views

How can I pass extra flags to FZF/ripgrep commands with the leader key?

Current functionality When I use <C-P> and <C-Å> I can respectively search file names and contents. Everything works great. Target functionality When prepending either with <leader&...
12
votes
7answers
2k views

Can vim automatically turn off Capslock when returning to normal mode?

After almost every time I type something in caps, I forget to turn off capslock when returning to normal mode. I then try to move the cursor and end up joining a bunch of lines and a lot of other ...
2
votes
1answer
794 views

How to copy lines from 4th till 11th and paste it from 15th till 22th line in ex mode?

To move cursor on the 4th line,toggle into normal mode,input 8yy. To move cursor to 15th line,and toggle into normal mode,press p . Now the lines from 4th till 11th was pasted from 15th till 22th ...
4
votes
1answer
60 views

Make Control-A and Control-X work better for host names and the like

I often am editing a file (e.g., a zone file) where I have things like: Whatever-AP-1 and want to quickly change it to Whatever-AP-2. It feels right to hit Control-A (increment), but of course Control-...
1
vote
1answer
314 views

How to use normal mode commands in ex mode?

When I start vi/vim as ex, I can use the -c option to provide the set of ex commands to apply to a file: echo Yes | ex -sc 's/Y/y/|%p|q!' /dev/stdin yes But how can I use normal mode commands like ...
2
votes
1answer
88 views

What is the difference between ^ and _ for cursor movement

They both seem to move the cursor to the first non-blank character of the current line and I wonder what was the reason for duplicating this functionality
0
votes
1answer
33 views

How to move a line onto the end of some other line

For example suppose i have 1 the cat jumps 2 over the moon I would like the result 1 the cat jumps over the moon In general how can I move line X onto the end of line Y. A solution that would ...