Questions tagged [insert-mode]

The mode in Vi and Vim in which you can insert text to the open document.

Filter by
Sorted by
Tagged with
202
votes
5answers
167k views

Why doesn't the backspace key work in insert mode?

Trying to delete characters in insert mode with the backspace key sometimes doesn't seem to work. I can backspace sometimes, but at other times it does nothing; the cursor doesn't go to the left, and ...
113
votes
16answers
118k views

Other ways to exit Insert mode besides Escape

The primary reason I like vim over emacs is that my hand movement distance away from the home row is very low (even as a programmer). However, the one main time that I do this is leaving insert mode, ...
42
votes
7answers
9k views

What is the easiest way to insert en dash in Vim?

To insert an en dash, I use ^v u 2014 which is seven keypresses. Is there an easier way? (I was looking at digraphs and didn't find en dash there.)
39
votes
5answers
29k views

How can I insert text at the end of a group of lines?

Let's say I had a block of text... Lorem ipsum Lorem ipsum dolor Lorem ipsum dolor sit Lorem ipsum dolor sit amet ...and I wanted to insert a . at the end of each line. What would the best approach ...
36
votes
5answers
29k views

Navigation in insert mode

I finally decided to ditch the arrow keys for navigation in favor of hjkl. I used the Vim hardmode plugin to disable the arrow keys. I got used to navigation pretty fast, but it turns out that ...
33
votes
5answers
10k views

What is the easiest way to insert Unicode characters into a document?

When writing documents occasionally I want to insert Unicode characters into the text. Sometimes I know the character code and sometimes I look it up on the web. Currently I go to insert mode and ...
27
votes
3answers
10k views

Undo in insert mode

Is there a command to undo the last operation performed while in insert mode? I just pasted text from the wrong register using <C-r>, and I have two options: Delete by hand what I just pasted ...
24
votes
4answers
7k views

Automatically load Vi into insert mode

I use Vi as my preferred (and, in fact, only) text editor on Linux Systems. I know how to change modes from normal to insert, and vice-versa. Is it possible to have Vi automatically load into Insert ...
23
votes
5answers
3k views

How do I keep accidentally creating a no break space before opening curly brace?

From time to time, let's say once a month, when I program, I introduce a No-Break space instead of a regular space, before opening a curly brace. This happens let's say when I'm writing () { This ...
22
votes
3answers
2k views

How to write vertically?

Lets say I want to produce the following text in my document: % % Not Important % O -------------------------> % | % S | % o | % m | % e | % | % M | % s | % g | % | % ...
21
votes
4answers
2k views

Undo <CR> in insert mode

Sometimes in insert mode I hit <CR> by mistake and I have to hit the backspace multiple times (depends on the indentation) to get back where I was. e.g. <div> <p> This is some ...
20
votes
4answers
7k views

How to enter insert mode when entering neovim terminal pane?

I have the following mappings to make it easy to move out of a terminal pane in neovim: tnoremap <C-h> <C-\><C-n><C-w>h " Workaround since <C-h> isn't working in neovim ...
20
votes
5answers
26k views

arrow keys don't work in insert mode

When I hit the arrow keys in insert mode I get characters instead of navigation: I'd like to be able to use the arrow keys to navigate. Things I've tried I have set nocompatible in my ~/.vimrc (...
19
votes
2answers
22k views

Insert tabs in INSERT mode when expandtab is set

I have set expandtab in my .vimrc file to convert tab to multiple space characters. However some files (like Makefile) need actual the tab character inserted. Is there an easy way to force the ...
18
votes
3answers
457 views

Speed bump on <Esc>O (Insert to Normal to Insert new line above cursor)

Often when I'm in Insert mode, I'll hit Esc to get into Normal mode, and then immediately hit O to begin a new line above the cursor and go into Insert mode there. But when I do that, there is a 1-...
17
votes
4answers
828 views

Set the paste option, but for one insertion only

I want to have a quick way of setting the Vim 'paste' option, inserting some text, and reverting to the previous value of 'paste'. A typical use case insert the OS clipboard content literally, ...
16
votes
3answers
28k views

How to add space on multiple lines when pressing spacebar (without extra configuration)?

I tried visual block, but visual block only allow to highlight or delete characters on multiple lines. Is there any function that allows to add space before the first character of multiple lines when ...
15
votes
1answer
13k views

What options are there to enter insert mode?

I used to enter insert mode by a never realizing that there is a system as to where the insert mode starts. I was sometimes annoyed that a would put the cursor after the first character of a line, ...
15
votes
1answer
1k views

How to move the cursor to the correct indentation level without quiting insert mode?

For example I have this JavaScript code. The | character represents the cursor position and it is on an empty line. function a() { console.log("a"); function b() { console....
14
votes
3answers
1k views

Edit different words simultaneously, one the same line like in Sublime Text with multiplie selections

is it possible to edit more than one word simultaneously, which are on the same line? For example, let's say I have this: Spam and Eggs is all you need for a healthy breakfast and I would like to ...
14
votes
1answer
1k views

How to achieve automatic list numbering in vim?

Contracts etc formal things need numbered lists. 1. Some text 2. More text 2.1. Sub-section text etc. The key is to eliminate the manual re-numbering when inserting or deleting a list item. Is ...
13
votes
1answer
2k views

Visual block insert new line

I work a lot with visual block mode, which I find really useful for quick changes across a lot of lines. But something I'm struggling to do is inserting a newline like so: Selection is noted as []: ...
12
votes
2answers
5k 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 ...
12
votes
1answer
3k views

How can I run an autocmd when starting Vim with no file, a non-existing file, or a blank file (but not when starting with an existing file)?

I would like to run an autocmd in the following scenarios when I start Vim: With no filename specified. When the file is new. When the file exists but is completely blank. In all of the above three ...
11
votes
4answers
3k 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 ...
11
votes
2answers
3k views

How can I insert a character repeatedly until even with next line?

Say I have a comment like this: //This is a comment And I want to make it like this: //***************** //This is a comment //***************** Is there an easy way to insert a character ...
11
votes
1answer
484 views

Map a sequence of letters in insert mode

I can already map a key combination in insert mode: :inoremap abc <do stuff> However, this has a few drawbacks: When typing a partial version of the sequence, such as ab, the characters aren'...
11
votes
1answer
3k 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.=...
10
votes
1answer
2k views

Cursor moves one character backwards on exiting insert mode

I recently have noticed that entering and then exiting insert mode will move your cursor one space to the left. This is a default behavior of vim, since it still occurs with vim -u NONE -U NONE -N. ...
10
votes
1answer
1k views

Is there a prepend insert mode?

I was trying to write a string with all chars from z to a and I thought this would be much easier if I could write backwards. The idea would be like an INSERT mode in which the cursor doesn't step ...
10
votes
2answers
2k views

Edit a directory inside Vim

Is it possible to edit a directory inside Vim? (Some commands are working for directories). I want to know what kind of operations can be done in a directory inside Vim. Vim can open the directories ...
10
votes
1answer
198 views

Is there a <C-w> for WORDs?

Pressing Ctrl-w in Insert mode will delete the previous word. It is equivalent to Ctrl-Backspace in Windows, and Opt-Delete in OS X, and really speeds up typing. Vim has the separate concepts of word ...
9
votes
2answers
2k views

Can I create my own mode in vim?

We have few modes in vim. The most common used are: Normal (=Command), Insert, Command-line, but also some sub-modes, like: Replace,Visual-line (V) or Visual-block (Ctrl+v). Does vim support creation ...
9
votes
1answer
6k views

What does CTRL-K do in insertion mode?

When I press ^K in my vim while I'm in insertion mode a '?' appears and then if I press a and then another character some strange characters appear the following are a few of the characters I could ...
9
votes
1answer
8k views

I can't switch to | cursor in insert mode

I want to change cursors to a | character in insert mode, and then back to a block in normal mode. I am using urxvt as my terminal, and neovim. To switch cursors in my terminal, I run the following ...
9
votes
2answers
601 views

How can I create a pseudo insert mode with a different keymap?

I am in the slightly unusual position of using two different keyboard layouts on a regular basis (Programmers-Dvorak and Turkish-F). These layouts are quite different from each-other and I am only ...
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
2answers
732 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 ...
8
votes
3answers
531 views

How to disable folding while typing?

I'm programming mostly in Python/Cython and use foldmethod=syntax (and foldclose=). Overall, this works fairly well, i.e. functions/classes/methods are folded reliably mostly. However, I have one ...
7
votes
3answers
3k views

How can I add text to the end of words on each line?

I have a series of single-word codes on separate lines in a text file. I'd like to add a backquote ( ` ) to the beginning and end of each word. I know I can add a backquote to the beginning of each ...
7
votes
3answers
3k views

Within a function, Is there a way to determine if vim is in insert mode?

Within a function, is there a way to determine if vim is in insert mode (or was in insert mode prior to calling the function)?
7
votes
1answer
4k views

Deleting and inserting in a single visual block selection

I'm trying to understand how the visual-block mode deals with Backspace and Delete, and if it is possible to vertically select a column of text, delete some characters, then insert new ones in a ...
7
votes
2answers
616 views

Remove the insert delay after entering insert in a read-only file

When entering or doing any command mode modifications to a read only file for the first time you will get the warning W10: Warning: Changing a readonly file That's fine, but this also introduces a ...
6
votes
2answers
2k views

Start Vim in insert mode for new files

I mostly use Vim to edit configuration files so I understand why it starts in normal mode. But I also use vi mode for the REPL (bash, zsh, ipython, etc.) and the shell always starts in insert mode (...
6
votes
2answers
337 views

imap beginning with <C-o> interferes with omnicomplete

I added the following key mappings: inoremap <silent> <Up> <C-o>gk inoremap <silent> <Down> <C-o>gj The goal was that j/k would still work the way that I was ...
6
votes
2answers
391 views

Deleting groups of autoindents in Insert mode

In my .vimrc I have set backspace=eol,start, which allows me to backspace over line breaks and the start of what I wrote since I entered Insert mode. This does not allow me to backspace over ...
6
votes
1answer
2k views

Mapping control-H in insert mode doesn't work; it always works like backspace

I tried mapping control-H, J, K, and L respectively in insert mode to move around splits. inoremap <C-h> <ESC><C-W><C-h>i inoremap <C-l> <ESC><C-W><C-l&...
6
votes
1answer
2k views

Triggering UltiSnips with enter

Is there any possible way to do expand trigger in UltiSnips with enter? I've tried <Enter>, <Return>, and <CR>. It works to trigger but doesn't work for new line. And I've tried to &...
5
votes
4answers
2k views

How do you change the last n characters for a range of lines?

Generally you can select a visual block for the first n characters of a range of lines, and just press c, insert characters, and press Esc to have it apply to all. However, this method is rarely ...
5
votes
2answers
555 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 ...

1
2 3 4 5