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
0
votes
0answers
19 views

Change cursor shape in Vim PowerShell

I have looked through the web but I have found no answer to this. https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes The above website mentions ways to do it in terminals but not when ...
1
vote
1answer
29 views

Conflict between system compose key and insert mode meta key mappings

I use the right alt key as a compose key on my system, to easily draw diacritics and accent characters. In Vim, I unlock alt key mappings with this (from stackoverflow): " Allow <alt> key ...
6
votes
3answers
526 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 ...
0
votes
2answers
28 views

How to delete strings to close quote and close parenthese

I have a code like this: h5 style=("text-align: center; margin-top: 2rem;") some text p style=("text-align: center; margin-top: 2rem;") some text And in first line, I want to ...
1
vote
1answer
28 views

Typing d in insert mode briefly moves cursor backwards

In Vim, when I'm in Insert mode and hit d, the cursor moves back one spot for a second, then jumps back to behind the letter just typed. This is quite distracting when typing texts. It looks like Vim ...
2
votes
0answers
39 views

how to have two different colour schemes for command mode and edit mode in vim?

I have been using vim for some time now but I am always unsure of which mode I am currently in and hence end up pressing Esc too often even in the command mode. This causes an irritating computer ...
1
vote
1answer
29 views

How to put cursor in the right position after switching from normal mode to insert mode in terminal

After launching a terminal inside vim via :terminal, vim doesn't put curosr in the right position after pressing i in normal mode. As seen in the following picture, the cursor is put at the end of the ...
0
votes
1answer
25 views

prevent printing control-character in insert mode and command line

When in insert mode, if no mapping is associated to a sequence, Vim will print the character corresponding to the signal. For example, typing <c-b> will input ^b as a character. It is more ...
1
vote
3answers
102 views

How can I delete forward in “Insert” mode?

I often use the Ctrl-w command in "Insert" mode to delete the word behind the cursor, just like I would do in Bash. In Bash, I also have a Meta-d (Esc-d) command for deleting the word in front of the ...
1
vote
1answer
37 views

blockwise visual mode multi line prepend doesn't work for me [duplicate]

I'm using nVim v0.4.3 and I'm having trouble getting multiline inserts to work in visual blockwise mode. You can check this asciinema to see what I'm doing. https://asciinema.org/a/...
0
votes
1answer
34 views

Simulate backspace in normal mode

I would like to have the delete key work similarly in normal mode as it does in insert mode, and it's been a bit tricky to map this. Here is what I have so far: :nnoremap <Backspace> i<BS>...
1
vote
4answers
353 views

How to delete a pair of parenthesis with backspace

I'm using vim to code C++ and I want to handle the parenthesis more easily. I knew that there was a plugin named Surround, which can help us but it is not what I expected. I set some shortcuts as ...
1
vote
3answers
40 views

How to loop backwards through getline

I want to code a vim function, which searches backwards a specific char from the cursor at the current line. Here is what I've done: function! CustomSearch() let currentLine = getline(".") "...
0
votes
2answers
27 views

Cursor difference with “Esc” and “Ctrl + O”

Say I have a session like this: Sunday|Monday Where | is the cursor in insert mode. If I press Esc, I get this: Sunda█Monday but I want this: Sunday█onday As I want to select the second "word", ...
1
vote
1answer
19 views

Setting to prevent <c-h> to erase text

I have a map which allows me to navigate with hjkl in insert mode: " In insert or command mode, move normally by using Ctrl inoremap <C-h> <Left> inoremap <C-j> <Down> ...
1
vote
1answer
36 views

Why doesn't inoremap work in this case

I'm coding c++ with vim and I want to set a shortcut while typing parenthesis and new line. Here is an example, if (a == 1) {}| // the cursor is at the end of the line and the vim is under INSERT ...
1
vote
1answer
15 views

Problem when inserting text from a function in a for loop

I have a function that animates the insertion of the contents of the last modified register at the cursor's location as if someone was typing it: function! AnimateInsertion() abort " split ...
2
votes
1answer
35 views

Insert the word which is above the cursor?

I know that in insert mode CTRL-Y can insert the character above the cursor. Is there a way of inserting the word above the cursor in insert mode ?
0
votes
1answer
15 views

Map hex character

If I want the output 𐐀g, I can create a map like this: imap <F2> <C-V>U10400g However for output 𐐀f, it causes a problem: imap <F2> <C-V>U10400f as the f is confused as ...
0
votes
1answer
49 views

Automatic insert mode and normal mode switching

Coming from emacs, jumping to the end of the line is easy: CTRL + E I have been recently trying out Vim, and I found out you need to first exit insert mode to then use commands. So, in Vim, I need ...
2
votes
1answer
55 views

Why do arrow keys behave differently in insert mode than in other modes?

Background I would like to disable arrow keys in all modes. This is what I tried: "EDIT: added remap for <esc> as per the comments inoremap <esc> <nop> inoremap <up> <nop&...
1
vote
2answers
49 views

Pasting text on Vim inside tmux breaks indentation

Ubuntu: 18.04 bionic tmux: version 2.6 VIM: Vi IMproved 8.0 (2016 Sep 12, compiled Jun 06 2019 ) Included patches: 1-1453 Modified by pkg-vim-maintainers@lists.alioth.debian.org Compiled by pkg-vim-...
0
votes
1answer
28 views

Normal mode Backspace and Delete

If I have a file like this in Insert Mode (pipe is cursor): Sunday | Monday I can press Backspace or Delete to remove the empty line. However in Normal Mode, neither of those work. I have been ...
1
vote
2answers
46 views

How to indent the cursor to the indentation of the above line in insert mode?

I previously asked the following question on how to indent the cursor to the identation of the above line: How to ident the cursor to the indentation of the above line? A correct answer was provided ...
1
vote
0answers
32 views

Ins-completion C-X C-F and the path variable [duplicate]

Can the insert-completion of file names CTRL+XCTRL+F can be used to complete filenames that are not in the current working directory ? But rather in any in the path variable ? Can we, for example, ...
0
votes
1answer
91 views

How to ident the cursor to the indentation of the above line?

I want to move the cursor to the indentation of the line above. As seen from the example below, when I move the cursor down (j or arrow-down), it goes to the start of the line. This is both true for ...
2
votes
1answer
80 views

Change <up>/<down> to gk/gj in insert mode

I want to replace the default behavior of the arrows in insert mode, so that they behave like gk and gj, I have used: inoremap <up> <Esc>gka inoremap <down> <Esc>gja But this ...
0
votes
1answer
47 views

How to prevent Vim from making a flashy screen effect when pressing `ESC` or `^[` in normal mode?

I often press ESC/^[ to ensure that I've left insert mode and entered normal mode. However, if I'm already in normal mode, Vim displays an annoying flashy screen effect: How can I prevent Vim from ...
3
votes
1answer
65 views

Saving file from INSERT mode

I would like to save files without exiting the INSERT mode. Is it possible? How?
3
votes
1answer
197 views

NeoVim - Go into insert mode when clicking in a terminal in a pane?

I'm trying to use NeoVim as a tmux replacement, and have found that no matter what I do, I can't get it to go into insert mode when I click in a pane that has a terminal in it. Here's the config I'm ...
1
vote
1answer
110 views

vimtex imap not working

I'm having a problem with using imaps with vimtex (i.e they don't work). To test the issue I went to .vim/plugged/vimtex/test/examples/minimal and started vim -u minivimrc. Typing `a (which is a ...
2
votes
1answer
40 views

Ctrl-W in insert mode erases only up to where insert was started

I frequently use <C-w> in insert mode to back up when I mistype things. I've noticed some odd behavior if I start insert mode when in the middle of a word. For example, if I have the following ...
1
vote
1answer
64 views

Call a function after inserting a newline

In insert mode, I want to call some function if <Enter> was typed. I tried InsertCharPre but it did not work.
0
votes
2answers
138 views

How to remap Autocomplete on Control+N, to Control+Space?

I am trying to remap this functionality: to Ctrl+Space, by using this line in .vimrc inoremap <C-Space> <C-n> However, I can not seem to get it to work. If I press Ctrl+Space after ...
1
vote
1answer
81 views

detecting insert-normal mode

I notice that when in insert, pressing <C-o> will take me to normal mode, but once I finish pressing a sequence of keys, I get taken back to insert mode. I find this very useful, but I want a ...
0
votes
0answers
51 views

Escape newlines when breaking text

I'm using Vim to typeset some Latex documents, and resizing it to take up half my screen so I can reference other materials on the other half. Therefore, formatoptions+=t would be very helpful here. ...
2
votes
1answer
109 views

Is it possible to supply arguments to inoremap?

Currently, I have the following map for cpp files: inoremap ;;f for<Space>()<Space>{<Enter>}<Esc>kkf)i Which essentially allows me to quickly setup a c-style for loop. ...
2
votes
2answers
385 views

How to auto-replace words, such as acronyms, while typing?

When typing a report, we have a large list of acronyms defined in Acronyms.tex. In order to use it, we have to encapsulate an acronym such as KDF with the acronym command: \ac{KDF}. I often forget and ...
1
vote
2answers
64 views

How can I stop Vim from inserting keypresses into the document unless the document is visible?

I have a macro that's essentially equivalent to the following: in insert mode, I press the following keys: Ctrl+O, :, !, t, r, u, e, Enter. This runs the command true in a shell and shows "Press ENTER ...
1
vote
1answer
174 views

Mapping using <Esc> writes “<Esc>” in insert mode rather than switching to normal mode

I have the following line in my .vimrc: inoremap kj <Esc> It had been working fine, ie it returned me to normal mode. But now it inserts the string "< Esc>" (I use the initial space here ...
0
votes
0answers
66 views

Temporary normal mode doesn't wait for the command

When I press C-o in insert mode, the expected behaviour is that vim will wait for me to execute a single command and then returns to insert mode. Usually, after pressing C-o I have all the time in the ...
2
votes
2answers
49 views

Automate breaking of history in insert mode

I started to learn ViM one month ago, so I'm not a ViM expert. My question is: if I make some changes in insert mode (let's say I type some text, then I delete the last two words and finally type ...
1
vote
1answer
72 views

Is there a way to enter command line mode for a single command directly from insert mode?

I'd like to go directly into command line mode from insert mode, enter a single command (say :r !date which inserts the date) and then go immediately back into insert mode. Basically something ...
1
vote
0answers
18 views

Get correct indentation when entering insert mode [duplicate]

When I enter insert mode using o or O when programming, the cursor appears at the correct level of indentation. In this example below, X is the place where I press o and Y is where my cursor appears. ...
0
votes
0answers
209 views

Visual block mode insert/append not working in vim on RHEL/CentOS?

I was trying to append some text to multiple lines in vi on a RHEL 6 system, however I could not get it to work. I press Control + V to get into visual block mode, select the lines I need, but when I ...
0
votes
0answers
74 views

Don’t start in insert mode when opening a shell script

How can I prevent vi from starting in insert mode when opening a "test.sh"-like file with the vi-plugin "bash-support" v4.3 ? When I vim test.sh it opens in insert mode When I vim .vimrc it opens in ...
0
votes
2answers
40 views

How do I map a sequence of letters in insert mode?

After trying to make this work: Map a sequence of letters in insert mode I can’t get the correct answer to work. Is it still working? Can anyone post a working .vimrc file? I want to get this: When ...
1
vote
0answers
14 views

How can I remap the arrow buttons in insert mode when Pencil is enabled

I use vim to write text, and that’s why I often use it in combination with the Pencil plugin. The plugin creates significant delay in the movement of the cursor when in insert mode. I have tried to ...
2
votes
1answer
30 views

Backspace + keypress adds a character of a different language in neovim with neomutt on my mac

I am a user of neomutt and I use neovim as my default editor. However, when I delete a character via backspace, and then type the correct character, I sometimes get a strange character from a ...
0
votes
1answer
53 views

How can I get vim to type continuously, rather than holding in place for keymappings?

For the purpose of this question, imagine that I have set iab phil philosopher In vim, as far as I know, the default display pattern when typing out the characters "phil" at the start of the word is ...

1
2 3 4 5