Keeping endofline representation in xml fileformat dos file

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Keeping endofline representation in xml fileformat dos file

Ni Va
Hi All,


I'm wokring on that kind of files'content, initially configured with ff=dos, ffs=unix,dos

<?xml version="1.0" encoding="utf-8"?>
<PROP ID="script" VALUE="&apos; Init properties
Option Explicit

Dim varName1, vaName2
Dim nameOfBar
&apos; array creation of components
fnameOfBar = split(Parent.somefoobar, &quot;|&quot;)
"/>


1/ Instead of the whole content up above, I see only one line with ^M in place of endline CR LF.


2/ Copying this inline containing ^M in new buffer opened with setlocal ffs=unix, I do this substitution %s/^M/^M/g
 
Then I see all content in different lines.


3/ After editing the script, I would like to restitute the modified content into original file in one line : all content inline with end of line replaced by ^M.  As at the origin.

But all attempts fails, even these that say to pass by changing ffs at opening time and writing time.

https://stackoverflow.com/questions/3852868/how-to-make-vim-show-m-and-substitute-it
https://superuser.com/questions/357760/vi-on-linux-show-m-line-endings-for-dos-format-files


Is someone can give me right way to restitute the text content inline containing ^M displayed.

Thank you
NiVa

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

sample.xml (244 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Keeping endofline representation in xml fileformat dos file

Christian Brabandt

On Do, 14 Mär 2019, [hidden email] wrote:

> Hi All,
>
>
> I'm wokring on that kind of files'content, initially configured with ff=dos, ffs=unix,dos
>
> <?xml version="1.0" encoding="utf-8"?>
> <PROP ID="script" VALUE="&apos; Init properties
> Option Explicit
>
> Dim varName1, vaName2
> Dim nameOfBar
> &apos; array creation of components
> fnameOfBar = split(Parent.somefoobar, &quot;|&quot;)
> "/>
>
>
> 1/ Instead of the whole content up above, I see only one line with ^M in place of endline CR LF.
>
>
> 2/ Copying this inline containing ^M in new buffer opened with setlocal ffs=unix, I do this substitution %s/^M/^M/g
>  
> Then I see all content in different lines.
>
>
> 3/ After editing the script, I would like to restitute the modified content into original file in one line : all content inline with end of line replaced by ^M.  As at the origin.
>
> But all attempts fails, even these that say to pass by changing ffs at opening time and writing time.
>
> https://stackoverflow.com/questions/3852868/how-to-make-vim-show-m-and-substitute-it
> https://superuser.com/questions/357760/vi-on-linux-show-m-line-endings-for-dos-format-files
>
>
> Is someone can give me right way to restitute the text content inline containing ^M displayed.

Can you provide an example file?


Best,
Christian
--
Es ist nicht genug, der Natur die Daumenschrauben anzulegen.
Man muß auch hinhören, wenn sie aussagt.
                -- Arthur Schopenhauer

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Keeping endofline representation in xml fileformat dos file

Ni Va
Le vendredi 15 mars 2019 10:46:51 UTC+1, Christian Brabandt a écrit :

> On Do, 14 Mär 2019, [hidden email] wrote:
>
> > Hi All,
> >
> >
> > I'm wokring on that kind of files'content, initially configured with ff=dos, ffs=unix,dos
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <PROP ID="script" VALUE="&apos; Init properties
> > Option Explicit
> >
> > Dim varName1, vaName2
> > Dim nameOfBar
> > &apos; array creation of components
> > fnameOfBar = split(Parent.somefoobar, &quot;|&quot;)
> > "/>
> >
> >
> > 1/ Instead of the whole content up above, I see only one line with ^M in place of endline CR LF.
> >
> >
> > 2/ Copying this inline containing ^M in new buffer opened with setlocal ffs=unix, I do this substitution %s/^M/^M/g
> >  
> > Then I see all content in different lines.
> >
> >
> > 3/ After editing the script, I would like to restitute the modified content into original file in one line : all content inline with end of line replaced by ^M.  As at the origin.
> >
> > But all attempts fails, even these that say to pass by changing ffs at opening time and writing time.
> >
> > https://stackoverflow.com/questions/3852868/how-to-make-vim-show-m-and-substitute-it
> > https://superuser.com/questions/357760/vi-on-linux-show-m-line-endings-for-dos-format-files
> >
> >
> > Is someone can give me right way to restitute the text content inline containing ^M displayed.
>
> Can you provide an example file?
>
>
> Best,
> Christian
> --
> Es ist nicht genug, der Natur die Daumenschrauben anzulegen.
> Man muß auch hinhören, wenn sie aussagt.
> -- Arthur Schopenhauer
When I download attached file sample.xml, Vim open it in fileformat=dos and display ^M chars..

Do you want another sample ?

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Keeping endofline representation in xml fileformat dos file

Ni Va
Le vendredi 15 mars 2019 14:50:35 UTC+1, [hidden email] a écrit :

> Le vendredi 15 mars 2019 10:46:51 UTC+1, Christian Brabandt a écrit :
> > On Do, 14 Mär 2019, [hidden email] wrote:
> >
> > > Hi All,
> > >
> > >
> > > I'm wokring on that kind of files'content, initially configured with ff=dos, ffs=unix,dos
> > >
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <PROP ID="script" VALUE="&apos; Init properties
> > > Option Explicit
> > >
> > > Dim varName1, vaName2
> > > Dim nameOfBar
> > > &apos; array creation of components
> > > fnameOfBar = split(Parent.somefoobar, &quot;|&quot;)
> > > "/>
> > >
> > >
> > > 1/ Instead of the whole content up above, I see only one line with ^M in place of endline CR LF.
> > >
> > >
> > > 2/ Copying this inline containing ^M in new buffer opened with setlocal ffs=unix, I do this substitution %s/^M/^M/g
> > >  
> > > Then I see all content in different lines.
> > >
> > >
> > > 3/ After editing the script, I would like to restitute the modified content into original file in one line : all content inline with end of line replaced by ^M.  As at the origin.
> > >
> > > But all attempts fails, even these that say to pass by changing ffs at opening time and writing time.
> > >
> > > https://stackoverflow.com/questions/3852868/how-to-make-vim-show-m-and-substitute-it
> > > https://superuser.com/questions/357760/vi-on-linux-show-m-line-endings-for-dos-format-files
> > >
> > >
> > > Is someone can give me right way to restitute the text content inline containing ^M displayed.
> >
> > Can you provide an example file?
> >
> >
> > Best,
> > Christian
> > --
> > Es ist nicht genug, der Natur die Daumenschrauben anzulegen.
> > Man muß auch hinhören, wenn sie aussagt.
> > -- Arthur Schopenhauer
>
> When I download attached file sample.xml, Vim open it in fileformat=dos and display ^M chars..
>
> Do you want another sample ?
--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

vim.gif (54K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Keeping endofline representation in xml fileformat dos file

Christian Brabandt
In reply to this post by Ni Va

On Fr, 15 Mär 2019, [hidden email] wrote:

> Do you want another sample ?

I don't see a sample. And please do not send screenshots.

Christian
--
Allein ist der Zustand, in dem sich jeder Nachdenkliche befindet.
                -- Helmar Nahr

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Keeping endofline representation in xml fileformat dos file

Ni Va
Le vendredi 15 mars 2019 16:52:12 UTC+1, Christian Brabandt a écrit :

> On Fr, 15 Mär 2019, [hidden email] wrote:
>
> > Do you want another sample ?
>
> I don't see a sample. And please do not send screenshots.
>
> Christian
> --
> Allein ist der Zustand, in dem sich jeder Nachdenkliche befindet.
> -- Helmar Nahr
It was not a screenshot but a gif animation and Sample file was attached on first post.

Here it is.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

sample.zip (55K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Keeping endofline representation in xml fileformat dos file

Christian Brabandt

On Fr, 15 Mär 2019, [hidden email] wrote:

> It was not a screenshot but a gif animation and Sample file was
> attached on first post.
>
> Here it is.

Please don't send screenshots or screen captures. Since I am reading my
mails on the console, this is pretty useless to me.

It looks like you are looking for a tool like dos2unix.

Alternatively, i can successfully convert the file using

vim --clean -c ':wq! ++ff=unix' sample.xml

Best,
Christian
--
Ich will nichts mit den Nieren wagen
solang' daran die Viren nagen.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Keeping endofline representation in xml fileformat dos file

Andy Wokula
In reply to this post by Ni Va
Am 14.03.2019 um 21:21 schrieb [hidden email]:

> Hi All,
>
>
> I'm wokring on that kind of files'content, initially configured with ff=dos, ffs=unix,dos
>
> <?xml version="1.0" encoding="utf-8"?>
> <PROP ID="script" VALUE="&apos; Init properties
> Option Explicit
>
> Dim varName1, vaName2
> Dim nameOfBar
> &apos; array creation of components
> fnameOfBar = split(Parent.somefoobar, &quot;|&quot;)
> "/>
>
>
> 1/ Instead of the whole content up above, I see only one line with ^M in place of endline CR LF.
>
>
> 2/ Copying this inline containing ^M in new buffer opened with setlocal ffs=unix, I do this substitution %s/^M/^M/g
>
> Then I see all content in different lines.
>
>
> 3/ After editing the script, I would like to restitute the modified content into original file in one line : all content inline with end of line replaced by ^M.  As at the origin.
>
> But all attempts fails, even these that say to pass by changing ffs at opening time and writing time.
>
> https://stackoverflow.com/questions/3852868/how-to-make-vim-show-m-and-substitute-it
> https://superuser.com/questions/357760/vi-on-linux-show-m-line-endings-for-dos-format-files
>
>
> Is someone can give me right way to restitute the text content inline containing ^M displayed.
>
> Thank you
> NiVa

Given a file.xml with mixed file endings.

You want to
(1) make it a DOS file:
        :e ++ff=dos file.xml
        " ... further edits ...
        :w
(2) make it a Unix file:
        :e ++ff=dos file.xml
        :setl ff=unix
        " ... further edits ...
        :w
(3) keep mixed line endings:
        :e file.xml
        " ... further edits ...
        :w

--
Andy

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Keeping endofline representation in xml fileformat dos file

Bailey Stoner
In reply to this post by Christian Brabandt
Other people are here. It's not just you two. Some people like screenshots. They aren't hurting anyone. I can reproduce this issue with a brand new, unconfigured copy of Vim and an XML file easily based solely on the description.

Complaining about screenshots isn't helping anyone. This person provided significant information for people who are in a console AND people who use a GUI, which is ideal.


Mar 15, 2019, 9:57 AM by [hidden email]:

On Fr, 15 Mär 2019, [hidden email] wrote:
It was not a screenshot but a gif animation and Sample file was
attached on first post.

Here it is.

Please don't send screenshots or screen captures. Since I am reading my
mails on the console, this is pretty useless to me.

It looks like you are looking for a tool like dos2unix.

Alternatively, i can successfully convert the file using

vim --clean -c ':wq! ++ff=unix' sample.xml

Best,
Christian
--
Ich will nichts mit den Nieren wagen
solang' daran die Viren nagen.

--
--
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 [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Keeping endofline representation in xml fileformat dos file

Ni Va
Le vendredi 15 mars 2019 19:06:38 UTC+1, Brandon Stoner a écrit :

> Other people are here. It's not just you two. Some people like screenshots. They aren't hurting anyone. I can reproduce this issue with a brand new, unconfigured copy of Vim and an XML file easily based solely on the description.
>
>
>
> Complaining about screenshots isn't helping anyone. This person provided significant information for people who are in a console AND people who use a GUI, which is ideal.
>
>
>
>
>
> Mar 15, 2019, 9:57 AM by [hidden email]:
>
>
>
> On Fr, 15 Mär 2019, [hidden email] wrote:
>
> It was not a screenshot but a gif animation and Sample file was
>
> attached on first post.
>
>
>
> Here it is.
>
>
>
> Please don't send screenshots or screen captures. Since I am reading my
>
> mails on the console, this is pretty useless to me.
>
>
>
> It looks like you are looking for a tool like dos2unix.
>
>
>
> Alternatively, i can successfully convert the file using
>
>
>
> vim --clean -c ':wq! ++ff=unix' sample.xml
>
>
>
> Best,
>
> Christian
>
> --
>
> Ich will nichts mit den Nieren wagen
>
> solang' daran die Viren nagen.
>
>
>
> --
>
> --
>
> 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 [hidden email].
>
> For more options, visit https://groups.google.com/d/optout.
Hi All,
I've tried to implement Andy's answer into my existing script that is doing :

A/ extracting the mixed line from original file.
B/ put it into new tmpfile and doing the Three Steps of Andy
C/ trying to reinject after B/ Steps, the content of tmpfile into original file at same line, in state of existing mixed line.

Fails because I don't see mixed end of lines.

Thank you all. Embedded mixed scripts are more and more used by these days and would be powerful to manage them easily.

Thank you for your kindness :)
NiVa


This is the vimscript function:

fun! EditScript(cword,line) "{{{

  if a:cword=='VALUE'

        " save cursor pos
        " let @c = getcurpos()
        let s:cursorpos = getcurpos()

        let g:lineline = getline(line('.'))
        if stridx(g:lineline,'scriptparsetext')>-1
                  \ || stridx(g:lineline,'script')>-1

          let pattern='.*VALUE="\([^"]\+\)".*'
          let @o = DecodeHtmlEntities(substitute(g:lineline, pattern, '\=submatch(1)', ""))

          " extract vbscript of a mixed file https://groups.google.com/forum/#!topic/vim_use/yvObbttLY6g
          "
          " (1) make it a Dos file
          let s:tmpfile = tempname()
          sp | exe 'e +ff=dos '.s:tmpfile

          " further editing
          put=@o

          %s/
/
/g

          w! | bw!  " save it


          " (2) make it a Unix file
          sp | exe 'e +ff=dos '.s:tmpfile
          setlocal ff=unix

          " further editing
          set ft=vb
          norm gg=G

          w! | bw!  " save it

          " (3) keep mixed line endings
          sp | exe 'e +ff=dos '.s:tmpfile
          " further editing
          set ft=vb

          w! " save it

          " mappings
          map <2-LeftMouse>  :exe 'silent! call EncodeScript()'<CR>
          map <C-RightMouse> :exe 'silent! call ReInjectScript()'<CR>
          map <C-MiddleMouse> :exe 'silent! call KeepMixedLineEndings()'<CR>

        else

          echomsg 'no entering code'

        endif
  else

        echomsg 'no entering code 2'

  endif

endfunction "}}}




--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

Sample.zip (5M) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Keeping endofline representation in xml fileformat dos file

Christian Brabandt
In reply to this post by Bailey Stoner

On Fr, 15 Mär 2019, Bailey Stoner wrote:

> Other people are here. It's not just you two. Some people like
> screenshots. They aren't hurting anyone. I can reproduce this issue

Are you saying netiquette is not needed anymore? Sending additional data
with your mail to this list will be multiplied to thousands of people
and may cause a bandwidth issue to those that intentionally only use
text mail. This might actually be common  when reading mail on a mobile
phone over a gsm network. If you must include such things, send a link
to a web site such as imgur.

> with a brand new, unconfigured copy of Vim and an XML file easily
> based solely on the description.

That's why I used the `--clean` parameter. So it should work everywhere
without a custom config file.

> Complaining about screenshots isn't helping anyone. This person
> provided significant information for people who are in a console AND
> people who use a GUI, which is ideal.

See above. There is a reason the netiquette exists. Also top posting
might not be considered polite. This is actually mentioned in the
signature of every mail. So please reconsider.

Best,
Christian
--
Wie wollte einer als Meister in seinem Fach erscheinen, wenn er
nichts Unnützes lehrte!
                -- Goethe, Maximen und Reflektionen, Nr. 901

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Keeping endofline representation in xml fileformat dos file

Christian Brabandt
In reply to this post by Ni Va

On Fr, 15 Mär 2019, [hidden email] wrote:

> Fails because I don't see mixed end of lines.

If you don't see mixed end of lines, chances are that your Vim is
handling it correctly. Simply write the file in the fileformat that you
need (using the +ff=unix or ++ff=dos argument.

Else, please provide a complete example of what works, what you expect
and what did not work.

Best,
Christian
--
Frauen möchten ohne warum und wofür geliebt werden.  Nicht weil sie
hübsch, liebenswert, wohlerzogen, anmutig oder intelligent sind,
sondern einfach nur weil sie sie selbst sind.
                -- Henri Frédéric Amiel

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Keeping endofline representation in xml fileformat dos file

Ni Va
Le samedi 16 mars 2019 00:05:26 UTC+1, Christian Brabandt a écrit :

> On Fr, 15 Mär 2019, [hidden email] wrote:
>
> > Fails because I don't see mixed end of lines.
>
> If you don't see mixed end of lines, chances are that your Vim is
> handling it correctly. Simply write the file in the fileformat that you
> need (using the +ff=unix or ++ff=dos argument.
>
> Else, please provide a complete example of what works, what you expect
> and what did not work.
>
> Best,
> Christian
> --
> Frauen möchten ohne warum und wofür geliebt werden.  Nicht weil sie
> hübsch, liebenswert, wohlerzogen, anmutig oder intelligent sind,
> sondern einfach nur weil sie sie selbst sind.
> -- Henri Frédéric Amiel

In order to keep mixed line endings and get all lines in jsut One Inline as opened, here is a steps I wrote:

In register @o is the initial line  foobar^Mbar^M^Mfoo^Mbarbarfoofoo


          " (1) make it a Dos file
          let s:tmpfile = tempname()
          sp | exe 'e +ff=dos '.s:tmpfile

          " further editing
          put=@o

          %s/^M/^M/g
          w! | bw!  " save it


          " (2) make it a Unix file
          sp | exe 'e +ff=dos '.s:tmpfile
          setlocal ff=unix

          " further editing
          set ft=vb
          norm gg=G
          w! | bw!  " save it

          " (3) keep mixed line endings
          sp | exe 'e +ff=dos '.s:tmpfile
          " further editing
          set ft=vb
          w! " save it

and then before replacing initial line by modified line

          " (4) paste modified line in place of original line
  1,1d

  " reload
 Chars inline
  1,$-1s/$/\^M/
  %j
  %s/^M /\^M/g

  " copy the only inline with mixed endings and ^M appearing
  norm ^v$hy

  " return to original buffer at prev saved cursor pos
  wincmd p
  call setpos('.', s:cursorpos)


  " inject modified inline with mixed endings ^M appearing.
  norm f"p
  norm lvt"d
  norm ^


Best Regards
NiVa

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.