Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I copied the content of an ant build.xml document from an .odt file to Vim editor. There were no garbage characters I could observe, but the build process failed due to incorrect XML tags.

I assume this is due to garbage characters which are invisible to Vim. When I type the same content in Vim it works fine. What would be the solution for my issue? I also tried gedit, but still I can't see any garbage characters.

share|improve this question
1  
Vim doesn't hide a lot from its user. As a matter of fact as far as I'm aware of, vim doesn't hide anything for its user. That is a key feature of the editor. Can you copy (part of) the file that seems to give you problems? –  jippie Jun 17 '12 at 18:08
3  
what do you mean with garbage characters? Without more details, e.g. what is the error message, what characters do you expect, what incorrect xml tags etc. we can not help. For a quick check you can use hexdump -C to check the file. –  Ulrich Dangel Jun 17 '12 at 18:10
    
what is the error you get from ant build? did you check for angled quotes (instead of quotes) and "long" dashes (instead of dashes)? That's the garbage usually word processors put in files they are not intended to open. –  guido Jun 18 '12 at 11:24

1 Answer 1

I don't know how you're copied the content (copy-paste from other editor to vim is a very bad idea), so I'll indicate two forms for to copy the content without remove/add characters.

  • Open vim.
  • :e build.xml
  • Esc
  • v
  • Select the text.
  • y
  • :e destination.txt
  • p
  • :wq

  • Open vim.
  • :e destination.txt
  • :r build.xml
  • :wq

You can also do cat build.xml >> destination.txt and after to edit the file.

share|improve this answer
    
Why is it a bad idea to paste into vim from another editor? Can you elaborate on that? It has always worked for me (using UTF-8 on both sides). You paste what you copied. –  Marco Jun 17 '12 at 19:24
    
e.g.: two terminal, the first with vim and the second with other editor. If you copy/paste from the second terminal the text of a file with tabs to the first terminal (vim), you copy the tabs as spaces. This is my experience. But we don't know what are the "garbage characters" of the file of the OP. Firstly I want discard this problem. –  Juan Francisco Cantero Hurtado Jun 17 '12 at 19:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.