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 !

2
votes
3answers
490 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
142 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
31 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
85 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
362 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
578 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,...
8
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
195 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 ...
4
votes
1answer
96 views

How can I make f motions wrap across lines?

I don't actually want f itself to wrap across lines, but I would like to know how I can create a single key mapping which will jump to the next instance of the letter which follows it. The mapping ...
2
votes
0answers
451 views

Why is ruler not shown in insert mode? [closed]

I have the ruler shown, but as soon as I drop into insert mode, it disappears and reappears upon entering normal mode. This is very annoying when trying to insert a certain number of spaces to have ...
6
votes
1answer
394 views

Continue an ex mode command after “norm”?

I often use extremely long macros when handling repetitive editing and refactoring. Whenever possible I write these as ex-mode commands rather than recording them as macros, because they are easier ...
5
votes
2answers
431 views

Substitution with math goes wrong

I have a large xhtml document that is broken into some 245 long paragraphs, each with a unique id in the form of "ud###" <p class="windowbg" id="ud000"> <!--- lots of content ---> </...
6
votes
1answer
2k views

How to repeat last action with movement?

Assume the content: foo fnord bar;" >> /tmp/foo/derp gnarf foo fnord bar;" >> /tmp/foo/derp I want to jump to the " and delete to end of line and repeat that over the rest of lines. Yet ...
3
votes
2answers
118 views

Have different tabs/windows remembering their mode

I have done a bit of research about this but found only very old answers, like this one, and all on the negative side. My problem is the following --- suppose you are working on a document/program, ...
3
votes
0answers
49 views

After a while in a session, commands to change one character change two. Why? [closed]

After vim has been open for a while (on Ubuntu in a console), I notice that commands start behaving differently. Mostly, they'll change or delete an extra character. For example: 123456 ^ cursor ...
1
vote
0answers
28 views

Delay after typing shift-o to insert a new line between brackets [duplicate]

I don't know why it is happening. Suppose I've got a code like this (let x be our cursor): int main() {x and then int main() { }x Now I would like to enter the normal mode and type shift + o to ...
10
votes
2answers
473 views

How do I flip characters or words like emacs' transpose?

On bash's readline in emacs mode, I recently discovered the transpose functionality, giving me the opportunity to quickly fix a typo like dc dir to cd dir by pressing CTRL+T on the c character. ...
9
votes
4answers
464 views

How to replace text inside () with previously yanked text?

Assume I have the text Fnord yanked before and that my cursor resides on the B of the line: M:mock(Baz) How can I change the text inside () with the previously yanked text? Currently, I often make ...
2
votes
0answers
43 views

How do i move all lines from curser and below up one [closed]

Instead of pressing backspace multiple times to move lines up one, is there a vim shortcut/command that can do this? I know you can move a single line up or down with :m - or +, so I figure it there ...
3
votes
1answer
1k views

How to disable key repeat in vim?

I am currently try to break inefficient habits, and one bad habit is to keep a button pressed, e.g. keep pressing j to move down approximately 10 lines instead of moving exactly 10 lines down with 10j,...
18
votes
4answers
2k views

How I apply a command to all lines?

If I want to indent all lines in a document, I can type >G to apply it to the current line and below, followed by and >gg to apply it to the lines above. Is there a combination I can use to ...
6
votes
1answer
127 views

How to keep in the undo history just one change for this command?

I want to keep in the undo history just one change for a long command such as: d0kJx. (I took the command from this answer.) This command (d0kJx) does this (The ^ is the cursor position): Before: a ...
7
votes
3answers
768 views

How to delete till the end of the previous line?

An example (The ^ is the cursor position): Before: a bc def ghi j k l mn o p q rs ^ After: a bc def ghimn o p q rs ^ or at least: a bc def ghimn o p q rs ^ I know I ...
9
votes
2answers
715 views

What is the mnemonic for Ctrl-Y (in normal mode)?

I know "expose one more line" for Ctrl-E, but why use Ctrl-Y to expose one more line at the top? Is there an easy mnemonic for this that I'm missing?
10
votes
1answer
1k views

Is there a way to insert a single character and then exit insert mode?

When I'm going through text and, for instance, adding backticks around certain words or quotes or whatever, it is irritating that I have to press Esc or Ctrl-[ after each insert. The inserts (and ...
6
votes
1answer
747 views

How can I repeat last Ex-mode command in normal mode?

I'm looking for something like . or @@ that will work in normal mode for repeating the last Ex-mode command. As per the rule of the XY problem, I'll also state the broader goal: I have a fancy regex ...
1
vote
1answer
70 views

How to write literal for Tab key to use for motion?

I've the following dummy file created via: echo -e "a a\tb b\tc c" > file Is there any literal for space which I can use for motion argument? For example this works (which removes the 1st a a ...
5
votes
1answer
1k views

Add tab in front of each line

I'm working with python code. After some modifications, I want to update the identation but obviously, select everything and press '=' doesn't work, python being python. So, is there any other way to ...
2
votes
1answer
441 views

Remapping [ and ] is really slow

I have remapped [ and ] to easily cycle through my open buffers. I don't understand why when I use this shortcut there is a delay of almost a second before the buffer is switched. This doesn't happen ...
2
votes
2answers
408 views

Key mapping that will invoke the wildmenu

I'm trying to create a key mapping that makes switching buffers quicker and easier - something like: set wildmenu nnoremap <Tab> :buffer<space><Tab> The problem is, this mapping ...
4
votes
1answer
972 views

How to abbreviate(ca) normal command with “Esc” and “Enter” key?

Yesterday I'm trying to make a doc command abbreviation for python. The original command is normal 0i"""^M""", which works in command-line mode. But failed when using alias doc defined by ca doc ...
3
votes
1answer
119 views

Use motion when putting

A very common use case I'm having is to copy something (let's say a word) and I want to paste it in another context (let's say a word with quotes). The way I do it is: const char *foobar(void) { ...
10
votes
2answers
275 views

Scrolling issues when the `wrap` option is set

I find myself dealing with this issue every time the wrap option is active (in my particular case whenever I'm working with markdown files). What happens is that, while scrolling up and down the ...
5
votes
1answer
13k views

Execute normal command over range

For a file looking like this: 2 AD,42.546245,1.601554,Andorra,376 3 AE,23.424076,53.847818,United Arab Emirates,971 4 AF,33.93911,67.709953,Afghanistan,93 5 AG,17.060816,-61.796428,...
2
votes
1answer
145 views

`normal` does not seem to allow automatic indentation

Why does this not work as expected? function! MyO() normal! o endfunction nnoremap TT :call MyO()<cr>i If this is the situation: | an indented text ^ (normal mode) typing o gives: ...
4
votes
1answer
196 views

Delete text after match in Ex?

I've sample file like: aa bb cc dd ee ff and I'd like to remove everything till the matched line dd. Normally in Vim I type: d/dd then Enter and it works. When using in ex, it doesn't work as ...
10
votes
6answers
4k views

How to delete line above/below cursor, but not current line?

Is there a command for deleting line (or n lines) above current one? Above = current not included. I.e., is there an alternative to dk which doesn't delete current line? Similar to how o/O and p/P ...
8
votes
4answers
1k views

Grok Vim motions and simple edits

I'm returning to Vim after using Emacs for a few years. I'm trying to grok Vim by reading and watching tutorials, as well as actually using it daily. When editing text, I find the Emacs commands of ...
9
votes
1answer
545 views

Understanding line reference differences through :g/^/norm and through :%norm

Let's say that I have the following very simple file a b c d e and I've decided that I want to add empty lines after each line. Several different methods immediately jump to my mind. We might just ...
16
votes
9answers
9k views

how to insert a newline without leaving normal mode

I wonder if I can insert a new line without leaving normal mode. For example, I have two lines: this is line one this is line two And the cursor is on line one. Now I want a new line between line ...
10
votes
1answer
2k views

Hand Placement for Vim Navigation

I'm a new Vim user, and I want to ask this somewhat elementary question in order to make sure I start learning Vim the right way and don't develop bad habits. When you use Vim, how do you position ...
6
votes
1answer
2k views

Define word boundaries

I use, e.g., dw to delete a word based on word boundaries defined by changing character classes, so that this command applied on abc,def,ghi will result in ,def,ghi. (So far so good, and it worked for ...
9
votes
1answer
150 views

How can I prevent (or at least prompt to confirm) absurdly large numbers from being used to prefix commands?

It doesn't happen as often as you'd think, but it happens occasionally, and I don't even own a cat. Basically if you mash the number row or numpad and then happen to hit a keycombo that triggers a ...
9
votes
2answers
3k views

Go to last non-whitespace character of previous/next line?

I like the - and <C-M> normal-mode keys for going to the first non-whitespace character of the previous/next line. Are there coresponding keys for going to the last non-whitespace character on ...
8
votes
1answer
164 views

Is it possible to make a numerically-prefixed hotkey run a function that many times?

I find that if you enter a numeric prefix prior to executing an ex command, the convention that it applies is to set up the command to prep an operation across a line range. It is explained in the ...
6
votes
3answers
652 views

How can I delete a function call, leaving its inner content intact?

Let's say I have a line like this: a = x(y(z)); And I want to change it to: a = y(z); What's the most efficient way to do this?
18
votes
1answer
2k views

How can I map d[count]d?

N.B. This is not a duplicate of How does the "d3fg" command work? Please read it before voting to close! I've come to a bit of an impasse in my quest to get small deletions work like big ...
9
votes
4answers
2k views

How to delete content backwards until “=” at the previous line?

I use an example of javascript code: 1 var a = 1; 2 var b = |{}; The cursor is at the position of |( on the character "{" when the cursor shape is block), I find out that I want a ...
3
votes
2answers
129 views

How to increase the 2nd number on a line

One thing I need to do frequently is to increment the 2nd number on a line. Increasing the first is very comfortable by just pressing Control-a, but I just can't find a nice way to increase the 2nd. ...
11
votes
1answer
507 views

How do I shift the line indent to a specific value?

Many times I run across a situation where a line is not indented properly. Ether through a paste, bad / not preferred indent plugin, or most often extra spaces offsetting the indent value. I usually ...