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
0answers
3 views

Keyboard mapping that mostly avoids Shift or Ctrl

I prefer to avoid pressing Shift and Ctrl keys when navigating code and doing minor edits. I rather type 2 small letters than Shift-key or Ctrl-Key combinations. Yet many commands in Vim require to ...
1
vote
1answer
24 views

Why my file is closing before finishing executing my normal commands?

I have a file with random content like the following: random content random content random content If I execute the normal command with :execute "g/./normal inewstring-" I get the following ...
0
votes
1answer
38 views

How to return to normal mode by pressing ESC only once

I have been using vim for a short time, so I may not know a lot, please forgive me. There is a problem with my vim. It cannot enter normal mode from insert mode by pressing esc/ctrl-[ only once, but ...
0
votes
2answers
36 views

How to convert spaces on a line to tabs?

I know there's a way because it happened by accident. I was frenetically moving in a short region of text and at some point, with some wrong keystroke, the leading spaces on the line became a tab (and ...
0
votes
0answers
17 views

Map a key in “search mode” [duplicate]

"Search mode" is not a true mode, but is it possible to create mappings that only apply while typing a search after / or ?? I am wondering how one would go about mapping <C-f> to start ...
0
votes
1answer
18 views

How to group all `cscope` related configuration into `augroup`, so it's only applied for C/C++ files?

How can I group all cscope (:cs) related configuration into e.g. autocmd, so that this configuration is only applied to c or cpp files? I have been looking at e.g. this, but it only address a single ...
0
votes
0answers
21 views

What keywordprg do you use for javascript?

I've recently learnt about using K in normal mode to get the manual information of the word under the cursor. In this regard, I'd like to know what programs I could use to handle javascript files, or ...
0
votes
0answers
17 views

How to automatically start in Normal mode? [duplicate]

I am using zsh on Mac and noticed that whenever I start vim, it always starts in insert mode. I use vim to inspect files more often than to edit. I tried adding set noinsertmode but it didn't have any ...
1
vote
0answers
20 views

Change colour of character under cursor?

I'd like the character under my cursor to always be black in normal mode, so it contrasts with the cursor. I'm using windows terminal, which doesn't support this directly, and vim (not gvim), so guifg ...
0
votes
0answers
32 views

VSCode Vim — don't want escape to enter normal mode if I'm exiting tooltip or Intellisense

I'm new to VIM and I'm loving it. I'm learning slowly but surely. I've passed the point where there's enough benefit and not too much hassle. I'm using the VS code integration. I'm learning VIM (...
1
vote
1answer
22 views

How to map UTF-8 symbols to numbers in command-line mode?

Sometimes I change input source (keyboard language) and my number buttons get mapped to rarely used UTF-8 symbols, e.g. 1 gets changed to ą, 2 to č, 3 to ę, etc. I have managed to map them in normal ...
1
vote
1answer
21 views

Why does “cw” from middle of current word not move to beginning of next word like “w” or “dw”? [duplicate]

Example scenario I have this text consisting of two columns with different words of different lengths and alignments: asdf foo bar qwer zzzzz xx Let's say I want to abbreviate the first ...
0
votes
1answer
32 views

noremap in .vimrc for YouCompleteMe does not work

noremap <leader>gdf :YcmCompleter\ GoToDefinition<cr> noremap <leader>gdc :YcmCompleter\ GoToDeClaration<cr> noremap <leader>gi :YcmCompleter\ GoToInclude<cr> ...
0
votes
0answers
33 views

What is the shortkey for adding a space before a word in normal mode?

I have the following text: #Text My cursor is on character T; I want to obtain # Text i.e., to put a space between # and T, without "pressing i and then space". Instead, I want to do so in ...
1
vote
1answer
47 views

Execute normal command after opening email in Mutt

I'd like to use ftplugin/mail.vim to execute a normal command after opening an email in Mutt. Specifically, when replying to an email, I'd like move the cursor after the header fields (I have set ...
2
votes
1answer
71 views

Search and yank in visual line mode with execute normal

I have this in a buffer: aaa bbb ccc ddd eee with the cursor on the first line. I do :execute 'normal! jV/ddd\<CR>y' which I expect should result in the middle three lines yanked. But what ...
1
vote
1answer
45 views

Is it possible to document or add comments to a scriptin file?

I have a lengthy scriptin that I'm using to help me convert JavaScript files to Typescript. There are about 30 commands defined in it so far: :%s/^\(\s*\)params\.\(\S\+\) = \(.*\);/\1 \2: \3,/ :g/...
0
votes
1answer
30 views

Record the mode before pressing <c-\><c-n> in terminal

I want to restore the pos of cursor in terminal when I reopen the terminal: If the mode was terminal mode before, it is easy to feed a 'a' to terminal to change from normal mode to terminal mode. If ...
2
votes
2answers
42 views

Delete the content and the brackets of a level above while inside in the inner level

My cursor is at H { //foo { //bar { //cursor is Here } //bar2 } } How do I delete the outer layer of brackets while keeping the layer where my cursor is intact? End result ...
0
votes
1answer
38 views

Keep open fold open on `o`

I have a file with foldmethod=indent. I have the folds automatically open when I enter them, and close when I leave them. When I sit in Normal mode on the bottom line of a fold and press o, the fold ...
0
votes
0answers
32 views

<number>dd not doing anything on an ubuntu machine

I use 999dd as a goto command before pasting/overwriting the entire contents from the clipboard. For some reason this is not working (at all) on a specific ubuntu machine. Why would this not work be ...
1
vote
3answers
142 views

How can I delete whitespace backwards until end of previous word?

I want to delete whitespace backwards until end of previous word. Say, I have the cursor on the character "d" in the word "dog": horse cat dog If I press Ctrl-W (Insert ...
-1
votes
1answer
104 views

In Vim, Save in normal mode

I am trying to improve my skill with vim. And I know ESC : w for to save. But in normal mode the shortcut for w is for "to the next word". is there another key for to save quickly? or I need ...
1
vote
1answer
35 views

How to jump back to current location after using key-binding `noremap <Leader>bA gg"*yG` without appending `<C-o><C-o>`?

I have created the following key-binding for copying all text in the buffer to the system clipboard: nnoremap <Leader>bA gg"*yG However, it moves the cursor, so I need to append <C-o>&...
1
vote
0answers
39 views

How to repeat `f <char>` in opposite direction when using `,` as the map leader?

I have set mapleader="," in my ~/.vimrc. How can I continue to repeat f <char> in the opposite direction, when using , as the map leader? Is it possible to remap , in the context of f &...
3
votes
1answer
63 views

Does “:norm! @q” use mapped keys inside the macro?

The documentation for :norm[al][!] states that "mappings will not be used" when the ! is written. Consider the following setup commands: :nnoremap \c Chello<esc> :let @q = '\cIthis is ...
4
votes
1answer
102 views

How to map `/` to `/\v` in Normal mode without moving the cursor?

I've created the following simple mapping in Normal mode, since I don't want to enter \v for "very magic" regex parsing, every time I use the / search command: nnoremap / /\v However, after ...
2
votes
3answers
360 views

Execute command for multiple files

I find myself often in the situation in which I want to run multiple vim commands on a multiple files. Consider file1.txt, file2.txt, file3.txt I would need to run :retab and then some :%s/ /, / for ...
0
votes
0answers
18 views

Why does disabling arrow keys in Insert mode (e.g. `inoremap <left> <nop>`) result in e.g. `0D` being written? [duplicate]

I want to disable the arrow keys in Insert mode, since I want to force myself to always go into Normal mode for performing movements. To achive this, I've made the following mappings for Insert mode, ...
4
votes
2answers
52 views

How can I use `ci'` to change the N'th occurrence of single-quoted text in a line?

I find the ci' (and similar commands) very useful, since I can execute it at the start of the line, and it will automatically change the first occurrence of text between single quotes ('...'). However,...
5
votes
2answers
117 views

Break the undo sequence in normal mode

Question: Is there something which is works same as i_CTRL-G_u, but for normal mode? This would be useful in mappings (like nnoremap), because (I think, but fixme) in normal mode, if you are just ...
0
votes
5answers
185 views

I keep forgetting which mode I'm in

My main problem is that I don't realize which mode I am in each time I use vim. Sometimes I forget to <ESC> into normal mode, hence pressing vim commands in insert mode. I have to waste time ...
2
votes
3answers
134 views

How do vim users type/edit while switching between modes?

I'm not talking about learning or introducing commands, but how to work by switching between modes, and using normal known commands. Do most vim users stay more in normal mode instead of in insert ...
1
vote
0answers
19 views

How to prevent `autocmd` for stripping trailing whitespace for moving the cursor? [duplicate]

I've the following autocmd for stripping trailing whitespace in a buffer, every time the buffer is written to a file: " trim whitespace autocmd BufWritePre * %s/\s\+$//e However, the autocmd has ...
1
vote
1answer
20 views

Unable to execute a substitute regex from inside a function

I have this function: function! Insert_article() execute "normal! :r !insert_article.pl\<cr>" execute "normal! :%s/\v^(#+\s+[^\n#]+)\n([^#]*#+)/\1 \2/g\<cr>" ...
1
vote
1answer
41 views

How to map a keybinding to a command which includes <C-U> (scroll-up) in my .vimrc?

I want to map a keybinding to a command which includes <C-U> not for clearing the command line but for scrolling the page up. Executing a command like this in my vim session works totally fine: :...
1
vote
1answer
70 views

Is it possible to view a history of commands (per mode) executed in Vim?

I sometimes execute commands in Vim by mistake, either in normal-, visual-, or ex-mode and have no idea what was executed. Is it possible to see a history of executed command per mode in Vim? I know ...
1
vote
1answer
35 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 ...
2
votes
2answers
86 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
27 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
25 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
57 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
154 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
51 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:...
2
votes
1answer
160 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
54 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
20 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
84 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>...
3
votes
0answers
19 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 ...
18
votes
3answers
3k 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 ...

1
2 3 4 5