Tuesday, October 24, 2017

Re: Insert space before last character

Hello Adrian,

This should work:

:%s#\(.*\)\(.\)#\1 \2

Like in your solution \( \) is defined to use \1 and \2 in the substitution.

Hope this works fine,

regards

Edwin




Am 24.10.2017 um 18:58 schrieb Adrian Johnson:
> Dear group:
>
> I am trying to insert space after first character in a line and a
> space before last character in same line using command mode. I could
> introduce space before first character but could not insert space
> before last character.
>
>
> F783S
> Y625D
> A1705V
>
> :%s//\(^.\)/\1 /g results in
>
> F 783S
> Y 625D
> A 1705V
>
>
> now I want to give space before last character to get following:
>
> F 783 S
> Y 625 D
> A 1705 V
>
> I tried different ways and could not introduce space. I am successful
> in remove the last character. Could anyone help please.
>
>
> Thanks
> Adrian
>

--
--
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/d/optout.

No comments:

Post a Comment