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
1
vote
2answers
63 views

Shouldn't `softtabstop` be set, when using option 2 in `:h tabstop` to configure Vim to use spaces for `<Tab>`s?

I want to configure Vim to use spaces for <Tab>s everywhere. Therefore, I've had a look at :h tabstop to figure out how to perform the configuration. Looking at the help text, option 2. seems ...
1
vote
3answers
44 views

How to make a shortcut to activate and deactivate multiple maps?

I know there are questions/answers to execute commands with a single shortcut, but in my case I can't think how to do multiple maps with a single shortcut in Insert Mode. In other words, what I want: ...
1
vote
0answers
27 views

Typing colon character in Insert mode undoing changes?

I am really curious as to why this is happening. I have this line in my .vimrc file (I am using WSL2 on windows and this line helps support copying from vim to the system clipboard): set clipboard=...
0
votes
0answers
23 views

How to paste text from other applications into Vim without incrementally indenting each pasted line? [duplicate]

I want to copy text from other applications into Vim, e.g. from Visual Studio Code, but the result is awful. In particular, each pasted line is being indented incrementally: Furthermore, visually ...
1
vote
1answer
23 views

line-completion based on non-initial substring

Is there a way to perform a completion similar to <c-x><c-l>, but completes lines based on an arbitrary substring rather than a leading prefix of the line? I'm especially interested in a ...
0
votes
0answers
18 views

Why does disabling arrow keys in Insert mode (e.g. `inoremap <left> <nop>`) result in e.g. `0D` being written? [duplicate]

I want to disable the arrow keys in Insert mode, since I want to force myself to always go into Normal mode for performing movements. To achive this, I've made the following mappings for Insert mode, ...
4
votes
2answers
50 views

How can I use `ci'` to change the N'th occurrence of single-quoted text in a line?

I find the ci' (and similar commands) very useful, since I can execute it at the start of the line, and it will automatically change the first occurrence of text between single quotes ('...'). However,...
1
vote
0answers
20 views

How can I make `<Shift>+<LeftArrow>` and `<Shift>+<RightArrow>` key bindings work using MacVim?

How can I make <Shift>+<LeftArrow> and <Shift>+<RightArrow> key bindings work using MacVim? I often use these (default) key bindings in Insert mode to move the cursor one word ...
0
votes
5answers
98 views

I keep forgetting which mode I'm in

My main problem is that I don't realize which mode I am in each time I use vim. Sometimes I forget to <ESC> into normal mode, hence pressing vim commands in insert mode. I have to waste time ...
2
votes
3answers
66 views

How do vim users type/edit while switching between modes?

I'm not talking about learning or introducing commands, but how to work by switching between modes, and using normal known commands. Do most vim users stay more in normal mode instead of in insert ...
1
vote
0answers
18 views

How to prevent `autocmd` for stripping trailing whitespace for moving the cursor? [duplicate]

I've the following autocmd for stripping trailing whitespace in a buffer, every time the buffer is written to a file: " trim whitespace autocmd BufWritePre * %s/\s\+$//e However, the autocmd has ...
-1
votes
1answer
42 views

Paste clipboard data in Insert mode

I have learnt to paste clipboard data (something i copied from web browser using ctrl+c) to my current buffer in insert mode. It is much easier than doing that in Normal mode. To paste clipboard data ...
0
votes
1answer
64 views

Navigation in insert mode with soft wrap and showbreak

I’m having trouble with hjkl movement in insert mode. The issue is that I have changed hjkl movement to move by display line. I have 'wrap' on. The cursor should normally move line by line, not move ...
0
votes
0answers
45 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 ...
2
votes
1answer
58 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
624 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
29 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
29 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
46 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
31 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
26 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
184 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
45 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
51 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>...
2
votes
5answers
462 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
54 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
34 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
22 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
50 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
17 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 ...
4
votes
3answers
68 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
56 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
59 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
62 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
33 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
52 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
132 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
99 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
62 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
103 views

Saving file from INSERT mode

I would like to save files without exiting the INSERT mode. Is it possible? How?
3
votes
1answer
229 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
131 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 ...
3
votes
3answers
66 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
76 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
197 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
102 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
55 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
124 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. ...

1
2 3 4 5