Git Product home page Git Product logo

Comments (4)

Gavin-Holt avatar Gavin-Holt commented on June 9, 2024

Hi

In my Windows setup I wanted to delete the current line or all partially selected lines (my version of wordstar yank block ^KY):

  1. I bind CTRL+Y as follows in bindings.json
    "CtrlY": "lua:initlua.delsel,SelectLine,Delete",
  1. From my init.lua file:
function delsel(Current)
-- Please see the Ctrl+Y binding. This avoids deleting EOL
    if Current.Cursor:HasSelection(Current) then
        Current.Cursor:DeleteSelection()
    end
end
  1. This repeats if I hold down CTRL+Y, it works on Windows console and Windows terminal.

Kind Regards Gavin Holt

from micro.

og900aero avatar og900aero commented on June 9, 2024
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

from micro.

Gavin-Holt avatar Gavin-Holt commented on June 9, 2024

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

from micro.

og900aero avatar og900aero commented on June 9, 2024

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.

from micro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.