Cannot delete indents nor past insertion point - vim

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

Related

Vim: How to permanently allow auto indent only on manual linebreak

Vim has a tendency to automagically mess with the indentations in the line I'm currently working on, as well as placing linebreaks. I want it to do an automatic indentation when I manually make a linebreak (i.e. physically hitting the Enter key), but not in any other case, I don't want it to make any linebreaks itself either, and I want these settings to be permanent.
The textwidth option controls the number of characters after which a line break will be inserted, see :h textwidth.
To turn off the insertion of line breaks while editing, the following lines should be added to .vimrc:
set textwidth=0
set wrapmargin=0
set formatexpr=
Information on the options can be obtained by the usual :h command.
Note that these options are set globally but may be overridden e.g. by a filetype plugin. If the problem persists, see :h ftplugin.
Another question is where :set textwidth=132 originates from. This may be due to an earlier misconfiguration or set from any plugin.

Configure backspace key properly in vi

I have a Ubuntu 12.04 OS. I installed vi and vim, but the backspace doesn't work properly. It is doing the same thing that delete key do.
I am expecting the backspace key to delete a character backwards, but it deletes forwards. I did some search on the Internet, there are too much suggestions for changing the .vimrc file, but non of them worked for me.
Is there anybody who has the same issue?
As explained in answer SO/a/10197995/1699311, you have to correct your terminal setting.
However, if you really want to stick with incorrect terminal behaviour (which will affect some other programs) you can instruct Vim to accommodate with that with :fixdel (it internally swap Backspace and Delete keys.)
All the previous suppose you don't have some mapping on that key.
Try adding the following to your .vimrc file, which would correct the behavior of the backspace key:
set backspace=2
Also, you can execute it inside vi/vim command mode:
:set backspace=2
Additionally, here is more information and solutions if this doesn't work for you: http://vim.wikia.com/wiki/Backspace_and_delete_problems
If your backspaces deletes forward you can use the command in vimrc file as shown below
set backspace=2
now on the vi command mode do the follwoing to re-excecute the .vimrc file
:so %
To know which .vimrc file is being read do the following
:echo $MYVIMRC

How can you delete old text in Insert Mode in GVIM

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.

Vim will copy the text when I delete it, but how can I disable it?

I don't like automatic copy the deleted text when delete in Vim, how to disable it?
Not sure there is a way to disable it, but there is a black hole register called '_', which swallows everything, and gives nothing back.
You use it by prepending "_ to the command, so "_dd would send the current line to the blackhole.
I also wanted to disable this and have found a solution:
Add this to your .gvimrc file and autocopy text on select will be disabled.
" Following three lines remove the auto copy function from VIM
set guioptions-=a
set guioptions-=A
set guioptions-=aA

How to prevent Vim indenting wrapped text in parentheses

This has bugged me for a long time, and try as I might I can't find a way round it.
When I'm editing text (specifically latex, but that doesn't matter) files, I want it to auto-wrap at 80 columns. It does this, except if I happen to be in the middle of a parenthetical clause, it indents the text which is very annoying. For example, this works fine
Here is some text... over
two lines.
but this doesn't
Here is some text... (over
two
lines
If anyone can tell me how to turn this off (just for text/latex files) I'd be really grateful. Presumably it has something to do with the fact that this is desired behaviour in C, but I still can't figure out what's wrong.
:set nocindent
The other options do nothing, and the filetype detection doesn't change it.
There are three options you may need to turn off: set noai, set nosi, and setnocin (autoindent, smartindent, and cindent).
This may be related, when pasting from gui into terminal window, vim cannot distinguish paste modes, so to stop any odd things from occuring:
set paste
then paste text
set nopaste
I had similar issues trying to paste xml text, it would just keep indenting. :)
gvim, the gui version of vim, can detect paste modes.
You can have a look at the autoindent option :
autoindent - ai
Copy indent from current line when starting a new line (typing
in Insert mode or when using the "o" or "O" command). If you do not
type anything on the new line except and then type or
, the indent is deleted again. When autoindent is on,
formatting (with the "gq" command or when you reach 'textwidth' in
Insert mode) uses the indentation of the first line. When
'smartindent' or 'cindent' is on the indent is changed in specific
cases. The 'autoindent' option is reset when the 'paste' option is
set. {small difference from Vi: After the indent is deleted when
typing or , the cursor position when moving up or down is
after the deleted indent; Vi puts the cursor somewhere in the deleted
indent}.
From the official Vim documentation
filetype plugin indent on
This switches on three very clever
mechanisms:
Filetype detection. Whenever you start editing a file, Vim will try to
figure out what kind of file this
is. When you edit "main.c", Vim will
see the ".c" extension and
recognize this as a "c" filetype.
When you edit a file that starts with
"#!/bin/sh", Vim will recognize it as
a "sh" filetype. The filetype
detection is used for syntax
highlighting and the other two
items below. See |filetypes|.
Using filetype plugin files Many different filetypes are edited with
different options. For example,
when you edit a "c" file, it's very
useful to set the 'cindent' option to
automatically indent the lines. These
commonly useful option settings are
included with Vim in filetype plugins.
You can also add your own, see
|write-filetype-plugin|.
Using indent files When editing programs, the indent of a line can
often be computed automatically.
Vim comes with these indent rules for
a number of filetypes. See
|:filetype-indent-on| and
'indentexpr'.
:set noai
sets no auto indent tt may be smartindent though. Check out the doc and see if you can find something more
http://www.vim.org/htmldoc/indent.html

Resources