Keyboard shortcut for deleting a line

3,390 views
Skip to first unread message

Hai Vu

unread,
Sep 9, 2008, 1:16:50 PM9/9/08
to TextWrangler Talk
Hello all,
Is there a keyboard shortcut to delete a line? I am aware of Cmd+L to
highlight the current line, then I can delete. Is there a faster way?

Jim McCarty

unread,
Sep 9, 2008, 3:14:37 PM9/9/08
to textwr...@googlegroups.com

If Use Emacs key bindings is selected (Preferences->Editing:
Keyboard), ctrl-k will yank all text to the right of the insertion
point, up to the line feed. To get the line feed, ctrl-k one more
time.

The text yanked is on the clipboard.

Jim


--

Napoleon Bonaparte - "In politics, absurdity is not a handicap."

Hai Vu

unread,
Sep 11, 2008, 6:31:43 PM9/11/08
to TextWrangler Talk
Thank you Jim for you suggestion. Howevever, I don't use the Emacs key
bindings because I am not familiar with Emacs. Furthermore, what I am
looking for is a keyboard shortcut which delete the current line
regardless of your cursor position. When I use Notepad++ in Windows
world, Ctrl+L does this nice and neat. I guess I have to live with Cmd
+L, then Delete.

Hai

On Sep 9, 12:14 pm, "Jim McCarty" <hucknca...@gmail.com> wrote:

Tom Robinson

unread,
Sep 12, 2008, 4:33:22 PM9/12/08
to textwr...@googlegroups.com
On 2008-09-12, at 10:31, Hai Vu wrote:

> Furthermore, what I am
> looking for is a keyboard shortcut which delete the current line
> regardless of your cursor position.

You should be able to write a short AppleScript to accomplish this,
then assign it a keyboard shortcut through the Scripts palette.

anoved

unread,
Sep 13, 2008, 12:36:28 AM9/13/08
to TextWrangler Talk
On Sep 12, 4:33 pm, Tom Robinson <barefootg...@tomrobinson.co.nz>
wrote:
I think this might do the trick:

tell application "TextWrangler"
tell text of text document 1
set a to startLine of selection
set b to endLine of selection
delete (lines a through b)
end tell
end tell

Save this in the scripts folder (accessible with Open Scripts Folder
in TW's script menu) and set up a keyboard shortcut as Tom suggests.

Note that if you have selected text from multiple lines all of the
lines will be deleted. Otherwise, only the line containing the cursor
will be deleted.

Change "delete" to "cut" to keep the deleted line or lines on the
clipboard. Might be useful.

Jim
Reply all
Reply to author
Forward
0 new messages