Friday, March 15, 2019

Re: Keeping endofline representation in xml fileformat dos file

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 cbl...@256bit.org:
>
>
>
> On Fr, 15 Mär 2019, niva...@gmail.com 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 vim_use+u...@googlegroups.com.
>
> 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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: