Open og900aero opened 2 months ago
Hi
In my Windows setup I wanted to delete the current line or all partially selected lines (my version of wordstar yank block ^KY):
CTRL+Y
as follows in bindings.json "CtrlY": "lua:initlua.delsel,SelectLine,Delete",
function delsel(Current)
-- Please see the Ctrl+Y binding. This avoids deleting EOL
if Current.Cursor:HasSelection(Current) then
Current.Cursor:DeleteSelection()
end
end
CTRL+Y
, it works on Windows console and Windows terminal.Kind Regards Gavin Holt
function delsel(Current) -- Please see the Ctrl+Y binding. This avoids deleting EOL if Current.Cursor:HasSelection(Current) then Current.Cursor:DeleteSelection() end end
I paste the following line in the bindings.json:
"Ctrl-k": "lua:initlua.delsel,SelectLine,Delete",
Then I create ~/.config/micro/init.lua file, and insert the following rows:
function delsel(Current)
-- Please see the Ctrl+Y binding. This avoids deleting EOL
if Current.Cursor:HasSelection(Current) then
Current.Cursor:DeleteSelection()
end
end
Now , when I press ctrl+k, the the following error message appear:
init:3: invalid number of function arguments (1 expected, got 2)
stack traceback:
[G]: in function 'HasSelection'
init:3: in main chunk
[G]: ?
Press enter to continue
Hi
Sorry try:
function delsel(Current)
-- Please see the Ctrl+Y binding. This avoids deleting EOL
if Current.Cursor:HasSelection() then
Current.Cursor:DeleteSelection()
end
end
Kind Regards Gavin Holt
Hi
Sorry try:
function delsel(Current) -- Please see the Ctrl+Y binding. This avoids deleting EOL if Current.Cursor:HasSelection() then Current.Cursor:DeleteSelection() end end
Kind Regards Gavin Holt
Thx. Working great.
But it wouldn't be bad if the deletion would also work with the Cut command when pressed for a long time, as in the case of a Linux terminals.
I use micro in Windows 10 with Windows terminal preview 1.20.10822.0 When I open file for edit in micro, then I hold down the CTRL+K key, it doesn't continuously delete the lines, but does nothing. When I release it, it deletes one row. If I use the nano program, there is no such problem.
I tried with the following version:
$micro --version Version: 2.0.13 Commit hash: 68d88b57 Compiled on October 21, 2023
$ micro --version Version: 2.0.14-dev.155 Commit hash: 55103179 Compiled on April 23, 2024
bindings.json: