Wednesday, May 8, 2013

Re: delete last character of multiple lines

On 2013-05-08 19:15, Phil Dobbin wrote:
> On 08/05/2013 18:29, Jürgen Krämer wrote:
> > :'<,'>s/.$//
>
> Does the '.' replace a character with nothing?

This is the method I'd default to. It's a standard search/replace
command. The pattern searched for is "any one character ('.') at the
end of the line ('$')" and replaces it with nothing (there's nothing
between the 2nd and 3rd slashes as a replacement).

You can visualize it by making the replacement something like "XXXX":

:'<,'>s/.$/XXXX

(the trailing "/" is optional when you don't have any flags to
include). You can then "u"ndo that to return to your original
document. Also, when there are no flags *AND* no replacement value,
the whole thing can be shortened to just

:'<,'>s/.$

-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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: