Lazarus

Using the Lazarus IDE => Editor => Topic started by: dculp on June 14, 2019, 11:22:11 pm

Title: Easy way to open current file in external editor?
Post by: dculp on June 14, 2019, 11:22:11 pm
Of course I can open the desired editor (Editpad Pro) and then open the current IDE file. However, is there a way to invoke the external editor and the current file directly from the Lazarus IDE?

Lazarus 2.0.2, Windows 7 Pro

Thanks,
Don C.

Title: Re: Easy way to open current file in external editor?
Post by: lucamar on June 14, 2019, 11:32:12 pm
Add it as an external tool to Lazarus - menu: "Tools->Configure External Tools ..."

Example in the attached image.
Title: Re: Easy way to open current file in external editor?
Post by: dculp on June 15, 2019, 04:01:47 am
Is there a way to open to the current IDE line number or cursor position?
Title: Re: Easy way to open current file in external editor?
Post by: lucamar on June 15, 2019, 12:03:24 pm
Is there a way to open to the current IDE line number or cursor position?

If the external editor allows setting them in the command line, then yes, using the macros $Col() and $Row().

Following on the example above for leafpad you would just set the parameters to:
Code: [Select]
--jump=$Row()
$EdFile()

Note that if the file on disk is different than the one in the IDE (i.e. if it's modified) you have to save it first by adding $Save() to the parameters like this:
Code: [Select]
--jump=$Row()
$EdFile()
$Save()

As yo can see in the image, there is a full list of macros in the "Add tool" window. Play with them to see their effects :)
Title: Re: Easy way to open current file in external editor?
Post by: dculp on June 20, 2019, 03:02:51 pm
The following works in EditPadPro7 where command line parameters L=line and C=column --

$EdFile() /L$Row() /C$Col()