m (moved Backward search for LaTeX documents on Mac OS X to Backward search for LaTeX documents: Tip should become more general than just Mac OS X) |
No edit summary |
||
Line 5: | Line 5: | ||
|created=January 11, 2007 |
|created=January 11, 2007 |
||
|complexity=intermediate |
|complexity=intermediate |
||
− | |author= |
+ | |author= |
− | |version= |
+ | |version= |
− | |rating= |
+ | |rating= |
|category1=LaTeX |
|category1=LaTeX |
||
− | |category2= |
+ | |category2= |
}} |
}} |
||
+ | When editing LaTeX with Vim and previewing the pdf with a pdf viewer, you would like to be able to click on a word in the pdf viewer and have vim automatically jump to the location in the source file you clicked on. This is called backwards search, since clicking in the pdf viewer updates the vim location. To update the pdf viewer to a page containing the current location in Vim, see [[Open pdf to the current location in a LaTeX file]]. |
||
− | Latex is a great language for typesetting scientific documents. |
||
+ | == Linux == |
||
− | The content of the document is written in some wonderful editor (Vim) and compiled to a PDF with all the bells and whistles. |
||
⚫ | |||
+ | There are some instructions [http://jlebl.wordpress.com/2011/01/13/vim-evince-and-forward-and-backward-latex-synctex-search/ here], but they should be copied into this page. |
||
+ | == Windows == |
||
− | When editing a document, one often reads the PDF, then goes back to the editor to change a couple of words. |
||
+ | {{Todo}} |
||
+ | Find how to do this on Windows. |
||
+ | == Mac == |
||
− | A great feature found in some other editors is the ability to jump to the word under the cursor directly from the viewer. That greatly reduces time spent while editing the document. |
||
− | + | Mac OS has a package called pdfsync and a supporting viewer (I strongly recommend PDFView) can be configured to run a custom script when the user command-clicks inside the document. |
|
− | |||
− | pdfsync and a supporting viewer (I strongly recommend PDFView) can be configured to run a custom script when the user command-clicks inside the document. |
||
− | |||
− | Sadly, the current version of Vim for Mac doesn't support clientserver feature of the standard version, so I could not use the <tt>--remote</tt> flag to send the command to Vim. |
||
− | |||
− | So I hacked together a small UI script that tells the windowing environment to perform the remote actions. |
||
− | |||
− | Together. you can now point to a word in the PDFView and it will take you to the right place in your editor of choice. |
||
− | |||
− | The AppleScript itself: |
||
− | |||
− | <pre> |
||
− | on run argv |
||
− | set CR to ASCII character of 13 |
||
− | set ESC to ASCII character of 27 |
||
− | set filename to (item 1 of argv) |
||
− | set lineNum to (item 2 of argv) |
||
− | tell application "Vim" to activate |
||
− | tell application "System Events" |
||
− | tell process "Vim" |
||
− | keystroke ESC & ":set hidden" & CR |
||
− | keystroke ":if bufexists('" & filename & "')" & CR |
||
− | keystroke ": buffer " & filename & CR |
||
− | keystroke ":else " & CR |
||
− | keystroke ": edit " & filename & CR |
||
− | keystroke ":endif" & CR |
||
− | keystroke ":" & lineNum & CR |
||
− | keystroke "zO" -- open folds, if any exists. |
||
− | end tell |
||
− | end tell |
||
− | end run |
||
− | </pre> |
||
− | |||
− | ==Comments== |
||
⚫ | |||
− | There is a script {{script|id=1951|text=bash script}} that updates this AppleScript. |
||
+ | To enable backwards search, install and configure the {{script|id=1951|text=gvim-pdfsync}} plugin. |
||
− | The improvements: |
||
− | * It's a bash script, and so it's easier to use in PDFSync-compatible applications like [http://skim-app.sourceforge.net/ Skim]. |
||
− | * It has no problems when you try to open two different files with the same base name. |
||
− | * It has no problems with filenames with spaces. |
Revision as of 07:14, 28 November 2011
created January 11, 2007 · complexity intermediate · version
When editing LaTeX with Vim and previewing the pdf with a pdf viewer, you would like to be able to click on a word in the pdf viewer and have vim automatically jump to the location in the source file you clicked on. This is called backwards search, since clicking in the pdf viewer updates the vim location. To update the pdf viewer to a page containing the current location in Vim, see Open pdf to the current location in a LaTeX file.
Linux
TO DO
There are some instructions here, but they should be copied into this page.
Windows
TO DO
Find how to do this on Windows.
Mac
Mac OS has a package called pdfsync and a supporting viewer (I strongly recommend PDFView) can be configured to run a custom script when the user command-clicks inside the document.
To enable backwards search, install and configure the gvim-pdfsync plugin.