12

In Eclipse you can press ALT-(arrows) to move a line up or down.

Has anyone discovered these hotkey features in TextWrangler?

1

5 Answers 5

5

For Mac OS X it is ctrl+ or ctrl+.

You may need to change the Mission Control hotkey settings (in System Preferences) as the two keyboard strokes are preset there.

2
  • 1
    verified, this is the correct answer
    – Alex
    Jun 3, 2016 at 9:37
  • 2
    Works the same in BBEdit. Text Wrangler was "sunsetted" by Bare Bones (makers of TextWrangler and BBEdit).
    – iaforek
    Oct 13, 2017 at 15:39
2

There's nothing mentioned in the manual (only Exchange characters and Exchange words).


If TextWrangler supports the Cocoa Text System (which I suspect it doesn't, but still) you can create the file ~/Library/Keybindings/DefaultKeyBinding.dict and enter the following:

{
    "~\UF701" = (
        "moveToBeginningOfLine:",
        "deleteToEndOfLine:",
        "deleteForward:",
        "moveDown:",
        "yank:",
        "insertNewline:",
        "moveUp:"
    );
}

This will add the shortcut Opt-DownArrow for a line-swap command (with the line below) to every application supporting the Cocoa text system.

1
  • If TextWrangler does not support this: get a real text editor. Even TextMate supports this.
    – Daniel Beck
    May 15, 2011 at 21:28
2

I do not think TextWrangler has this built in.

You can run applescripts in TextWrangler though, so you could make this work. I even found some applescripts that will do this.

You will need to replace BBEdit with TextWrangler in the applescripts. Put the scripts in "~/Library/Application Support/TextWrangler/Scripts/" and they will show up on the scripts menu in TextWrangler. Click Window -> Palettes -> Scripts to view the scripts palette, where you can set custom keyboard shortcuts.

1
  • If you want to assign those to Option-Up (⌥↑) and Down, you can use the Keyboard System Preference. TextWrangler didn't allow me to use "Option"(⌥) as an modifier. Now it works very sleek.
    – Klaas
    Aug 3, 2012 at 12:39
0

nathangs solution works pretty well. But the provided link does not work anymore. So here are the scripts as plain text. Just paste them into the "AppleScript Editor" and save them to ~/Library/Application Support/TextWrangler/Scripts/

Works fine on Mountain Lion and with TextWrangler 4.

MoveLineDown.scpt:

tell application "TextWrangler"
    set x to startLine of selection
    tell text 1 of window 1
        if x = (count of lines) then return
        set myline to contents of line x
        delete line x
        if length of line x = 0 then
            make line at line x with data "
"
            make line at line (x + 1) with data myline
        else
            make line at line x with data myline

        end if
        select insertion point before line (x + 1)
    end tell
end tell

MoveLineUp.scpt:

tell application "TextWrangler"
    set x to startLine of selection
    if x = 1 then
        beep
        return
    end if
    tell text 1 of window 1
        set oldCount to count of lines
        set myline to contents of line x
        delete line x
        if x = 2 then
            if length of line 1 = 0 then
                make line at beginning with data "
"
            end if
            make line at beginning with data myline
        else
            if length of line (x - 2) = 0 then
                make line at line (x - 2) with data "
"
                make line at line (x - 1) with data myline
            else
                make line at line (x - 2) with data myline
            end if
        end if
        select insertion point before line (x - 1)
    end tell
end tell
0

If you'd like to leave the default mission control, and can face using control option then I started with the system preferences as mentioned here TextWrangler: hotkeys to move line up/down, but found it easier to change the Bbedit

  • ctrl+ & ctrl+

to

  • ctrl+option+ & ctrl+option+

In the menu settings, File->Settings Select Menu & Shortcuts select Edit unfold Lines Click on the existing shortcut for Move Line Up change it, and repeat for down

Showing Bbedit menu settings, with Menu & Shortcuts Edit unfolded Lines and Move Line Up selected

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .