Recent

Author Topic: Easy way to open current file in external editor?  (Read 592 times)

dculp

  • Full Member
  • ***
  • Posts: 104
Easy way to open current file in external editor?
« 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.


lucamar

  • Hero Member
  • *****
  • Posts: 2075
Re: Easy way to open current file in external editor?
« Reply #1 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.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

dculp

  • Full Member
  • ***
  • Posts: 104
Re: Easy way to open current file in external editor?
« Reply #2 on: June 15, 2019, 04:01:47 am »
Is there a way to open to the current IDE line number or cursor position?

lucamar

  • Hero Member
  • *****
  • Posts: 2075
Re: Easy way to open current file in external editor?
« Reply #3 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 :)
« Last Edit: June 15, 2019, 12:18:44 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

dculp

  • Full Member
  • ***
  • Posts: 104
Re: Easy way to open current file in external editor?
« Reply #4 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()