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
1answer
28 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 ...
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 ...
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
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
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>...
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 ...
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 ...
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", ...
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 ...
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 ...
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 ...
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 ...
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 ...
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
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 ...
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
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
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 (...
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 ...
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?
1
vote
1answer
58 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
1answer
77 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 ...
10
votes
6answers
2k 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
43 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, ...
1
vote
1answer
154 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 ...
2
votes
1answer
417 views

How to enter normal mode while in terminal buffer? [duplicate]

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 ...
1
vote
1answer
573 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
38 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
144 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
202 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
74 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
232 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 ...