268 votes
Accepted

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

tl;dr: Add this to your vimrc to make the backspace work like in most other programs: set backspace=indent,eol,start Longer answer Though the default behaviour may be surprising, the backspace "...
user avatar
88 votes
Accepted

Other ways to exit Insert mode besides Escape

A common binding you'll see is jj, because it works well for QWERTY layouts if you use home row positioning. inoremap jj <ESC> In that case, to type a literal jj - you should wait for 1 sec (...
user avatar
  • 1,044
58 votes

Other ways to exit Insert mode besides Escape

Beside the built-in alternatives <C-[> and <C-c> to <Esc> key cited by others, another popular solution is to remap <CapsLock> as an additional Escape. This both on a Qwerty ...
user avatar
57 votes
Accepted

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

You can use digraphs: Ctrl+k-N (with a capital N) In Insert mode, digraphs are entered by Ctrl+k followed by a two-character sequence. For en-dash, the sequence is -N. As Quincy pointed out, U+2014 ...
user avatar
  • 7,240
50 votes

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

I do the following to append text to multiple lines: <c-V> - Enter Visual Block mode. Use j/k to select the lines. $ - Move cursor to last character. A - Enter insert mode after last character. ...
user avatar
  • 1,562
48 votes
Accepted

Navigation in insert mode

There are many options you have. One option, and IMO the sanest and easiest is to just stop disabling the arrow keys. I understand why many hardcore vimmers say things like You should never ever use ...
user avatar
  • 16.8k
40 votes

Other ways to exit Insert mode besides Escape

The mappings that I use are: inoremap jk <esc> inoremap kj <esc> This way, you can simply hit j and k at the same time, without having to worry about which one you press first.
user avatar
  • 13.8k
39 votes
Accepted

Insert tabs in INSERT mode when expandtab is set

Instead of just pressing Tab, first press Ctrl-V and then press Tab. This can be used to insert a variety of special chars. See :help i_CTRL-V for details. Ctrl-V also works in command-line mode (:...
user avatar
  • 28.2k
36 votes
Accepted

Automatically load Vi into insert mode

You can use the +startinsert option (or +star for short) to start Vim with insert mode. vim +star myfile.txt If you want this to happen by default when starting Vim, you can make an alias (in your ....
user avatar
  • 15.7k
32 votes
Accepted

What options are there to enter insert mode?

Entering insert mode at different locations The vim help documents have a great section on this: :help inserting A quick summary is: i: Insert before the cursor. I: Insert before the first non-...
user avatar
  • 1,143
29 votes
Accepted

How to enter insert mode when entering neovim terminal pane?

A terminal buffer name always starts with term://: autocmd BufWinEnter,WinEnter term://* startinsert Note that this will always put you in insert mode when you move to the terminal window, ...
user avatar
28 votes
Accepted

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

Others have already provided work-arounds, but as for the reason why it happens, I bet you're accidentally pressing Alt+Space. I'm using Xubuntu with the 105-key Finnish keyboard layout myself, so ...
user avatar
25 votes

Insert tabs in INSERT mode when expandtab is set

Rather than change your behavior (which is error prone). I would set up vim to behave differently for this file type. So in my normal editing I expand tabs. But specifically for make files I set the ...
user avatar
  • 5,850
25 votes

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

You were right about visual mode, but you should have tried blockwise visual mode by pressing <C-V>. In blockwise visual mode you can select the lines and columns of your selection. When you ...
user avatar
  • 15.2k
24 votes
Accepted

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

Preface: This has nothing to do with Vim as such, but I will show you what I consider to be the "best" way to insert these characters by far; Vim's digraph system is more or less the same, but it only ...
user avatar
22 votes

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

Not sure if I totally understand the question, but if you wanted to delete until you only have var a = {};, you could, from the cursor position, use d?1Enter d takes a motion, and you can give it a ...
user avatar
  • 5,886
22 votes

Undo <CR> in insert mode

I have this in my vimrc, the second part is relevant: inoremap <expr> <silent> <cr> pumvisible() ? "<c-y>" : "<c-g>u<cr>" What this does: everytime you hit Enter ...
user avatar
  • 9,340
21 votes

Other ways to exit Insert mode besides Escape

<C-[> and <C-c> are two native alternatives to <Esc>. See :help i_<esc> and :help i_ctrl-c which explains the difference between <C-c> and <Esc>.
user avatar
  • 33.1k
21 votes

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

In Vim there are no multi-cursors like in Sublime Text (but there are some plugins as I remember). But it seeems not so important stuff for vim because there is another way to achieve this. For ...
user avatar
20 votes

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

To insert Unicode characters such as the euro or copyright symbols, or diacritical marks such as the German umlaut or accent grave, digraphs can be used. For example, in insert mode press Ctrl+k and ...
user avatar
  • 16.8k
20 votes
Accepted

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

As @jamessan mentioned, <C-f> will indent to the correct place from insert mode. You can also use <C-t> and <C-d> to increase or decrease the indention level from insert mode. ...
user avatar
20 votes

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

You can add an autocommand that replaces non-breaking spaces with regular ones upon saving particular file types, eg. by putting something like this in your vimrc: augroup RemoveSpaces autocmd! ...
user avatar
19 votes

Navigation in insert mode

I like to use the Control key to turn the hjkl movement keys into "universal" movement keys. Here's the relevant bit of my .vimrc: " In insert or command mode, move normally by using Ctrl inoremap &...
user avatar
18 votes
Accepted

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

I agree with Alexander here. In day to day editing I would probably use the . command as well, but if you want to execute just one command I would use the substitute command: :s/S\|E/organic_&/g ...
user avatar
  • 296
18 votes
Accepted

Undo in insert mode

Vim offers a limited ability to specify the scope of an undoable change with the Ctrl-G u command, which breaks the undo sequence. See :help i_CTRL-G_u In your case, the solution would be to remap &...
user avatar
  • 5,934
18 votes

arrow keys don't work in insert mode

What's causing the behaviour When you press the left arrow, your terminal is sending the following escape sequence: ESC O D This can also be notated as ^[OD, where ^[ is notation for Ctrl-[, which ...
user avatar
  • 28.2k
18 votes

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

On first line just type: 4:norm A. 4 and : create a range for you and then norm A. adds the dot to each line Another solution for longer paragraphs could be: Vip<C-v>$A.<Esc> The first ...
user avatar
  • 691
17 votes
Accepted

How to write vertically?

Really good solution would probably require some more work, but "not bad" is not very hard to achieve. Idea All we need is to move one line down after each character, so let's do just that via ...
user avatar
  • 1,628
17 votes

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

This happens only in the terminal, but not in GVIM, right? The reason is that Vim cannot distinguish between the individual types keys and an ANSI Escape sequence starting with the same keys (i.e. ^[O....
user avatar
  • 16.9k
16 votes

How do I insert the output of an external command at the cursor position?

In normal mode press double !, then enter the command, or just type the following: :.!ls
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible