Last active
December 19, 2015 18:38
-
-
Save rkaneko/6000000 to your computer and use it in GitHub Desktop.
^Mの変換が上手くいかない。。。 normal modeから
:%s/^M//ge ( ^M は <Ctrl+v> Enter のように入力しています。 ) と打つのと同様のことを実現する関数を作り、normal modeから :RemakeXML と入力して下記サンプル ( hoge.xml ) の ^M 部分の変換を実現したい。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"see : http://www.kaoriya.net/blog/2012/02/09/ | |
function! s:remake_xml() | |
%s/\n//ge | |
endfunction | |
command! -nargs=0 RemakeXML call <SID>remake_xml() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"see : http://www.kaoriya.net/blog/2012/02/09/ | |
" ↑のエントリに載っているものを関数化したもの | |
function! s:remake_xml() | |
set ft=xml | |
%s/></>\r</ge | |
%s/>\(\S\)/>\r\1/ge | |
%s/\(\S\)</\1\r</ge | |
%s/\r//ge | |
gg=G | |
endfunction | |
command! -nargs=0 RemakeXML call <SID>remake_xml() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<place id="p1">^M <name>^M <graphics>^@<offset x="" y="" />^@</graphics>^M <text>p1</text>^M </name>^M <marking>^M <graphics>^@<offset x="" y="" />^@</graphics>^M <text>0</text>^M </marking>^M <graphics>^@<position x="166" y="78" />^@</graphics>^M </place> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment