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

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
147
votes
4answers
106k 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 ...
75
votes
12answers
59k 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, ...
33
votes
7answers
6k 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.)
28
votes
5answers
8k 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 ...
23
votes
3answers
7k 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 ...
22
votes
4answers
5k 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 verse. Is it possible to have Vi automatically load into Insert ...
22
votes
3answers
1k 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
1k 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
2k views

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

I am conscious this is a strange question, and this might not even be the right forum to post it. But this has been a problem for several years. From time to time, let's say once a month, when I ...
19
votes
5answers
10k 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 turns out that ...
16
votes
4answers
566 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
312 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-...
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
5answers
7k 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 ...
14
votes
3answers
4k 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 ...
14
votes
1answer
418 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.log("b"); ...
11
votes
2answers
11k 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 ...
11
votes
1answer
5k 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, ...
11
votes
2answers
941 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
305 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'...
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 ...
10
votes
1answer
2k 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 ...
10
votes
1answer
104 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 ...
10
votes
1answer
1k 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 []: ...
10
votes
1answer
844 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 ...
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 ...
9
votes
2answers
1k 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 ...
9
votes
1answer
591 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 ...
9
votes
2answers
410 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
479 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
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.=...
7
votes
3answers
7k 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 (...
7
votes
2answers
411 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
3answers
2k 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)?
6
votes
2answers
814 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 ...
6
votes
2answers
200 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
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
1answer
915 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. ...
6
votes
1answer
4k 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 ...
6
votes
2answers
174 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 ...
5
votes
2answers
465 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 ...
5
votes
4answers
1k views

Stop highlighting when entering Insert mode

I would like Vim to stop highlighting matches when entering Insert mode. And not to highlight them again until a new search is performed. A first thought would be to add the following line to my ....
5
votes
2answers
12k 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 ...
5
votes
1answer
150 views

Is there a way to push existing text left while inserting (e.g., insert right-aligned text)?

In insert mode, typing normally moves the cursor right and pushes text to the right of the cursor farther to the right on the line. I am typing some right-aligned text and am wondering - is there a ...
5
votes
1answer
158 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 ...
4
votes
3answers
572 views

Is it possible to wrap characters around text every time you paste something from the system clipboard?

I am going to be pasting a lot of characters into a file. Each time I paste something, the pasted element will need to be wrapped in quotes and followed by a comma. Is there a way to automatically ...
4
votes
1answer
1k 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 ...
4
votes
3answers
952 views

Effects of set paste

This wikia page explains how to paste text from a different application into vim when in insert mode. Simply apply the command set paste and things will work as expected. After you are done, just ...
4
votes
2answers
400 views

Breaks line without leaving insert mode

With the textwidth option set the text written can be wrapped when we leave insert mode. If I type a line longer than my textwidth value then it will go on a new line. e.g. with set textwidth=5 and ...