Can I insert .jpeg and .gif images in my Vim files?

7

3

Well I am new in Vim. So learning while working using Vim. I am currently learning Kivy (A Python framework) and taking some notes using Vim. However sometimes I need to save pictures (like .jpeg, .bmp etc.) and animations (like .gif) in my notebook. But the problem is after spending 15 minutes in Google I did not get any good answer to whether I can insert pictures and animations to my Vim documents or not? If I can insert then how can I do so? Can anyone let me know if there is any way to do?

So why you should insert .gif images?

You can see this .gif image (http://kivy.org/docs/api-kivy.uix.anchorlayout.html#module-kivy.uix.anchorlayout). It gives much better idea than reading tons of words. I just want to save .gif images like this. I know I can download and play these images using IE. Also I can create links from my Vim document to the file to play it using IE. But I think the most convenient way would be inserting the file inside of my notebook(i.e. my Vim file).

Hellboy

Posted 2015-03-05T14:50:35.203

Reputation: 91

Answers

5

I hope to complete other answer with more existing solutions.

Emacs way

Maybe emacs allows that you want : it allows to show images in buffer and to play animation, (M-x find-file RET ~/example.gif RET image-toggle-animate). In org-mode you can add image in your note and then open it aside, and animate (this scriptable).

Vim way

As said, Vim is just a text editor it can only show and color text. (this part feel like i'm doing my auto-promotion)

You can embed poor qualities images (pixel art 16 colors 80x80 pixel with a 1ppi resolution) in text files with Vim-Supertxt.

For the case of taking notes, i proceed with Vim-Zim that i configured to open image with feh (a small picture viewer) or gifview -a (animated gif viewer) using the keybinding <Leader><Tab>. Alternatively you could use zim --server Notes to render the notes on a local webserver (localhost:8080).

Zim way

Zim is a personal wiki which could do what you want.

But to see animated GIF you shall insert image (check option 'import image in note') and then start a local web server with Zim.

Luffah

Posted 2015-03-05T14:50:35.203

Reputation: 51

1

since 16 october 2015 is possible convert .jpg/.png in ASCII https://github.com/ashisha/image.vim

python required.

does exists also thumbnail.vim: https://github.com/vim-scripts/thumbnail.vim but i don't know how to use this. Maybe it requires building?

Have fun!

kompowiec2

Posted 2015-03-05T14:50:35.203

Reputation: 11

You can freely edit your own posts but for your protection, this must be done under the original user account. It looks like you have created a second account, which will also interfere with your ability to comment on your post. See Merge my accounts to get your accounts merged, which will solve the problem.

– fixer1234 – 2015-12-10T17:37:09.487

1

This names a couple of tools but doesn’t answer how to accomplish what was asked.  Also, external links can become unavailable, in which case the answer would have no value.  Please see How do I recommend software in my answers?

– Scott – 2015-12-11T21:52:54.750

@fixer1234: I see you also have a library of canned comments.  You might want to be a bit more careful with it; I don't know of any browser that recognizes http://%24siteurl%24/…. – Scott – 2015-12-11T21:57:28.653

@Scott: Glad you spotted that. I had problems for a few days with the SE Auto-Comment add-in. It uses that variable and normally substitutes an actual URL. I didn't think to check it because it normally works, and the bad "link" is formatted like a real one. I should probably just edit those placeholders to hard-code the link. Thanks. – fixer1234 – 2015-12-11T22:23:57.090

@fixer1234: Ah, so you've gone high-tech.  I'm a caveman; I just have a document from which I copy and paste.  :-)  ⁠ – Scott – 2015-12-11T23:16:24.007

1

No.

Vim is a text editor; as such it only deals with raw text and is not capable of embedding images or sound files or whatever.

You should try something like EverNote or OneNote instead.

romainl

Posted 2015-03-05T14:50:35.203

Reputation: 19 227

Well then I can try MSWord as I am familiar to it. But don't you think any plugin can do the job? – Hellboy – 2015-03-05T16:55:47.160

@Hellboy no plugin will be able to do that. Check Vim FAQ 1.1.

– mMontu – 2015-03-05T17:23:22.740

@Hellboy, no any plugin can only do, what Vim supports. There is no possibility to add new features, that Vim does not support. If you want images, then keep using a word processor – Christian Brabandt – 2015-03-06T05:53:33.257

Alternatively, one can extend gVim. Vim is open-source. Displaying an image is one of the easiest tasks in the hello world. – Evgeni Sergeev – 2015-07-11T05:29:22.303

1

@romainl is right, but I want to give his answer a different spin.

Vim supports editing a vast set of different file types. Though it can open binary files (which most images are encoded in), it is predominantly used to edit text files. That's where Vim's editing capabilities shine and enable very efficient editing.

So, though many file formats are edited by programmers and technical people inside Vim, most of them are meant to be consumed by another application: Python scripts are executed by the Python interpreter, HTML is viewed in the browser, Markdown may be transformed into another format.

Conclusion

Keeping a notebook is a good practice, and you certainly can use Vim to efficiently maintain it. However, if you have a need for including graphics (and elaborate formatting like headers in different font sizes etc.), Vim will only support you with the editing part, the viewing has to be done in a different application. (But that's okay and quite common, as I've outlined.)

For the format, there are many possibilities: HTML, Markdown, or any kind of Wiki (which are mostly browser-based, but you can integrate Vim with browser editing, e.g. via the Pentadacyl addon for Firefox).

If this feels too complex for you, better stick with one of the mentioned all-in-one alternatives like MS Word or OneNote.

Ingo Karkat

Posted 2015-03-05T14:50:35.203

Reputation: 19 513