4

with sublime text, I can delete from cursor to end of line with

super+k-k

how I can delete from cursor to the end of file ?

10

No need to write a script. Simply highlight the first line you want to delete, then:

Ctrl+Shift+End

This will select all the text until the end of the file. Then just press delete!

This works in many different programs. Not just sublime Text.

  • 2
    Use Cmd+Shift+down if you're on mac – igrek Jun 8 '17 at 17:38
1

It's not too hard, but you'll have to create a macro and a custom key binding to do it. First, create a new file with the following contents:

[
    {"command": "move_to", "args": {"to": "eof", "extend": true}},
    {"command": "add_to_kill_ring", "args": {"forward": true}},
    {"command": "right_delete"}
]

Save the file as ~/Library/Application Support/Sublime Text 2/Packages/User/Delete to EOF.sublime-macro. You can access the Packages folder by going to Sublime Text 2 -> Preferences -> Browse Packages... - this will open up a new Finder window in the right directory.

Next, go to Sublime Text 2 -> Preferences -> Key Bindings - User. If you haven't made any custom key bindings before, this file will be empty, otherwise it will contain previous key bindings. If it is empty, paste the following into it and save:

[
    { "keys": ["super+k", "super+f"], "command": "run_macro_file", "args": {"file": "Packages/User/Delete to EOF.sublime-macro"} }
]

Make sure the value for "file": is exactly the same name as the macro file you just created. If you already have custom key bindings, simply copy the middle line (leave out the square brackets on the first and last lines) and paste it at the beginning of your key bindings file, on a line just after the opening bracket [. Make sure you add a comma , at the end of the line:

[
    { "keys": ["super+k", "super+f"], "command": "run_macro_file", "args": {"file": "Packages/User/Delete to EOF.sublime-macro"} },
    // existing key bindings...
]

Save the file, and you should now be able to hit Command ⌘K,Command ⌘F and delete to the end of the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.