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
1
vote
2answers
50 views

Check pending command state

Is it possible to check if a normal mapping/command is being typed? That's also when the showcmd setting takes effect. I can't seem to find anything about this in the doc, no autocmd-event nor related ...
1
vote
1answer
27 views

Typing d in insert mode briefly moves cursor backwards

In Vim, when I'm in Insert mode and hit d, the cursor moves back one spot for a second, then jumps back to behind the letter just typed. This is quite distracting when typing texts. It looks like Vim ...
7
votes
4answers
1k views

Splitting a line into two

We can make from two lines a single with J. It looks as the following: line 1 line 2 after J pressed on line 1 we've got this: line 1 line 2 But is there a combination which what do the opposite (...
0
votes
1answer
16 views

Join values by keys

I would like to use VIM to group a file by keys (e.g. "asian") and join the associated values. The keys are already sorted. Example: asian <==> asiat asian <==> asiatisk asiatic <==&...
0
votes
0answers
22 views

cursor moves in range

I have this function that gets range. From the help: The cursor is still moved to the first line of the range, as is the case with all Ex commands. Can it not do it? I just want to ...
2
votes
2answers
1k views

Remapping tab key to autocomplete in commandline mode in Vim

I am using Vim 7.4 and I wish to map the tab key so I can use new combinations to autocomplete arguments in command mode from the current directory Contents of current directory: Funwithstrings.cs ...
2
votes
0answers
38 views

how to have two different colour schemes for command mode and edit mode in vim?

I have been using vim for some time now but I am always unsure of which mode I am currently in and hence end up pressing Esc too often even in the command mode. This causes an irritating computer ...
0
votes
2answers
26 views

Why do I have to press the caret button twice to go to the beginning of the line?

When I press the caret button in normal mode, vim first prints a caret at the cursor position. Only with the second press of the caret button does the cursor actually move to the beginning of the line....
2
votes
1answer
48 views

Put cursor at arbitrary line and column

Normal, insert, and visual modes restrict cursor movements to locations occupied by some characters. They don't allow moving to the right from the end of line and down beyond end of file. For example:...
1
vote
1answer
12 views

execute + colon character doesn't work

I want to :retab selection in my vimscript function. When I write execute "normal! :'<,'>retab" nothing happens. If I write: let cmd = "normal! :'<,'>retab" echom cmd The output is ...
1
vote
1answer
28 views

How can I use the `:term` command without closing the current window on exit?

I often use the :term command in my projects to create new directories or perform other work. However, if I have multiple windows open, then executing :term from one of them will also close that ...
1
vote
2answers
1k views

key mapping <C-'> (Ctrl single quote) not working

I have this line in my .vimrc nnoremap <C-'> :marks<CR> and want to use Ctrl-' to show all marks. Sadly, it never works, be it on ubuntu, cygwin, or windows 10. After vim 8.0 was ...
7
votes
2answers
3k views

How to repeat last action with movement?

Assume the content: foo fnord bar;" >> /tmp/foo/derp gnarf foo fnord bar;" >> /tmp/foo/derp I want to jump to the " and delete to end of line and repeat that over the rest of lines. Yet ...
1
vote
1answer
18 views

Overwrite text object with single char

I'm looking for a way to replace the text print("This is a test") by print("**************") i.e. i want to overwrite every character of a text object (the string inside quotes) or up to a ...
0
votes
1answer
31 views

Simulate backspace in normal mode

I would like to have the delete key work similarly in normal mode as it does in insert mode, and it's been a bit tricky to map this. Here is what I have so far: :nnoremap <Backspace> i<BS>...
16
votes
3answers
2k views

Change an entire line in Vim

Is there a way to delete a full line and start with an insert? Normally I would do: 0 (go to start of line) C (delete to end of line and start insert) But is there a command to do the above without ...
2
votes
0answers
13 views

How to disable mouse scroll wheel when in normal mode?

I want to completely disable the mouse but mouse scrolling in normal mode is not disabled. I have disabled other mouse function but scrolling in normal mode is still on. To disable the mouse I have ...
0
votes
2answers
27 views

Cursor difference with “Esc” and “Ctrl + O”

Say I have a session like this: Sunday|Monday Where | is the cursor in insert mode. If I press Esc, I get this: Sunda█Monday but I want this: Sunday█onday As I want to select the second "word", ...
0
votes
2answers
17 views

Visual mode word behaves differently than in normal mode?

Say I have the text: This is a test! If my cursor is on the first character, "T", and then I do d4w, then I am left with just !. However, if instead I do v4wd then I'm left with nothing (i.e. the ...
1
vote
1answer
36 views

Why doesn't inoremap work in this case

I'm coding c++ with vim and I want to set a shortcut while typing parenthesis and new line. Here is an example, if (a == 1) {}| // the cursor is at the end of the line and the vim is under INSERT ...
2
votes
0answers
13 views

vim command mode g++ doesn't pick the bash alias [duplicate]

I have g++ alias defined in my .bashrc file as alias g++='g++ -Wall -DLOCAL=1' I am invoking following command from vim command/normal mode to compile a program - !g++ % The issue is, this ...
1
vote
2answers
45 views

How can I make external command use current line as input and append output to end of same line?

Using Vim 8.0 I'm trying to make a table where the first column is the name of a file and the second column the creation date of such file, to which I have access by the exif data. I would like to ...
0
votes
0answers
33 views

Remove command echo in status bar

I've noticed that sometimes in ViM the status bar shows me the command I've just executed (for instance, if I keep the key 'l' pressed to keep going right, I see at the bottom right of the screen a ...
0
votes
1answer
49 views

Automatic insert mode and normal mode switching

Coming from emacs, jumping to the end of the line is easy: CTRL + E I have been recently trying out Vim, and I found out you need to first exit insert mode to then use commands. So, in Vim, I need ...
2
votes
1answer
80 views

Why doesn't d_ delete to the first non-blank character on the line?

v^ and v_ both select to the first non-blank character on the line. d^ deletes to the first non-blank character on the line, but d_ deletes the entire line. Why is this? Is there any reason to use ...
0
votes
1answer
27 views

Normal mode Backspace and Delete

If I have a file like this in Insert Mode (pipe is cursor): Sunday | Monday I can press Backspace or Delete to remove the empty line. However in Normal Mode, neither of those work. I have been ...
3
votes
1answer
67 views

delete brackets and select region

Is there a quick way to delete brackets ( some string ) and then select "some string"? ds( deletes them (using the surround plugin). vi( selects but only when they exist. looking for normal mode.
3
votes
1answer
95 views

Is it possible to place marks at the end of a line?

Typical mark placement using m places the mark at the cursor. When the cursor is on the last character of a line, this means that jumping to that mark for the purpose of copying text starts the ...
35
votes
10answers
32k 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 ...
0
votes
2answers
38 views

How to delete entry from indented argument from list?

Let's say with the cursor I'm on b in def f(a=1, b=2, c=3, e=4 ) and we want to delete the whole argument including the line break, so that we get def f(a=1, c=3, ...
3
votes
1answer
50 views

How do I reduce the height of the area where commands are entered?

I seem to have messed with some settings which have resulted in the area where I enter commands now being 2 characters in height. See the screenshot below: What do I have to set in my init.vim file (...
3
votes
1answer
144 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
34 views

Edit NERDTree text using normal mode vim keybindings

When using the "Add Childnode", "Move Node", "Copy Node", etc. options through the "m" menu, it opens up a text field to type in the name of the destination file. Unfortunately, I cannot figure out ...
1
vote
2answers
46 views

How to indent the cursor to the indentation of the above line in insert mode?

I previously asked the following question on how to indent the cursor to the identation of the above line: How to ident the cursor to the indentation of the above line? A correct answer was provided ...
0
votes
1answer
90 views

How to ident the cursor to the indentation of the above line?

I want to move the cursor to the indentation of the line above. As seen from the example below, when I move the cursor down (j or arrow-down), it goes to the start of the line. This is both true for ...
0
votes
1answer
45 views

How to prevent Vim from making a flashy screen effect when pressing `ESC` or `^[` in normal mode?

I often press ESC/^[ to ensure that I've left insert mode and entered normal mode. However, if I'm already in normal mode, Vim displays an annoying flashy screen effect: How can I prevent Vim from ...
10
votes
2answers
2k views

Is there a way to insert a single character and then exit insert mode?

When I'm going through text and, for instance, adding backticks around certain words or quotes or whatever, it is irritating that I have to press Esc or Ctrl-[ after each insert. The inserts (and ...
0
votes
1answer
50 views

Paste word under cursor into new line

In normal mode I want to be able to select a word and when I press <leader>i yield the following string in next line, The word is <word_that_was_highlighted>. Is it possible to do this in ...
0
votes
1answer
33 views

:o autocomplete

Without any plugins, I am able to autocomplete :vsp filena<tab> I wonder why I don't get autocompletion of filenames with :o. I have tried this in different installations, terminals and OS.
2
votes
1answer
125 views

Yank then Paste without moving cursor

I want to be able to: :42y then something like: :13p having it to paste the yanked line in a new line after 13, without taking my cursor away. So far, all solutions I have found involves going to ...
3
votes
2answers
1k views

What is the difference between normal mode and command line mode?

Normal mode is also called command mode, and is different from command line mode. It seems both can be used for : commands, but what is the difference?
5
votes
1answer
200 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
57 views

How to execute with call and <C-R>/ matching?

I want to count the searching pattern and here is my code: execute '%s/' <C-R>/ '/\=' . Count(submatch(0)) . '/gn' Here is my Count function: function! Count(match) if has_key(b:types, a:...
0
votes
1answer
49 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
68 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 ...
2
votes
1answer
98 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
336 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
76 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 ...
15
votes
1answer
9k 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 ...
5
votes
2answers
840 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> ...