10

Adobe Acrobat Reader is currently one of the good PDF readers available on the Linux platform. xpdf and Evince do their job well, but Acrobat's display seems to be better.

I am used to the Vim editor and I want Vim navigation features (using h,j,k, and l to move around) in Adobe Reader. How do I do that?

I know Evince offers that kind of navigation.

1
  • Did not know about superuser.com. I just moved the question over there. I shall let here, just in care it is of interest to somebody. Sep 14, 2009 at 11:16

9 Answers 9

3

I have set vim like navigation in Adobe Reader using AutoHotKey. You need to configure key mapping to be active only when Adobe Reader is the current active window so that this key binding does not affect other applications. The following modified AutoHotKey.ahk script does that

#IfWinActive ahk_class AcrobatSDIWindow
h::Send {Left}
Return

#IfWinActive ahk_class AcrobatSDIWindow
j::Send {Down}
Return

#IfWinActive ahk_class AcrobatSDIWindow
k::Send {Up}
Return

#IfWinActive ahk_class AcrobatSDIWindow
l::Send {Right}
Return

The ahk_class name can be determined by running AutoIt3 Window Spy.

The only drawback is during Search/Find operation in Adobe Reader. If your search text contains h/j/k/l it will be interpreted as arrow keys. You can overcome this limitation by suspending the autokey or by clicking Pause Script from the taskbar notification area. Better approach to overcome this limitation is using uppercase letters( HJKL ). Since adobe searches case insensitive, you search will cover hjkl letters too. for instance taKe matches with take

2

I'm not sure if that is possible.

But you should try Zathura, which works very well and tries to mimic vim - it even has a command line mode, triggered by :.

1
  • i hope i can annotate to pdf files with zathura too..
    – Student
    Jul 18, 2019 at 12:18
1

As far as I know, this isn't possible. There is a project under way to create a pdf viewer that has a vim-like interface, but although the development seems to be quite active, it has a way to go yet. If that's of any interest, you can find it here (versions are available for Linux and Windows, although the development is focused on Windows):

http://code.google.com/p/apvlv/

Otherwise, I think you're stuck with evince or using the cursor keys.

1

This AutoHotKey script I wrote supports hjkl, gg, G, C-e, C-y, C-f, and C-b, along with /, n, and N for searching. Pressing / takes you into search mode, and Esc, Enter, and Ctrl-[ will put you back in normal mode. If things aren't working like they should, try pressing Escape to get back into normal mode.

#IfWinActive ahk_class AcrobatSDIWindow
h:: 
if (inAcrobatSearchMode)
  Send h
else Send {Left}
return

j::
if (inAcrobatSearchMode)
  Send j 
else Send {Down}
return

k::
if (inAcrobatSearchMode)
  Send k 
else Send {Up}
return

l::
if (inAcrobatSearchMode)
  Send l 
else Send {Right}
return

n::
if (inAcrobatSearchMode)
  Send n
else Send {F3}{Esc}
return

+n::
if (inAcrobatSearchMode)
  Send N
else Send +{F3}{Esc}
return

+g::
if (inAcrobatSearchMode)
  Send G
else Send {End} 
return

; see http://stackoverflow.com/questions/1794258/detect-a-double-key-press-in-autohotkey

g::
if (inAcrobatSearchMode)
  Send g
else {
  if (A_PriorHotkey <> "g" or A_TimeSincePriorHotkey > 400) {
      ; Too much time between presses, so this isn't a double-press.
      KeyWait, g
      return
  }
  Send {Home}
}
return

/::
if (inAcrobatSearchMode)
  Send /
else {
  inAcrobatSearchMode := true
  Send ^f
}
return

Esc::
inAcrobatSearchMode := false
Send {Esc}
return

^[::
inAcrobatSearchMode := false
Send {Esc}
return

Enter::
if (inAcrobatSearchMode) {
  inAcrobatSearchMode := false
}
Send {Enter}
return

;go back into normal mode after scrolling with any control command

^e::
inAcrobatSearchMode := false
Send {Esc}{Down}
return

^y::
inAcrobatSearchMode := false
Send {Esc}{Up}
return

^f::
inAcrobatSearchMode := false
Send {Esc}{PgDn}
return

^b::
inAcrobatSearchMode := false
Send {Esc}{PgUp}
return

#IfWinActive

Here's a Gist

Please leave short bug reports or suggestions in the comments!

There are some known issues with holding down the Ctrl movement commands for long periods that have to do with AutoHotKey not being able to translate the input fast enough, but the non Ctrl movement commands shouldn't have this problem.

Unfortunately, I don't know enough about Linux or Mac OS X to be able to provide solutions for them as well. If anyone manages to port this to other operating systems, please either add your own answer or suggest an edit to this one with instructions. :)

1

In Linux, there is an alternative to AutoHotkey which is called AutoKey, and here is my solution:

(I just made it under Ubuntu 14.04 with AutoKey although it hasn't been updated for a long time)

  • Install Autokey first. Download it at https://code.google.com/p/autokey/downloads/list, extract it and follow README to compile and install it (I chose Qt version)
  • run autokey, either from Launcher, or run it in terminal at /usr/bin/autokey-qt
  • to use j to move down, just
    • create a new phrase
    • name it mendeley - up or whatever meaningful
    • in the phrase box (the large text box – which is actually an editor !) , type <up>
    • assign j as Hotkey using Set button
    • set Window Filter by clicking the last Set button
    • Save and test it in your favorate PDF viewer (mine is Mendeley because it supports highlighting and annotation)
  • and I also made k to move up, space to page down, and shift + space to page up.

Ref:

1

Sounds like a job for IronAHK!

k::send {up}
j::send {down}
l::send {right}
h::send {left}

I know basic hotkey functionality like this works, but some of the more complex commands are not yet supported by IronAHK.

1
  • Is k::Up syntax not supported?
    – Phoshi
    Nov 28, 2009 at 11:06
1

SumatraPDF is a very nice minimalist PDF and eBook reader for Windows that has a much cleaner interface than Acrobat and it has vim-like navigation keys by default and you can fully customise them.

It can also run on Linux very well under wine.

SumatraPDF

0

Meh, this question is one year old, I'll give it a try nevertheless.

Slightly off topic, because I don't know how to do it in acroread, but you might want to try Apvlv:

"Apvlv is a PDF/DJVU/UMD Viewer Under Linux/WIN32 and its behaviour [is] like Vim."

If you're willing to leave acroread, this pdf-reader will give you lots of vim-love.

Apvlv is based on libpoppler (same back-end as evince and now also xpdf), so you might encounter the same display issues that you mentioned. But it certainly fires up more quickly than acroread, which is the slowest in the industry! Good luck.

Disclaimer: I once wrote a piece of documentation for this project.

0

Notice that above answers are written almost 10 years ago (now 2023), and auto hot key has upgraded to V2.0, claiming that they had removed all #if like statements which cause above answers not working anymore:
Removed all legacy If statements, leaving only if expression, which never requires parentheses (but allows them, as in any expression).

And below is the code based on manav m-n's answer in 2013, and modified by chatGPT to be functioning now. Below code is currently used by me.


    #If WinActive("ahk_class AcrobatSDIWindow")
h::
    if (inAcrobatSearchMode)
        Send h
    else
        Send {Left}
return

j::
    if (inAcrobatSearchMode)
        Send j
    else
        Send {Down 4}
return

d::
    if (inAcrobatSearchMode)
        Send d
    else
        Send {Down 50}
return

k::
    if (inAcrobatSearchMode)
        Send k
    else
        Send {Up 4}
return

u::
    if (inAcrobatSearchMode)
        Send u
    else
        Send {Up 50}
return

l::
    if (inAcrobatSearchMode)
        Send l
    else
        Send {Right}
return

n::
    if (inAcrobatSearchMode)
        Send n
    else
        Send {F3}{Esc}
return

+n::
    if (inAcrobatSearchMode)
        Send N
    else
        Send +{F3}{Esc}
return

+g::
    if (inAcrobatSearchMode)
        Send G
    else
        Send {End}
return

g::
    if (inAcrobatSearchMode) {
        Send g
        return
    }

    if (A_PriorHotkey <> "g" or A_TimeSincePriorHotkey > 400) {
        ; Too much time between presses, so this isn't a double-press.
        KeyWait, g
        return
    }

    Send {Home}
return

/::
    if (inAcrobatSearchMode) {
        Send /
        return
    }

    inAcrobatSearchMode := true
    Send ^f
return

Esc::
    inAcrobatSearchMode := false
    Send {Esc}
return

^[::
    inAcrobatSearchMode := false
    Send {Esc}
return

Enter::
    if (inAcrobatSearchMode)
        inAcrobatSearchMode := false
    Send {Enter}
return

;go back into normal mode after scrolling with any control command

^e::
    inAcrobatSearchMode := false
    Send {Esc}{Down}
return

^y::
    inAcrobatSearchMode := false
    Send {Esc}{Up}
return

^f::
    inAcrobatSearchMode := false
    Send {Esc}{PgDn}
return

^b::
    inAcrobatSearchMode := false
    Send {Esc}{PgUp}
return

#IfWinActive

Currently, I think it is better to change Send {Down} to send {wheeldown} because it appears to be smoother and moves a larger area that suit for reading.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .