Recent

Author Topic: Copy and Past Code  (Read 438 times)

yinhuajian

  • New Member
  • *
  • Posts: 16
Copy and Past Code
« on: January 06, 2026, 08:29:46 am »
In Visual Studio, when no code is selected, pressing Ctrl + C copies the entire line where the cursor is located. Immediately pressing Ctrl + V then inserts a new line and pastes the copied code. 

Does Lazarus have a similar feature?

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: Copy and Past Code
« Reply #1 on: January 06, 2026, 09:15:31 am »
Yes, but you have to select the line(s). Lazarus behaves similar: ctrl-c, ctrl-v, ctrl-z amongst others. (Basically Wordstar)
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

fred

  • Full Member
  • ***
  • Posts: 205
Re: Copy and Past Code
« Reply #2 on: January 06, 2026, 10:23:54 am »
I asked lumo AI "write a lazarus editor macro to duplicate a line" and it gave the code and instructions to add it to the IDE.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12114
  • Debugger - SynEdit - and more
    • wiki
Re: Copy and Past Code
« Reply #3 on: January 06, 2026, 10:48:32 am »
Lazarus has a duplicate line command: Ctrl-Shift-Alt-Insert

If a selection exists, it acts on the selected lines (including the non selected part of each partly selected line).
There is another command (you can edit keys for it) that will duplicate the selection (without any extension).

There are also commands to move the current/selected lines up/down.
Or move the selected text in any direction.

And there are commands to cut/copy the current line to clipboard.
(By default, if nothing is selected, the IDE either does not copy, or does copy the "word at caret" to clipboard).
Copy/Cut can also append to existing clipboard.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12114
  • Debugger - SynEdit - and more
    • wiki
Re: Copy and Past Code
« Reply #4 on: January 06, 2026, 10:55:05 am »
If you want an exact replica of what you described you can write yourself an editor macro.
https://wiki.freepascal.org/IDE_Window:_Editor_Macros

They support Pascal script. So you can check if anything is selected or not, and then copy accordingly.
You can then assign such a macro to ctrl-C

n7800

  • Hero Member
  • *****
  • Posts: 607
  • Lazarus IDE contributor
    • GitLab profile
Re: Copy and Past Code
« Reply #5 on: January 15, 2026, 07:47:43 pm »
For reference, you can find the above features in "IDE Options > Editor > Key Mapping".

There's also an option: "IDE Options > Editor > General > Miscellaneous > Copy current word when no selection exists"

Personally, I don't enable it because I'm afraid of accidentally overwriting the buffer when I miss [Ctrl+V] ))

 

TinyPortal © 2005-2018