Jump to content

SciTE LineJumper


 Share

Recommended Posts

I hate using the arrow keys to go up or down several lines and especially loathe having to use the mouse.  Which is what I usually do after I've hit the down arrow fifteen times.  So, I cooked up this lua script which will jump the curser the indicated amount of lines either up or down.

With this installed and SciTE reloaded simply press [ctrl] + [1] through [5].  This will jump the cursor from one to five lines in the document from its current position.  To go the other way then press [ctr] + [alt] + [1] through [5].  I can add more if you think it would be necessary.  Forgot to mention that this only works with the number pad.

To use this just place the following lua file in the "...AutoIt3SciTELUA" directory.

LineJumper = EventClass:new(Common)

function LineJumper:OnKey(key, shift, ctrl, alt)
    local lines = 0

    if ctrl == true and alt == false then
            if key == 97  then
            lines = 1
            LineJumper:LineJump(lines)
        elseif key == 98  then
            lines = 2
            LineJumper:LineJump(lines)
        elseif key == 99  then
            lines = 3
            LineJumper:LineJump(lines)
        elseif key == 100 then
            lines = 4
            LineJumper:LineJump(lines)
        elseif key == 101 then
            lines = 5
            LineJumper:LineJump(lines)
        end
    elseif ctrl == true and alt == true then
            if key == 97  then
            lines = -1
            LineJumper:LineJump(lines)
        elseif key == 98  then
            lines = -2
            LineJumper:LineJump(lines)
        elseif key == 99  then
            lines = -3
            LineJumper:LineJump(lines)
        elseif key == 100 then
            lines = -4
            LineJumper:LineJump(lines)
        elseif key == 101 then
            lines = -5
            LineJumper:LineJump(lines)
        end
    end

    return false
end

function LineJumper:LineJump(lines)
    local jump_to_line = editor:LineFromPosition(editor.CurrentPos) + lines

    if jump_to_line <= 0 then
        jump_to_line = 0
    end

     editor:GotoLine(jump_to_line)

    return false
end

After you have done that then open SciTE and click 'Options' --> 'Open Lua Startup Script' and paste this line after the other lines (may require administrative rights):

LoadLuaFile("LineJumper.lua")

Not really useful but it is what it is.

Found the scite editor functions here:

Edited by jaberwocky6669
Link to comment
Share on other sites

You seem to enjoy using Lua. It looks like an interesting idea that you have created. Very good.

If you know what line number that you want to go to then you can use Ctrl+G and then enter the line number. Press return and your there. I usually hide the line numbers by default so it can be perhaps a best guess if I use it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...