We’re rewarding the question askers & reputations are being recalculated! Read more.

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
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( ...
2
votes
1answer
190 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
133 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
573 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
186 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
4k 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
74 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
467 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
124 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
132 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
621 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
164 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
411 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
739 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
216 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
98 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
537 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 ...
8
votes
1answer
463 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
443 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
123 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
29 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
564 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
44 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
128 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 ...
8
votes
3answers
921 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 ...
12
votes
2answers
1k 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
811 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
74 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
2k 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
520 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
472 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
1k 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
145 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
314 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 ...
7
votes
1answer
15k 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
148 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
241 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
5k 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 ...
8
votes
1answer
682 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 ...
20
votes
9answers
15k 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 ...