Closed aidanmaney closed 3 months ago
I personally don't use Vim key bindings, so I'm not familiar with them (although I know some very basic stuff) and I'm not sure what keys should be assigned to what functionality in the case of PDF viewers.
If you could list all the keys and the corresponding functionality that you want to have in detail, I might be able to add this feature (although the priority is not very high, unfortunately).
For example, should j
scroll to the next page or do the same thing as the space
key does currently?
Apologies for the slow response.
Referencing this cheat sheet I think the following subset of mappings would be useful:
Key/Chord | Action |
---|---|
J | Go to next page |
K | Go to previous page |
gg | Go to first page |
Shift + G | Go to last page |
Shift + H | Go to top of current page |
Shift + L | Go to bottom of current page |
Ctrl + C or Esc | Abort (e.g. stop capturing input to search bar) |
Control + N or Enter | Go to and highlight next match |
Shift + Control + N or Shift + Enter | Go to and highlight previous match |
+ | Zoom in |
- | Zoom out |
= | Zoom to original size |
/ | Search for text (forward in document) |
? | Search for text (backward in document) |
: | Enter command mode (with commands to be added later) |
To answer your question I would have j
put the viewport at the top of the next page rather than move a set distance like space
does now.
Thank you for considering this addition!
Thanks, a subset of your list has been experimentally supported in 0.39.10.
0.39.17 added the support for y
(copy the selected text).
BTW Recently, I've started learning vim myself and found it very attractive. I hope I will be able to support more and more key bindings in the future.
Currently, PDF++'s vim support is kinda hacky. It uses Scope
, which isn't supposed to be used with multi-char key bindings.
https://github.com/RyotaUshio/obsidian-pdf-plus/blob/main/src/vim.ts
Given the nature of the Scope
class, it's not easy to support complex key bindings like 10g
(go to page 10).
I'd appreciate any help from those who know the right way.
From the next version (0.39.25), j
/k
/h
/l
will scroll the page rather than take you to the next/previous page.
This is the identical behavior to Zathura.
To go to the next/previous pages, use => from 0.39.26, use J
/K
/H
/L
instead.J
/K
. H
and L
will be aliases for ^
and $
, respectively, which scrolls the page to the top/bottom.
The next version (0.39.25) will also add the support for
/
/?
- search forward/backwardn
/N
- go to next/previous matchI found a related thread on the forum: https://forum.obsidian.md/t/vim-movement-on-pdf-reader/65198
Currently, PDF++'s vim support is kinda hacky. It uses
Scope
, which isn't supposed to be used with multi-char key bindings.https://github.com/RyotaUshio/obsidian-pdf-plus/blob/main/src/vim.ts
Given the nature of the
Scope
class, it's not easy to support complex key bindings like10g
(go to page 10). I'd appreciate any help from those who know the right way.
I somehow managed to get this kind of commands to work! For example, you will be able to do
2j
to scroll down the page twice as much as j
2J
to advance two pages10G
to go to page 10150=
to set the zoom level to 150%from the next version.
I believe PDF++'s vim mode is now powerful enough to close this issue. For requesting a new vim feature or reporting bugs, please create a new issue. Thank you!
Describe your request
PDF viewers like Zathura support Vim-style bindings for search, navigation, etc.
Since many Obsidian users (myself included) enjoy the built-in Vim-mode in Obsidian, it would be nice to navigate PDFs in much the same way.
My initial idea would be to capture input(s) on a PDF page and map it to the corresponding key(s) e.g. the page-up/down and home/end keys and either re-use the existing Vim command bar for search or add a modal.