Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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 !

3
votes
2answers
318 views

How to add accent to letters in normal mode?

I want to edit words that need accents (á) were they are missing. It's no problem to write down accents in insert mode: it is just "' + letter", so I can easily write á, é, í, ó, ú. How do get ...
6
votes
2answers
108 views

How can I undo an entire command (e.g. d4b), including the motions?

Say I do d4b, then realize I only needed d3b. If I hit u, it'll only undo the d part, and I'll still be 4 words back as if I just did 4b. I'd like to end up exactly where I was before I executed d4b. ...
8
votes
1answer
329 views

use case for `gs`

according to documentation for gs: go to sleep for N seconds (default 1) Thus you can put Vim to sleep for 10 seconds using 10gs. What is a good use case for this command?
2
votes
2answers
561 views

How to find out the meaning of certain non-printable characters?

I have an XML file with some invalid characters. Vim show them for example as ^C I know that this is some special character and how to replace them. Yet what is its meaning? And ^C is just one ...
1
vote
2answers
825 views

Paste with space inserted before text

Is there a command to paste (p) text with space inserted before that text like in join? I don't want to achieve that by mapping. Normally p pastes text right in the cursor's position in Normal Mode. ...
5
votes
2answers
2k views

Math calculations in vim?

I saw someone insert the result of an equation in vim, but I don't remember how it was done. For example say I want to insert the result of 7*7? How do I insert the results of an equation?
2
votes
1answer
544 views

How to copy lines from 4th till 11th and paste it from 15th till 22th line in ex mode?

To move cursor on the 4th line,toggle into normal mode,input 8yy. To move cursor to 15th line,and toggle into normal mode,press p . Now the lines from 4th till 11th was pasted from 15th till 22th ...
3
votes
2answers
80 views

Jumping to one character past the search

I understand that f jumps to the first matching character, and t jumps to one character just before the first matching character For example, given the string VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, I ...
3
votes
2answers
1k views

What is the purpose of `s`?

What is the intended use case for the s command in normal mode? I've been looking at it for some time, inadvertently pressing s, but can't find any use case that would make sense for me.
1
vote
1answer
46 views

How do I apply the Lowercase action to a line movement?

From the vim-as-language article: Vim’s "verbs" mostly fall into 2 main categories. Some of them act on a single character, and others act on a "motion" or "text object". And from the vim wiki for ...
2
votes
1answer
624 views

What's the difference between :open, :visual, and :edit?

I'm somewhat new to vim (read: really new). I'm used to vi-keys for moving and I understand the concept of operators vs motions vs commands and whatnot, but I'm still learning the commands. When I ...
6
votes
3answers
285 views

Is it possible to execute a Normal mode command only on the first/last line of a range?

I want to comment out a piece of code. For instance this snippet: foo bar foo Should become this: <!--foo bar foo--> So I type the following sequence: vap:norm '<i<!--<C-v><...
6
votes
1answer
630 views

Delete to EOL without entering insert mode

I have a file that looks like this: Bunch of text trailing... Bunch of text trailing... Bunch of text trailing... Bunch of text trailing... Bunch of text trailing... I can ...
1
vote
1answer
38 views

How can I use a register with :find?

I'm trying to improve my vim-abilities. I'm writing a command and a function to find the current Word under the cursor. What I want to be able to do is type :FindFile and have the word under the ...
1
vote
1answer
57 views

Understanding File Saving Behavior in Windows

I'm a beginner at Vim. I have downloaded the latest version of Vim on my Windows 7 system. I attempted to open and save an existing .txt file after making a minor change and got some interesting ...
1
vote
1answer
115 views

how to reenter normal mode after startinsert

I met a weird problem: Vim is still in insert mode after executing the code below, it's weird because the redraw command did work. :startinsert execute 'silent !ls' execute 'normal "\<esc>"' :...
4
votes
2answers
161 views

is there a better way of deleting a block of code?

I often use da{dd to delete a whole block of code. if a block of code is within paragraph, dap works really nicely. I tried some function text objects plugins for Javascript but didn't have much ...
0
votes
2answers
496 views

execute normal command doesn't work

Running execute g:xx doesn't work. let g:str="move to right win\t<C-w>h" let g:temp=escape(matchstr(g:str,'\(\t\)\@<=.*$'),'<') let g:xx= "normal ".g:temp execute g:xx Can anyone ...
2
votes
1answer
90 views

Do nothing if the current symbol is not space

I'm trying to configure line splitting which I want to make available only if the current symbol is space. I currently configured it as so: r<ENTER>k$ But this does the following: line1 line2 ...
6
votes
3answers
613 views

Splitting a line into two

We can make from two lines a single with J. It looks as the following: line 1 line 2 after J pressed on line 1 we've got this: line 1 line 2 But is there a combination which what do the opposite (...
7
votes
3answers
307 views

Append bash output to vim buffer

We can execute bash command from vim like this: :! shuf -i1-123124 -n1 which generates random number in the given range. Is there a way to append the output to vim buffer?
5
votes
2answers
2k views

Vim jump between words and stop at end of line

In normal mode, b and w are jumping between words, and I would like to stop at the end of line. For example: The cursor is right over here When I press w, what I expect is Instead, the cursor ...
1
vote
1answer
111 views

Automatizing cursor movement in normal mode

Beginner Vim user here. I already learned about automating deleting with commands, which happens this way: [number]d[j/k/h/l] [OR] d[number][j/k/h/l] Where number stands for the amount of the ...
3
votes
2answers
2k views

Uncomment multiple lines

In vim I can use for instance 10j to go 10 lines down. And I can use . to repeat the last deletion. Now, in bash script I have many commented lines like this: # ... # ... # ... # ... # ... # ... # .....
3
votes
1answer
65 views

How can I write a range to a command, and then read the resulting output?

I have an SQL file that I have to work on from the command line. -- Query 1 select 1; -- Query 2 select * from metadata; I've marked line 4 as a (4Gma) and line 5 as b (5Gmb), then execute :'a,'b w !...
1
vote
2answers
87 views

How to cancel a deletion after pressing 'd' in normal mode?

If I'm in normal mode and I accidentally press d vim will then wait for a motion to choose what to delete. Is their a motion or cancel command to not delete anything? Is the only option to delete ...
0
votes
1answer
323 views

Copy a file from an archive

I recently discovered that vim can open archives like .zip or tar.gz and list all files in them. We can even open the files in vim by pressing enter on a filename we want. But I want to extract some ...
-1
votes
1answer
72 views

Is there a one-key command to insert before the first character of the line?

I can use ^, i to get into insert mode from normal mode. But I was wondering if there's a shorter way to do it.
3
votes
1answer
137 views

Which text object defines text enclosed in space?

Since I need to operate on a sequence of symbols between spaces I'd like to know which text object defines it. Here is an example: 45908 Sep 24 21:31 [r].t3891993.tr some another text. ...
1
vote
1answer
264 views

Editing text in a quotation mark

I have a line which contains the following text: 'some text in the quotation mark' some other text goes here ^ cursor is here What is the fastest way to replace the text within a ...
2
votes
1answer
2k views

How does p command work in vim?

I'm experimenting with vim and got a little stuck with the p command and the way it works. TEST Data to copy //copy from here test data to copy //line for experiments RESULTS: tTEST est data // ...
13
votes
1answer
5k views

How to use a variable in the expression of a 'normal' command?

How can one use a variable when executing something via normal! in vimscript? Example: function! MyFunction(someArg) normal! (a:someArg)l endfunction This should move the cursor someArg steps ...
1
vote
1answer
33 views

Reading external file data at the end of the buffer

If I am in the middle of the buffer and want to append external file data to the current buffer. So far I move to end of the file with G and reading the data :r file so it is doing the work ...... Is ...
3
votes
0answers
104 views

How do I prevent the delay when mapping jj to <ESC> in insert mode?

I've recently mapped jj to <ESC> in insert mode for quick escaping. While everything is functional, I find the brief delay after typing j while it waits for a second input very distracting. Is ...
8
votes
2answers
436 views

Set line numbers only while in normal mode

I don't have much use for line numbers while in insert mode so I would like to turn them off. However they are great for normal mode. Constantly using set nu! is tiresome. Is there a way to tie set ...
3
votes
2answers
303 views

How to enter commands starting with i

vimtex lists some commands like ie to be entered in mode nxo. How do I do that? What is mode nxo? (Usually i brings me into insert mode, and e then just inserts an e.)
4
votes
1answer
195 views

return to normal mode when the window loses focus

Is it possible to make Vim automatically exit whatever mode it's in and return to normal mode when the terminal window loses focus?
4
votes
1answer
57 views

Certain functionality doesn't work with `normal!`

I always have problems selecting visual areas with the normal! command in vim. Against all I expected, the following doesn't work: function! s:foo() normal! v/\S\<cr> endfunction nnoremap &...
1
vote
2answers
294 views

Philosophical question: Is remapping keys to allow navigation in Insert Mode bad practice? In fact, why even have Normal Mode? [closed]

I decided to remap the arrow keys to C-h, C-j, etc. in my vimrc. Then I decided to allow half-page scrolling (which I use a lot) with C-u and C-d. But now I'm realizing that I rarely use hotkeys in ...
2
votes
1answer
449 views

Function does not work when called as from a mapping

I have a function that depends on the character under the cursor : if it's a ), then the function does nothing ; if it's not, the function adds a ). function! Ket() let char = getline(".")[col('.')...
1
vote
4answers
107 views

Motion remap to select function doesn't work with v

I want to add a motion: :onoremap <silent> f( :<C-U>normal! f)vF(b<CR> If I have this line, where the asterisk is my current position: int a = fo*o(4, 5, 99); I want to type vf( ...
2
votes
1answer
185 views

Remap plugin command with plugin command + vim shortcuts

I'm using rails.vim with the command :AS which open the alternate file (like test) and split the window. The problem is, it's always on the top and I would like to open it below the current window. ...
9
votes
1answer
126 views

Use backspace to modify the current command in normal mode?

Sometimes when entering a command in normal mode you may make a typo, for example if I intend to type 10dk, I might accidentally start typing 19d. Since the command has not been completed/committed ...
-3
votes
2answers
515 views

How to remember the most basic commands [closed]

I only use vi when I must. The commands I memorized so far are: :q! exit ZZ save and exit $ go to end of line ^ go to beginning of line I recently installed OpenBSD 5.9. Then I had to use vi or ...
2
votes
1answer
115 views

How can I insert a line with `:normal!`?

:normal! )i<CR> will go to the start of the next sentence and insert the actual characters <CR>. How can I modify this to insert a line break instead? (I've also tried \n and \r instead ...
3
votes
4answers
3k views

delete repeated line in vim, keep the n-th line in Vim

I want to ask how to delete repeated lines in vim. For now, I have a file which contained 12740 lines. There are only 98 unique lines, and each line is duplicated 129 times. I have tried: g/^\(.*\)$\...
0
votes
1answer
69 views

Window Swtiching Mappings Not Working

To make things a bit quicker, I've remapped the window switching commands like this: nnoremap <silent> <C-j> <C-w>j nnoremap <silent> <C-k> <C-w>k nnoremap <...
5
votes
2answers
445 views

Move to non-existing Nth column

I have some 30 characters in a line. When I press 80|, it should move 50 character to the right, thus move the cursor to 80th character. (30, 50, 80 are for examples) How to achieve this using ...
4
votes
1answer
115 views

Motion to jump back one level of indentation, not including blank lines

I've been authoring a lot of F# in Vim lately. Like Python it is pretty strictly indentation-based. However, unlike Python mode for Vim, it does not appear that the standard F# Vim plugin supports any ...
2
votes
1answer
126 views

What does yap<S-}>p do?

over at https://hashrocket.com/blog/posts/8-great-vim-mappings I came across said mapping. While it is clear to me it yanks a paragraph, I'm having trouble decomposing this command. What does the a do ...