user4035
user4035

Reputation: 23719

How to make a link to external file line in Emacs org-mode

I have 2 files:

  1. php file with code
  2. org file with docs

How to create a link to a line in php file from org file? So clicking it will move the cursor to the appropriate line in php file.

Upvotes: 24

Views: 18476

Answers (3)

Jeff Rush
Jeff Rush

Reputation: 91

For posterity and some future seeker of this information, which I've been using for a few years in my docs.

Use: [[file+emacs:/path/to/file.php::line]]

The '+emacs' forces Emacs to open the link inside Emacs instead of some other app that handles that file extension.

Upvotes: 1

Nek
Nek

Reputation: 1944

If I understand the question right you can do it automatically with two org-mode commands:

Move the point to a line in a php file and M-x org-store-link.

Go to an org file and C-c C-l or M-x org-insert-link and follow the instructions in the minibuffer.

You are done, click the link or C-c C-o when the point is on it to open the link.

I have org-store-link on C-c l and org-insert-link on the default C-c C-l. This makes the process very convenient and fast to execute.

Have fun with org-mode.

Upvotes: 21

choroba
choroba

Reputation: 241758

Use this notation in the org mode to create a link:

[[/path/to/file.php::line][string-to-display]]

If you want the file name to be displayed, use just

[[/path/to/file.php::line]]

See Hyperlinks in the Org mode Info page for details and other ways to specify links.

Upvotes: 30

Related Questions