How can you delete old text in Insert Mode in GVIM - vim

I've just downloaded GVIM for the PC and MacVIM for the Mac and they both have different behaviour to the VIM I was using in MSYS.
Here's the problem. I bring up a file in VIM and enter insert mode. I can no longer delete any of old text. I can insert new text and delete them just fine so I know my backspace and delete keys are working. What's even more annoying that if I move the cursor to another line and come back to my original one, the new text I've typed becomes undeletable as well.
The command line VIM allows me to delete old text in insert mode but the GUI versions do not. I've looked in the options and googled but have not come up with anything.
Does anyone know how I can make the GUI version behave like the command line version of VIM?

Check the output of
:set backspace?
It will likely say something like
backspace=indent,eol
This means you can hit backspace to delete over end of line and indent characters. To be able to delete text that was present before you went into insert mode, you need to add 'start'.
:set backspace=indent,eol,start
This is equivalent to
:set backspace=2
For more details see
:help 'backspace'

The vi in msys is just an older version of vim. (5.8.9 in msys 1.0.10). So either the defaults changed or you are using a different settings file for gvim than you are for msys.

Related

Cmder cursor and highlight issues with Neovim

Currently in normal mode and the cursor is still just a | instead of the usual block
This doesn't change regardless of the mode, I have tried reinstalling both neovim and cmder and the same result happens regardless of the .vim file being used.
using the / command to search for the word "there" and it makes the word im searching for invisible with or without a stock config for both cmder and neovim
currently in visual select highlighting all of the text but the highlight on the text is clear/can't see it but it is working.
For all of these issues I have tried using a new .vim file and a stock cmder config and have reinstalled both and the issue still occurs, the issue doesn't happen when I use neovim through the command prompt or from powershell.
Note:
The highlight issue doesn't occur when using regular vim through cmder only with Neovim, however the cursor staying a | persists in regular vim as well.
Update with regular vim:
Regular vim is working properly with highlighting cursor and everything, the issue only happens with neovim now, if this doesn't get fixed then ill just switch to regular vim.
I've never used cmder before, but for iterm2, for example, there is a setting associated to this:
If you're on osx you can hit <⌘ + ,> to get to the preferences for the current application.

Can not leave Insert-mode in gvim 8.1 after starting without opening file

I just installed gvim 8.1 on my Win10-machine and wanted to modify _vimrc, and to learn to use vim.
I can switch modes with a,i, <C-o> to enter insert-mode, and <C-c> or <Esc> to get back to normal mode, but only when I opend a file with gvim.
If I only start gvim, it displays an empty unnamed file in insert mode, and no combination of keys lets me leave the insert mode.
I tried:
Ctrl+c
Esc
^c
^C
activating/deactivating Capslock
Ctrl+[ (German QWERTZ-keyboard, [ is on AltGr+8)
I also deleted msvim.vim, because I thought that might help, but it had absolutely no effect.
Any other ideas how to leave insert mode here? Everything is fine if I open a text-file directly...
Try typing <C-o>:verbose set insertmode?<CR>. If it replies with insertmode, you're in easy mode (:help easy). For that session, you can turn this off via <C-o>:set noinsertmode<CR>.
If you're lucky, the :verbose also tells you the file where (mistakenly) :set insertmode happened. But I rather suspect that the shortcut that starts Vim passes the -y command-line argument (but it's only effective if no files are passed). To fix that, you need to check the shortcut (don't use one that says Vim (Easy mode) in it, or launches evim.bat) or your file associations in the Windows registry.

How to disable 'vi compatible' mode for Vim in Cygwin on Windows 8?

I am using Cygwin 1.7.22 (32-bit) on Windows 8 (64-bit). Within Cygwin, I am using Vim 7.3.1152, which is the default version.
Behavior that seem like bugs:
When I press I to enter insert mode, it does not say -- INSERT -- in the bottom left. In fact, it doesn't say anything. It does behave correctly, though.
When I delete letters using Backspace in insert mode, the letters do not disappear but the cursor does move to the left.
When I use the arrow keys in insert mode, it enters the letters A, B, C, and D, rather than moving the cursor. The arrow keys work normally outside of insert mode.
How do I make Vim behave as I expect?
Create a ~/.vimrc file with the following contents to put vim in nocompatible mode (actually the mere presence of the file is sufficient.)
set nocompatible
The behavior you are seeing is how vi used to behave. These are not bugs.
Take a look at :h nocompatible
In vim compatible mode tries to emulate vi as closely as possible.
--insert-- is not part of vi so it not shown in compatible mode.
I believe vi did a lazy redraw of the screen and didn't update until you exited back to normal mode. Also backspace is only usable also only works on stuff that was entered in the current insert mode. Overall its not very user friendly.
The arrow keys are sent to vim as escape sequences (escape followed by a coupled of letters). Let ^[ be escape. ^[OA is up on my computer its probably something similar on yours. vim sees this as an escape (goes back to normal mode), and O (add a line above the current) and A which is the A you see entered onto your screen. This just means that vim in compatible mode does not interpret the escape characters properly. Most likely because vi did not interpret them (nor was it designed to use them).
set nocompatible fixes problems 1 and 3.
I think set backspace=indent,eol,start should fix problem 2.
This was asked months ago, but I am answering for future reference for anyone else who encounters this problem.
I was just bitten by this issue. All advice listed in this post, and in other posts on this forum (not to mention posts on other forums) does not work, at least for some of us. I finally figured out the real issue.
vim on cygwin, for whatever reason (at least this was the case for me) does not use the .vimrc you put in your directory. Let's say you copy the example one to your working directory, or copy some .vimrc from online. Or maybe you create a new one from scratch, and put all the settings the good people here and elsewhere recommend (set backspace = blahblah, set nocompatible, set this, set that). It doesn't work. Why? Because for whatever reason (at least in my case) vim isn't looking at the .vimrc you just created.
The solution is to FORCE vim to use a particular .vimrc, by passing in -u on the command line like so:
vim -u [/INSERT/PATH/TO/.vimrc]
For the love of all that is holy, DO NOT type square brackets or the words "/INSERT/PATH/TO/.vimrc" verbatim. Use your brain please.
Anyway, this solved my problems and I was able to use the default example .vimrc and get proper delete and backspace behavior while in insert mode, not to mention other goodies.
You might want to alias the vim command in your .bashrc like this:
alias vim='vim -u [/INSERT/PATH/TO/.vimrc]'
Regarding A,B,C,D for arrow keys in Vim, adding:
:set term=cons25
to ~/.vimrc worked like a charm.
source: http://vim.wikia.com/wiki/Fix_arrow_keys_that_display_A_B_C_D_on_remote_shell
Following different answers in this topic I found a simple solution.
$ vi --version | head
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 30 2020 21:54:08)
Included patches: 1-486
Modified by <cygwin#cygwin.com>
Compiled by <cygwin#cygwin.com>
$ vi --version | grep 'user vimrc'
user vimrc file: "$HOME/.virc"
2nd user vimrc file: "~/.vim/vimrc"
So I just created ~/.virc (not vimrc) and it works! The content of the file:
set nocompatible
Probably, if you already have this file you will add the above string in it. Or, as people say above, if you have an empty ~/.virc, nocompatible mode must be already in use (I didn't check it).
Apart of the question, line numbers (that I find very useful) may be shown in vi by adding:
set number

Cannot delete indents nor past insertion point

When I enter insert mode, vim will not allow deleting text behind where I entered insert. Also when I use auto indent, I cannot delete the indentations that get automatically created.
I've tried a blank vimrc and even tried my own version of vim compiled from source. How can I delete properly in vim?
Are you attempting to delete them using backspace? Try :set backspace=indent,eol,start
By default you can't backspace over auto-indentation, previous edits or line breaks.
Try :set nocompatible

mapping already exists for ^I in vim

I have added the following lines to the vimrc file so that i could use s-tab for indenting
map <esc>[Z <s-tab>
ounmap <esc>[Z
After i have added this , i get the following error. I use SnippetsEmu plugin
Error detected while processing function <SNR>15_SnipMapKeys:
line 10:
E227: mapping already exists for ^I
How do i solve this conflict.Why does this happen
A helpful way you can detect whether your version of vim is capable of differentiating between Tab and Shift-Tab is to:
Go into insert mode, press Ctrl-v* then Shift-Tab. I get <S-Tab> when I do that (gvim 7.2 on Windows XP).
If you don't get that then I don't think you can map Shift-Tab separately from Tab with your current setup.
*Ctrl-v will take the next key combination you press and output the key combination that vim actually sees.
EDIT: If you're sourced mswin.vim then you'll want to use Ctrl-q instead.

Resources