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
28 views

Set cursor anywhere in window

How to setup Vim so you can f.e mouse click in the middle of new opened empty Vim window and place cursor exactly there ( f.e line 23 char 49), instead of line 1 char 1 because? Is there better way ...
7
votes
1answer
335 views

How to prevent Vim from clearing the system clipboard (:reg +) on exit?

After copying text to the system keyboard clipboard in vim, I'm unable to paste the text after exiting vim. I find this behavior frustrating, since I often copy text in files to paste it on the ...
0
votes
1answer
41 views

How to select non-uniform length strings from within multiple lines

Suppose I have this data: import { york1400 } from "./data/york1400"; import { york1430 } from "./data/york1430"; import { york1500 } from "./data/york1500"; import { ...
1
vote
2answers
53 views

How to make an user-defined command that works in normal and visual mode?

Goal I would like to create a command that can automatically put an x inside a []. This command should work in both normal mode and visual mode. normal mode If it is in normal mode, and the cursor is ...
1
vote
1answer
32 views

How can I start a :terminal in terminal-normal mode?

I want to run an async command and when it completes open a terminal window. Since the opening is delayed, I don't want it to steal input from me, so the new window should be in Terminal-Normal mode. ...
0
votes
0answers
16 views

How to add a line at the beginning of my file from normal mode?

I'm trying to add the line HELLO WORLD to the beginning of my file from normal mode. How do I do this?
1
vote
0answers
35 views

How to do a motion without leaving history (in .)?

Often, you do a complicated motion, which you want to repeat soon by pressing . but carry out a simpler motion overwrites that one. Can I keep that complicated motion in . itself ? Concrete example: ...
0
votes
1answer
33 views

Why does cw followed by ctrl-r register consist of two edits?

I did cwCtrl-Ra at the beginning of a word to paste the content of register a in its place. And this, I thought, is done entering insert mode only once; or at least, never going back to normal mode. ...
3
votes
1answer
43 views

Curious behavior of :%normal g_lD (remove trailing spaces in file)

This is a noob attempt of mine, to remove trailing spaces in a file. The first attempt is: :%normal g_lD It worked, and I was happy. Then I tried it on a single line where there was no trailing ...
0
votes
1answer
39 views

How to make cursor move to the top line inserted with 2O?

Using a simple example: h[]ello If I type 2o<esc>, the cursor will be moved to the last inserted line like this: hello [] But if I type 2O<esc>, the cursor will be moved to the last ...
1
vote
0answers
28 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
30 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 ...
1
vote
2answers
62 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
71 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
20 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
26 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
31 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
21 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
95 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
170 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
25 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
28 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
51 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
78 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
80 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
41 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
47 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
62 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
35 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
208 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
186 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
37 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
49 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
67 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
139 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 ...
3
votes
3answers
921 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
62 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
193 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
329 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
207 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
21 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>" ...
2
votes
1answer
84 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
96 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
45 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
105 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 <==&...

1
2 3 4 5