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

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).


Solution 1:

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.

Solution 2:

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.

Solution 3:

@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.

Solution 4:

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!