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
6answers
1k views

Replace the word at the cursor with a single character?

An operation I do often in vim is to replace the word at the cursor with a single letter. Currently, I do this via: cw x Esc (Where x is my replacement letter). This isn't bad, but is there a way ...
2
votes
1answer
120 views

Why am I missing a quote in this remap?

nnoremap <leader><cr> :execute "normal! i\\\<cr>\<esc>" When I run that, it says: E114: Missing quote: "normal! i\\\ E15: Invalid expression: "normal! i\\\ What's wrong with ...
0
votes
2answers
735 views

Vim is in read-only mode [duplicate]

I'm using vim for scripting and configs and noticed that I sometimes forget to open file with sudo and therefore when I made some editings I got the error: E45: 'readonly' option is set (add ! to ...
1
vote
1answer
1k views

Remapping tab key to autocomplete in commandline mode in Vim

I am using Vim 7.4 and I wish to map the tab key so I can use new combinations to autocomplete arguments in command mode from the current directory Contents of current directory: Funwithstrings.cs ...
0
votes
2answers
302 views

Vim jump word forward and enter insert mode

I'm using vim for python scripting and found that I pretty much often need to jump a word forward e-button and enter insert mode. Is there some built-in shortcut for this or ea is reuqired to push all ...
1
vote
1answer
799 views

key mapping <C-'> (Ctrl single quote) not working

I have this line in my .vimrc nnoremap <C-'> :marks<CR> and want to use Ctrl-' to show all marks. Sadly, it never works, be it on ubuntu, cygwin, or windows 10. After vim 8.0 was ...
1
vote
1answer
208 views

Map autocomplete word in normal mode?

I want to map , in normal mode to function as autocompleting a word <c-n> in insert mode. Also, I want to keep pressing , in normal mode to cycle through the list and then finally when I finish ...
10
votes
2answers
5k views

How to execute a command on vim startup

I just installed a plugin for python which displays methods tree. So I would like to open the tree on startup, so not necessary to push the buttons everytime I open some .py file. But, I want this ...
0
votes
1answer
143 views

Debug ultisnip snippet

I have ultisnips installed and when I type ve in normal mode it changes the word. Let's say I have: word When I type ve to select until the end of the word it does the following Plese also help me ...
3
votes
2answers
390 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
113 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. ...
10
votes
1answer
375 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
705 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
3answers
1k 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. ...
6
votes
3answers
3k 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
779 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
101 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
3k 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
50 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
858 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
304 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
662 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
58 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
154 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
217 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
589 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
105 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
723 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
322 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
125 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
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
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
386 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
73 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
185 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
348 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 ...
3
votes
1answer
3k 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
7k 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 ...
4
votes
1answer
145 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
477 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
328 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
251 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
299 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
517 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
118 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( ...