Thanks Tim and Edwin for quick reply Much appreciated Adrian On Tuesday, October 24, 2017, Tim Chase <v...@tim.thechases.com> wrote:
> On 2017-10-24 12:58, Adrian Johnson wrote: > > 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. > > You can do > > :%s/.$/ &/ > > which will add a space before the last character. If there's > trailing whitespace, you may have to tweak it: > > :%s/\S\s*$/ &/ > > In the future, you can do both in one pass by capturing the parts you > want and reassembling them: > > :%s/\(.\)\(.*\)\(.\)/\1 \2 \3/ > > Hope this helps, > > -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+unsubscr...@googlegroups.com <javascript:;>. > For more options, visit https://groups.google.com/d/optout. > -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.