Created
August 16, 2018 10:18
-
-
Save lukpueh/ebc8410c1ce97045d76992ffb6091e9b to your computer and use it in GitHub Desktop.
Sublime Text 3 command to find next or previous occurrence of a string in a tex document and in the corresponding open pdf document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Sublime Text 3 command to find next or previous occurrence of a string in a tex | |
document and in the corresponding open pdf document, built with ST3 package | |
`LaTeXTools`, and displayed using OSX pdf viewer `skim`. | |
Add snippet to new *.py file in: | |
~/Library/Application\ Support/Sublime\ Text\ 3/Packages/User/ | |
Handy keybindings: | |
(~/Library/Application Support/Sublime Text 3/Packages/User/Default (OSX).sublime-keymap | |
) | |
``` | |
[ | |
{ "keys": ["ctrl+x"], "command": "find_in_pdf", "args": {"from_keybinding": true} }, | |
{ "keys": ["ctrl+z"], "command": "find_in_pdf", "args": {"from_keybinding": true, "prev": true} }, | |
] | |
``` | |
""" | |
import sublime | |
import sublime_plugin | |
class FindInPdf(sublime_plugin.TextCommand): | |
def run(self, *args, **kwargs): | |
from_keybinding = kwargs.pop("from_keybinding", False) | |
# Jump to previous or next occurrence | |
if kwargs.pop("prev", False): | |
self.view.window().run_command("find_prev", {"select_text": True}) | |
else: | |
self.view.window().run_command("find_next", {"select_text": True}) | |
# Show corresponding line in pdf | |
self.view.run_command("jump_to_pdf", {"from_keybinding": from_keybinding}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment