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
1answer
41 views

How to go to the nth-to-last character in insert mode?

Capital A in Vim takes me to the last character in insert mode, but can I go to the nth-to-last character in insert mode (or append mode) in vim? Example: this is some t|ext how to go specifically to ...
1
vote
1answer
45 views

Delete from cursor position until end of line in command-line mode

I am trying to emulate readline keybindings in insert and command-line modes (for example, <C-u> for deleting from cursor position to beginning of the line, or <C-w> to delete previous ...
1
vote
1answer
33 views

Tab to align cursor with next non-whitespace character in the line above (in insert mode)

How can we do this with vim? set hlsearch " Highlight search matches set incsearch " Highlight search matches as you type set visualbell ...
0
votes
1answer
48 views

How to set a keybinding in Insert mode

I'm new to Vim, and I've read that a best practice in Vim is to begin a new Append with each line. In other words, instead of pressing <Enter>, it is more advisable to leave Insert mode, and ...
0
votes
1answer
26 views

Replacement of characters gives ^@ when replaced with newline but not newline [duplicate]

Why does replacement of something by using :%s/,/\n/gc in vim gives me ^@ instead of giving me newline. Sed replacement works perfectly sed s/,/'\n'/g. Any idea how to do sed thingy in Vim and save ...
3
votes
1answer
131 views

Can macros be edited? [duplicate]

I want to end up in insert mode after a macro. Is there a way to do that? A real life example: Given "foo", I'm wanting to convert it into "$123" where the number is something I ...
0
votes
1answer
14 views

Trigger complete keybind mapping using <C-O> when in Insert mode

I know that when I am in insert mode I can enter Normal mode for one command only and automatically switch back to insert mode using <C-O>. For example to go to the end of the line when in ...
1
vote
1answer
46 views

Inserting abbreviation from file

First, I apologize if this is a trivial question. I have the following file (main.ab) defining a Python snippet: def main(args): ... if __name__ == '__main__': args = ... main(args) And ...
1
vote
1answer
109 views

Auto pairing using strings instead of characters

I'm already aware of existing solution to automatically "surround" sentences/word/etc (eg: auto-surround, vim-surround, etc) but those (as far as i know) don't support using normal strings ...
0
votes
1answer
31 views

How to make cursor move to the top line inserted with 2O?

Using a simple example: h[]ello If I type 2o<esc>, the cursor will be moved to the last inserted line like this: hello [] But if I type 2O<esc>, the cursor will be moved to the last ...
1
vote
2answers
60 views

How to return to normal mode by pressing ESC only once

I have been using vim for a short time, so I may not know a lot, please forgive me. There is a problem with my vim. It cannot enter normal mode from insert mode by pressing esc/ctrl-[ only once, but ...
1
vote
0answers
87 views

NeoVim : Can we "insert literally" every ASCII symbol with `<c-v>` ? (including delete `^?` )

In insert or command mode, the printable ASCII chars, like a can be insert with just a (we don't need <c-v> for those ones, but most of them will still work with <c-v>letter ). If I type, ...
0
votes
1answer
31 views

How to make mouse click ALSO enter Insert mode?

I've enabled mouse and clipboard and ... something else: set mouse=a set clipboard+=autoselect guioptions+=a That's almost perfect, but I want it so that when I left click it moves the cursor and ...
0
votes
0answers
21 views

How to automatically start in Normal mode? [duplicate]

I am using zsh on Mac and noticed that whenever I start vim, it always starts in insert mode. I use vim to inspect files more often than to edit. I tried adding set noinsertmode but it didn't have any ...
1
vote
1answer
34 views

Enter insert mode automatically after moving (e.g. with e, w)

Is there something similar to A and I for "smaller ranges" like w and e, i.e. I don't want to have to press i to insert, after navigating to the end of the word with e?
0
votes
2answers
105 views

How to backward-kill-word in Vim insert mode like zsh?

I'm re-learning Vim. My question is that I want to option + ⌫ to backward-delete a word in INSERT MODE. I've spent some days to achieve this (and succeeded) to my zsh shell through bindkey in .zshrc ...
0
votes
0answers
18 views

Shift+AnyLetter and Forward Slash Not Working on wsltty [duplicate]

I'm noticing errant behaviour with some standard key sequences with Vim 8.1 on wsltty. The correct behaviour is displayed when inside wsltty's standard terminal, so until proven otherwise I'm assuming ...
0
votes
1answer
141 views

When would I use append and when would I use insert?

I already know that a and i makes the cursor one space to the right and left respectively, but when would I use i to edit a file? Is there some special circumstance that makes insertion mode more ...
-1
votes
1answer
132 views

Enter insert mode after search?

So you're in Normal mode, then you press f followed by a character, then vim takes you to the next occurrence of that character. When you land on that character you are in Normal mode. My question is ...
1
vote
1answer
24 views

How to prevent cursor shift when using <C-O>{delete cmd} at the end of a line?

<C-w> deletes a (small-)word in insert mode, but I often want to delete the Word (to last whitespace) I've most recently typed. I tried inoremap <C-_> <C-o>dB which kind-of works -- ...
0
votes
1answer
58 views

Keep open fold open on `o`

I have a file with foldmethod=indent. I have the folds automatically open when I enter them, and close when I leave them. When I sit in Normal mode on the bottom line of a fold and press o, the fold ...
1
vote
3answers
198 views

How can I delete whitespace backwards until end of previous word?

I want to delete whitespace backwards until end of previous word. Say, I have the cursor on the character "d" in the word "dog": horse cat dog If I press Ctrl-W (Insert ...
1
vote
2answers
127 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
70 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
56 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=...
1
vote
1answer
32 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
62 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
21 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
296 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
188 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
20 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
157 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
220 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 ...
2
votes
1answer
137 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 ...
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 ...
0
votes
2answers
31 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
45 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
72 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
39 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
68 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 ...
2
votes
3answers
981 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
177 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
119 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
6answers
808 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
141 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
102 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
46 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
92 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
26 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 ...

1
2 3 4 5