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
4
votes
2answers
5k 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
56 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
1k 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
338 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
701 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
44 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
67 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
209 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
298 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
709 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
127 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 ...
7
votes
3answers
1k 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
351 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
3k 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
146 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
3k 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
66 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
93 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
461 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
75 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.
5
votes
1answer
299 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
542 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 ...
6
votes
1answer
4k 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 // ...
15
votes
1answer
9k 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
34 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 ...
5
votes
1answer
188 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
557 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
353 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
327 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
303 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
615 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
129 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
232 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
158 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
717 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
275 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
5k 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
87 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
515 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
132 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
147 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 ...
2
votes
3answers
808 views

How to put at end of line?

How to put at end of line with vim? I would like to use p to put some text at the end of the current line without moving the cursor. Edit: For example I would like to copy a word to the end of the ...
2
votes
1answer
216 views

Weird behaviour with <c-i> and :normal

When I execute: :exe "normal! \<c-o>" , it works as expected (it jumps to the previous cursor location). But when I execute: :exe "normal! \<c-i>" , it outputs the E471 error: E471: ...
2
votes
1answer
33 views

Applying changes to lines in alternating modes

I know I can apply changes to multiple lines by selecting the lines in visual mode (I use ctrl-v) and defining the set of actions and the mode to start in (e.g. norma A, will add a comma at the end of ...
1
vote
1answer
93 views

perl multi line comments are not aligned properly

With Vim 7.2, when a perl block is aligned using =, Multi line comments are moved as per the blocks inner alignment. But they should be placed at immediate start of the line. Is there any way to ...
0
votes
1answer
479 views

Vertical Navigation secrets without a plugin

At my workplace using my current compiler I have a vim plugin enabled. The only thing that I am uncomfortable with vim is vertical line navigation and I wanted to know how some of the vim gurus ...
6
votes
1answer
1k views

Hardcore vim mode: what is the best way to move vertically? [duplicate]

This question has been migrated from here I have started using vim a while back and have been jumping with my right hand on and off "home row". As I learned more about efficient navigation, using "f,...
9
votes
1answer
2k views

Vim normal and insert mode cursor not changing in GNU screen

I use vim in a few different contexts; typically, I like to put this in my .vimrc: let &t_ti.="\<Esc>[1 q" let &t_SI.="\<Esc>[5 q" let &t_EI.="\<Esc>[1 q" let &t_te.=...
4
votes
1answer
230 views

How to simulate Return and Escape for global command without using Control-V?

I've the following sample content which I want to edit: <table> <tr><td title="Title 1">col1</td><td>col2</td><td>col3</td></tr> <tr><td ...