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
2 votes
1 answer
57 views

How can I have <C-E> and <C-Y>'s normal mode functionalities also work in insert mode?

Once I've asked a general question about special characters, but I've not really pulled anything out of it. So now I'm asking a very specific question. I want to have Ctrl+e and Ctrl+y behave in ...
  • 1,756
5 votes
2 answers
1k views

What does g CTRL-A really do?

Today I had that old feeling of wonder on how powerful VIM is: I needed a number sequence in the start of some fields and discovered the power of g CTRL-A. So as I always do when I discover something ...
2 votes
1 answer
71 views

Break line after the n-th comma

Suppose I have the next line 1,0,10,10,9,7,7,5,41,3,57,7,1,9 I want to split it into several lines, each containing n commands for example, for n = 4 1,0,10,10, 9,7,7,5, 41,3,57,7, 1,9
  • 143
2 votes
1 answer
46 views

vim-textobj-entire does not work if "e" not typed immediately after "a" or "i"

I'm using Neovim v0.7.2 with Kana Natsuno's vim-textobj-entire plugin, but I observed that when using ae or ie after some operator (say doing something like g~ae to toggle the case of an entire buffer)...
2 votes
1 answer
27 views

Deleting between two marks (or, from the previous mark to the cursor)

I'm a long time vi/vim user from college days in the 90s, but never considered myself a power user. I'd like to improve at it and the other day I was staring at something in an Ansible playbook like ...
  • 123
1 vote
2 answers
133 views

Leave terminal normal mode

Once I'm in 'terminal normal mode' (where VIM has control on the terminal display), i can't come back to simple 'terminal mode' (where i can write BASH or launch process). How to leave the "...
2 votes
1 answer
73 views

How to :edit executable from path?

Environment: Linux I apologize in advance if this question already exists somewhere and has a proper answer. It is just so difficult for me to search because the keywords are all so generic. Put ...
2 votes
1 answer
65 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 ...
1 vote
1 answer
35 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$...
  • 21
0 votes
0 answers
26 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 ...
2 votes
1 answer
55 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 ...
's user avatar
1 vote
1 answer
46 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 ...
  • 1,756
0 votes
2 answers
54 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 ...
  • 103
2 votes
2 answers
239 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 ...
  • 183
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?
1 vote
2 answers
35 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 ^...
1 vote
1 answer
36 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 ...
  • 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 ...
  • 141
0 votes
1 answer
28 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 ...
4 votes
1 answer
63 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 :...
1 vote
3 answers
315 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 ...
  • 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 ...
0 votes
0 answers
35 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 ...
  • 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()...
  • 101
1 vote
1 answer
138 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
1 answer
425 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 ...
  • 1,075
0 votes
1 answer
45 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 { ...
  • 217
1 vote
2 answers
156 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 ...
  • 577
1 vote
1 answer
50 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. ...
  • 525
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?
  • 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: ...
  • 43
0 votes
1 answer
38 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. ...
  • 1,756
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 ...
0 votes
1 answer
60 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
0 answers
37 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
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 ...
  • 385
1 vote
2 answers
129 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
2 answers
340 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 ...
  • 1,756
0 votes
0 answers
22 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 ...
  • 255
0 votes
1 answer
36 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 ...
  • 1,075
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 ...
  • 101
1 vote
0 answers
476 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
0 answers
382 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 (...
  • 101
1 vote
1 answer
44 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,203
1 vote
1 answer
69 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 ...
  • 113
1 vote
1 answer
85 views

noremap in .vimrc for YouCompleteMe does not work [closed]

noremap <leader>gdf :YcmCompleter\ GoToDefinition<cr> noremap <leader>gdc :YcmCompleter\ GoToDeClaration<cr> noremap <leader>gi :YcmCompleter\ GoToInclude<cr> ...
  • 165
0 votes
0 answers
34 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 ...
  • 101
1 vote
1 answer
106 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
1 answer
92 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 ...
  • 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/...

1
2 3 4 5 6