[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to get vi to delete characters



DTi4565459@aol.com wrote:
>Most of the time I can get vi to insert characters after entering 'i'
>
>Also know how to :wq etc
>
>But I can't figure out how to delete characters: my book says ndd will
>delete N lines; but it doesn't work.  In insert mode, backspace key
>often changes case of letters.  Del key doesn't delete anything.  

That sounds like either you're using a strange terminal, or a
less-capable vi clone, or both. Debian doesn't tend to give you strange
terminals (log in to other Unixes from Debian, though, and you'll find
plenty; I've never bothered digging deep enough to find out which), so I
suspect you're trying things which only work in certain vi clones.

First, install vim and use that as your vi. :)

A quick summary of deletion follows. For more than this, the vim online
help files are exceptionally good; use :help or :h. These commands have
to be executed in command mode; thus, if you're currently in insert
mode, you need to hit Escape first.

  x             Deletes one character
  d<movement>   Deletes everything from the current position to wherever
                the movement would take you; sometimes this works in
                terms of lines rather than characters. For example, dl
                deletes a character, dw deletes a word, dj deletes this
                line and the next, and d} deletes to the end of the
                paragraph. As a special case, repeat the command to act
                on the current line - thus, dd.
  Nd<movement>  As above, but you put a number before it to act multiple
                times. 3dd deletes this line and the next two.
  <visual>d     Possibly the most intuitive, depending on your
                background. Hit v to enter visual mode, where you can
                move around and extend a block. Then commands, like d,
                will act on that block and take you out of visual mode.
                v again will cancel visual mode if you decide you made a
                mistake. Visual mode is vim-specific.

  s             Like x, but takes you into insert mode afterwards. Short
                for "substitute".
  c             Like d in all its contexts, except "change" rather than
                "delete": that is, it deletes then takes you into insert
                mode. Note, cc changes the current line, *not* cd.

In insert mode, put 'set backspace=2' in your ~/.vimrc, or type ':set
backspace=2' at vim. (This might be the default, depending on your
package.) Then, backspace can backspace over the start of the current
insertion, which is what most people expect.

Like I say, for other basic vi things please consult the vim help files.
It looked here like you needed a bit more of a tutorial.

-- 
Colin Watson                                     [cjw44@flatline.org.uk]



Reply to: