Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
1 answer
22 views

Only highlight trailing whitespace in normal mode

I have some code in my ~/.vimrc to highlight trailing whitespace. " Highlight trailing whitespace hi TrailingWhitespace ctermbg=red guibg=red matchadd("TrailingWhitespace", '\v\s+$') I ...
user avatar
1 vote
1 answer
29 views

Ctrl+Arrows work differently in normal mode and in insert mode

For some reason, in my VIM there is a difference in behaviour of Ctrl+Arrow keys in normal mode and in insert mode. To demonstrate this, I edit the file which contents are: aaa.aaa,aaa/aaa!aaa@aaa#aaa$...
user avatar
  • 21
0 votes
0 answers
20 views

a `nnoremap <buffer><silent>` on .vimrc make the curssor very slow on normal mode

To automate a bit the title creation for rst text I added this to my .vimrc: au FileType rst nnoremap <buffer><silent>h1 yypVr=o au ...
user avatar
2 votes
1 answer
46 views

'de' and 'e' is not analogous to 'dw' and 'w'

(Context: I am doing the vim tutor) Exploring 'e' and 'w' commands I noticed 'e' places the cursor on top of the last letter of the current word, and if I type 'de' with the cursor somwhere between ...
user avatar
1 vote
1 answer
29 views

Special characters, escaped special characters, escape sequences, and terminal codes

I refer to those 4 terms using terminology picked up by various sources: Steve Losh, in his Learn Vimscript the Hard Way's chapter 16 refers to things like <cr> (these 4 characters typed in a ...
user avatar
  • 1,572
0 votes
2 answers
51 views

Can Vim be configured to leave insert/replace mode when I use the cursor keys

I find I forget to leave INSERT or REPLACE to navigate around the file with cursor keys, Page Up, Page Down, etc. Or, I walk off from the computer to make my coffee, or whatever. Then when my brain ...
user avatar
  • 103
2 votes
2 answers
90 views

How to speed up cursor movement?

When I hold the key k to move cursor up, is it possible to speed up the cursor movement? I know that I can combine number with command (like: 20k) to move up many lines, but sometime I just prefer to ...
user avatar
  • 163
0 votes
0 answers
40 views

$ moves caret past last character

This is the starting situation: Now I press $: Now I press i: Now I press Esc: Why did the $ move past the end of the line?
user avatar
1 vote
2 answers
32 views

`db` including current character

When in normal mode, with the following (^ indicates cursor position): Lorem ipsum ^ How do I delete the entire word ipsum in the least keystrokes? Things I've Tried: db gets Lorem m ^...
user avatar
1 vote
1 answer
33 views

Visually select two words in Vim

Say I have a phrase is later found at and what to delete a phrase later found, then what I do would be In the normal mode, I put a cursor on l, and press vww. This will select from l to a of at. This ...
user avatar
  • 379
4 votes
1 answer
44 views

Speedier indentation of many files

I recently needed to re-indent a large number of files. I used variations of: find . -type f -exec vim -c "normal gg=GZZ" {} \; Which worked well, but incredibly slowly (across several ...
user avatar
  • 141
0 votes
1 answer
23 views

Quickest Way To Fold Using Marks

I've found if do :set number, I can fold between specific lines x and y with xGzfyG or easier for me xggzfygg. That's great but it's a distraction to find the line numbers as is [visual]zf. I use ...
user avatar
4 votes
1 answer
56 views

Are there any commands starting with Z other than ZZ and ZQ?

As far as I understand it is the only two commands that exist. And this "Z" chosen because it not used for anything else. But I am not sure. Sorry for such basic question. I tried to use :...
user avatar
1 vote
3 answers
211 views

How supply range to normal mode key-binding?

I've created a mapping to a function that accepts a range. Like this: command! -range Test call TestFunc(<range>,<line1>,<line2>) nnoremap <leader>t :Test<CR> How do I ...
user avatar
  • 211
6 votes
2 answers
2k views

Ctrl-A and Ctrl-X doing the opposite of what they should

I had the following piece of Markdown text that I wanted to edit: * 2-6 for a moka pot * 7-10 for a drip machine * 5-12 for a pour-over When I had the cursor over the number 6 in the first bullet ...
user avatar
0 votes
0 answers
19 views

How to override current command

I have Template command installed from sonicteomplate The problem with this plugin is, when I call a plugin, the cursor jumps to where {{_cursor_}} is, but it stays in normal mode, it doesn't go to ...
user avatar
  • 379
0 votes
0 answers
11 views

How to leave insert mode immediately with python (or force vim to dispatch its event queue)?

Reproduction step : Use this vimrc : function! Ttt() py3 << EOF vim.command('echom mode()') vim.command('stopinsert') vim.command('echom mode()') EOF endfunction au InsertChange * :call Ttt()...
user avatar
  • 101
0 votes
1 answer
71 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 ...
user avatar
7 votes
1 answer
393 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 ...
user avatar
  • 995
0 votes
1 answer
44 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 { ...
user avatar
  • 197
1 vote
2 answers
98 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 ...
user avatar
  • 567
1 vote
1 answer
44 views

Run :terminal so it starts 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. ...
user avatar
  • 485
0 votes
0 answers
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?
user avatar
  • 101
1 vote
0 answers
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: ...
user avatar
  • 43
0 votes
1 answer
35 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. ...
user avatar
  • 1,572
3 votes
1 answer
44 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 ...
user avatar
0 votes
1 answer
55 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 ...
user avatar
1 vote
0 answers
33 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 ...
user avatar
1 vote
1 answer
31 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 ...
user avatar
  • 375
1 vote
2 answers
95 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 ...
user avatar
0 votes
2 answers
204 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 ...
user avatar
  • 1,572
0 votes
0 answers
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 ...
user avatar
  • 255
0 votes
1 answer
33 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 ...
user avatar
  • 995
0 votes
0 answers
25 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 ...
user avatar
  • 101
1 vote
0 answers
269 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 ...
user avatar
0 votes
0 answers
312 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 (...
user avatar
  • 101
1 vote
1 answer
38 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 ...
user avatar
  • 1,073
1 vote
1 answer
45 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 ...
user avatar
  • 113
0 votes
1 answer
70 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> ...
user avatar
0 votes
0 answers
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 ...
user avatar
  • 101
1 vote
1 answer
101 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 ...
user avatar
2 votes
1 answer
87 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 ...
user avatar
  • 295
1 vote
1 answer
47 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/...
user avatar
0 votes
1 answer
50 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 ...
user avatar
2 votes
2 answers
76 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 ...
user avatar
  • 123
0 votes
1 answer
103 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 ...
user avatar
  • 69
0 votes
0 answers
50 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 ...
user avatar
1 vote
3 answers
304 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 ...
user avatar
  • 995
-1 votes
1 answer
273 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 ...
user avatar
1 vote
1 answer
44 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>&...
user avatar
  • 995

1
2 3 4 5 6