I have a lot of inline images and I want to disply only 1 in buffer and hide others while viewing.

With M-x org-toggle-inline-images I can do this for the entire buffer, but it's too much for me.

So, how can I do this?

Update: With M-x org-open-at-point I can preview the image, but I would like to be able to compare multiple images.

1 Answer 1


I don't think that there is anything ready-made, but it does not take too much work to create something like that. The main question is what interface you find convenient.

org-toggle-inline-images (bound to C-c C-x C-v) calls the function org-display-inline-images underneath the covers (that is mentioned in the doc string BTW - do C-h f org-toggle-inline-images to see it).

If you do C-h f org-display-inline-images, you will see that it is capable of displaying images in a region:

(org-display-inline-images &optional INCLUDE-LINKED REFRESH BEG END)


BEG and END define the considered part. They default to the buffer boundaries with possible narrowing.

So one way to go is to narrow the buffer to a region that contains just the image you want with C-x n n, toggle inline images with C-c C-x C-v and widen the buffer with C-x n w. That's probably too much work so we can write a more targeted function:

(defun ndk/org-display-inline-images (beg end)
  (interactive "r")
  (org-display-inline-images nil nil beg end))

(define-key org-mode-map (kbd "C-c v") #'ndk/org-display-inline-images)

The function passes the region to org-display-inline-images, so you avoid the narrowing/widening of the buffer. We also define a keybinding to it, so it can be called easily. Now all you have to do is select a region that contains one or more images, press C-c v and the image(s) within the region will be inlined. You can get rid of the inlining with C-c C-x v, i.e. calling our old friend org-toggle-inline-images.

If that's still too much work, you can write a more specialized function that determines the region around the link at point on its own and passes that region to org-display-inline-images. It's more limited in the sense that it will only look for one image around point, never more than one, but you might prefer that:

(defun ndk/org-display-inline-image-at-point ()
  (let* ((context (org-element-context (org-element-at-point)))
         (type (org-element-type context))
         (beg  (plist-get (cadr context) :begin))
         (end  (plist-get (cadr context) :end)))
     (when (eq type 'link)
        (org-display-inline-images nil nil beg end))))

(define-key org-mode-map (kbd "C-c v") #'ndk/org-display-inline-image-at-point)

This version uses the org-element parser to figure out the "thing" around point and it finds a link, it gets the beginning and the end of the region that the link occupies and passes that region to org-display-inline-images as before.

Putting your cursor on a link and saying C-c v then inlines the link. Moving to another link and doing C-c v there undoes the previous inlining and inlines the new link. If any inlining is showing, then using the toggle function with C-c C-x C-v gets rid of all inlining.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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