Using Vim to edit Microsoft Word files
Asked Answered
S

4

23

I've found ViEmu, a vi emulator for microsoft word. However, I wanted to use vim to edit DOC or even rtf files. Is this possible ?

Are they any other formats that preserve page/paragraph layout compatible with both Microsoft Word and Vim? I am also open to OpenOffice formats.

Sled answered 23/9, 2010 at 12:13 Comment(1)
I have a huge need for this as well. OpenOffice has a bug where it is changing the font and size of the last few characters of each form field in .dot files. All I need to be able to do is edit the text fields in a file. If you just open the file in vim, you can at least see the text strings; haven't tried modifying them yet. The console "strings" program might help converting in one direction, but I'm not sure how to go back. There must be some general tool out there for modifying the strings in some nasty binary blob...Ackley
M
21

That’s not possible. Vim is by its very nature a plain text editor and doesn’t offer Microsoft Word style WYSIWYG. You cannot edit formatted documents.

To be sure, you can edit the source code of an RTF file (RTF is a fairly simple formatting language so editing it manually is theoretically possible) but I don’t think this is what you’re after.

If you want to edit using Vim but still produce documents with formatting, your best shot is LaTeX. This allows you to create professional documents via a macro programming language.

Markham answered 23/9, 2010 at 12:14 Comment(2)
Its ok, I can always copy paste between gvim and MSWord, its not such a big loss. I was just curious. Thanks for your reply.Sled
Sorry taking me so much time to accept your answer, i forgot :)Sled
C
8

If you are willing to install a plugin called textutil.vim you can do this. The caveat is that when you open the program in vi/vim it converts the .rtf or .doc file to plain text and then converted back when you save it back.

As with all conversions you are liable to lose something in it, but at least it allows you to edit something in a pinch.

Campbellbannerman answered 23/9, 2010 at 12:19 Comment(1)
textutil.vim is just a wrapper around OS X's textutil command, which supports docx in recent versions of OS X, so it would just involve adding a few lines to the script. Here's a modified version: hastebin.com/raw/emahawaqel (can't test as I'm not on OS X.)Brest
J
4

I had a similar question... The guys at the *nix forum really helped out. Have a look at their answers, all of them, they are all good solutions for various people in all sorts of different circumstances. https://unix.stackexchange.com/questions/64014/editing-rich-text-format-files-command-line/64037

Johnstone answered 7/2, 2013 at 15:53 Comment(0)
W
1

Not WYSIWYG, but you can create documents with formatting using Markdown. It's a very simple version of HTML and it produces beautiful documents easily.

You could edit the documents in VIM itself, or you could use Rstudio (which is free) with VIM keybindings enabled.

Using Rstudio you can easily convert your markdown to Word, HTML and Latex.

http://rmarkdown.rstudio.com/

https://www.rstudio.com/products/rstudio/download/

Weinberger answered 27/5, 2016 at 10:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.