Stack Exchange Network

Stack Exchange network consists of 174 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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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 !

4
votes
2answers
64 views

Change text between two $ symbols

If there is some text between quotations, such as "x = 5" I can type ci" in normal mode to delete the text inside the quotations and switch to insert mode. I often want to perform this same action ...
0
votes
1answer
27 views

How to move a line onto the end of some other line

For example suppose i have 1 the cat jumps 2 over the moon I would like the result 1 the cat jumps over the moon In general how can I move line X onto the end of line Y. A solution that would ...
0
votes
0answers
11 views

Vim waits for more input after “O” in normal mode [duplicate]

If I use small o in normal mode, vim inserts a new line below the current one and places me in insert mode without delay. For a while now vim behaves strangely when using big O. Instead of directly ...
0
votes
1answer
73 views

How can I pass extra flags to FZF/ripgrep commands with the leader key?

Current functionality When I use <C-P> and <C-Å> I can respectively search file names and contents. Everything works great. Target functionality When prepending either with <leader&...
0
votes
1answer
39 views

Append line break to current line (opposite of `J`)

Is it possible to append a line break to the current line in normal-mode? Basically the opposite of what J does.
1
vote
2answers
75 views

How to change highlighted text?

I write using LaTeX a lot for scientific writing. I often need to modify some text that includes numbers and units like: 4.2 cm into: \SI{4.2}{cm} to be properly typeset by LaTeX. Of course, the ...
3
votes
1answer
77 views

Parsing a valid normal-mode command (possibly with regex)? (for Vim-like Word add-in)

I am writing a VBA routine so I can use normal-mode commands in Microsoft Word. (Yes, I am! Edit And here you go!) I am only going to support the d, c, and y operators initially, and only char/word/...
1
vote
2answers
70 views

vimscript: how to get selected text in a register in normal mode? [duplicate]

I am trying to get the mouse selected text in a register in normal mode. If the selection is a substring, only the selection should be copied, not the complete word. Currently the script has: normal!...
4
votes
4answers
111 views

Delete with search motion in normal command

I am attempting to delete from start of line until string foo. In normal mode, 0d/foo accomplishes this. Now, I would like to do this for every line in my buffer. Reading documentation and SO it ...
2
votes
1answer
62 views

Why are two <cr> characters required when executing this highlighting toggle command?

I use this keymapping toggle to highlighting on and off, but when I originally found it, the author did not list two <cr> at the end of the command. I found that if I didn't have two <cr> ...
0
votes
1answer
121 views

What is the difference between normal mode and command mode in vim?

I know that normal mode and command mode is same thing but tells different. I found this in http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-Tutorial(Part_1)
4
votes
3answers
143 views

Reverse a set of paragraphs

Is there a good way to reverse a set of paragraphs (navigable via cursor motion { and })? My practical use case is reversing the order of blocks of latex code (ie, reversing the order of jobs in a ...
1
vote
1answer
54 views

Use Python to change to normal mode

I'm writing a function that uses Vim's Python API. The function runs while I'm in insert mode and I want this function to set my mode to normal mode. I tried a few things, like for example, this ...
1
vote
1answer
52 views

Unexpected behavior from cb command

One of the most basic editing commands is c<motion> to change text, e.g. cw - change word, c$ - change to end of line, cc - change entire line, c3l - change 3 characters to the right. My ...
1
vote
0answers
41 views

Is there a way to print the current sequence of command keys in normal mode? [duplicate]

Sometimes I get lost in normal mode. Is there a way to have vim/vi print the last keys pressed, perhaps at the top/bottom of the screen. For example, in normal mode I may enter the command 22gg to go ...
1
vote
0answers
41 views

indenting with ':g' command not working from the command line

When I need to work with some scrambled javascript/json code, one of my first steps is to introduce proper line breaks, followed by proper brace based indentation. For the later, I found the following ...
0
votes
2answers
241 views

How can I delete whole word in command insert mode?

Following my pressing ':' I can switch to command insert mode and pressing 'Up Arrow' I can bring up my previous command. How can I delete a word left of my cursor during command insert mode? Say for ...
0
votes
0answers
22 views

How can I switch from insert mode to normal mode with alphabetic keys? [duplicate]

'Esc' key kind of too far for my left hand to reach every time. Would be perfect if we could just pressing any middle row alphabetic keys consequently may be certain number of times ( eg: 'ffff'). Any ...
1
vote
1answer
55 views

What is Lang-Arg in vim?

I was seeing the docs in :help map-mode where I saw that map! works for Insert and Command-line modes while lmap works on Insert, Command-line, Lang-Arg But I've never heard of Lang-Arg mode. Can you ...
1
vote
2answers
223 views

Move cursor to new line character

When in visual mode you can select the new line character. E.g.: The quick brown fox jumps over the lazy dog.⏎ In visual mode you can select both the period and the (invisible) carriage return, or ...
1
vote
2answers
92 views

Don't yank character with <DEL> key in normal mode

I am using NeoVim with Tmux on an Ubuntu on Windows setup. I have bound neovim's clipboard to the system clipboard by using : set clipboard+=unnamedplus and further configuration inside tmux. So far, ...
1
vote
1answer
32 views

Can I remap <C-(key)> while replacing a character? If not, is there a workaround or hack?

I have i-mapped <C-a>, <C-s> etc. to commonly used keys that I use often but find annoying to type normally, for example * and _. It works as expected in insert mode, but when executing a ...
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
70 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
269 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 ...
0
votes
1answer
461 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
82 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
170 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 ...
0
votes
0answers
43 views

Would it be possible to catch showcmd text into variable?

The showcmd makes vi show command as it is typed. I would like to create a plugin which would show the command text (exactly same as showcmd shows) near the cursor. To achieve this I need to somehow ...
1
vote
1answer
100 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 ...
8
votes
2answers
2k 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
63 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 ...
4
votes
2answers
179 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 ...
0
votes
0answers
50 views

Problem with Esc(or Ctrl-[) navigation and insert mode

I'm having a weird problem lately when I'm coming out of Insert Mode to navigate in Normal Mode after just one navigation command (w,b, etc) vim sets me into Insert Mode Again, I'm not using the ...
6
votes
2answers
101 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. ...
7
votes
1answer
206 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
380 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 ...
0
votes
2answers
334 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. ...
3
votes
2answers
666 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?
1
vote
1answer
188 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 ...
1
vote
2answers
46 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
354 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
35 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 ...
1
vote
1answer
332 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
238 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
518 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
48 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
93 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
117 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 ...