Monday, October 25, 2010

Re: problem with backspace

On 10/25/2010 08:48 AM, rameo wrote:
> I would like to have tabstop = 4 and only spaces (no tabs).
> I added this in my vimrc:
> set tabstop = 4
> set expandtab
>
> Everything works fine... however.
> The backspace key goes only 1 space back now and not 4 spaces.

Well, you're deleting the one-space which is there, which is both
the behavior I would expect and the behavior I'd want since
backspace deletes one character.

A couple ideas:

1) less palatable may be to use tabs instead of spaces (i.e. set
'noexpandtab') where one backspace deletes one tab. This could
be pared with post-read and pre-write auto-commands to exchange
tabs for spaces so the file-contents are what you want.

2) learn to love ^D and ^T

:help i_CTRL-D
:help i_CTRL-T

(in the same place, the help also describes the "0" and "^"
prefixes to ^D clearing leading whitespace) I use ^D and 0^D
regularly, and ^T occasionally. These also have the added
benefit that they can be used anywhere in the line, not just at
the break between leading-whitespace and the start-of-text.

3) write a more complex mapping for backspace-in-insert-mode that
will sniff the character(s) before the cursor and if there are
&shiftwidth space-characters, delete that many of them. This is
more complex, apt to hit odd edge-cases, leading to noisome breakage.

Hope this gives you some ideas you can use,

-tim

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment