Questions tagged [insert-mode]
The mode in Vi and Vim in which you can insert text to the open document.
235
questions
0
votes
1answer
29 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
52 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
9 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
17 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
33 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
50 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
87 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
49 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
23 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
37 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
140 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
85 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
68 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
36 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
28 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
52 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
184 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
132 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
19 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
74 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
126 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
126 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
107 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
2k 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
35 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
57 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
35 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
50 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
524 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
110 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
84 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
641 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
96 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
64 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
25 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
73 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
18 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
76 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
16 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
101 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
74 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&...
2
votes
3answers
264 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
51 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 ...
2
votes
2answers
73 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
35 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, ...