Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Has anyone discovered these hotkey features in TextWrangler?

share|improve this question

migrated from stackoverflow.com May 15 '11 at 20:55

This question came from our site for professional and enthusiast programmers.

    
this might be of use, but it looks like the answer is tentatively "no" groups.google.com/group/textwrangler/browse_thread/thread/… –  zourtney Mar 11 '11 at 5:22

3 Answers 3

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.

share|improve this answer
    
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 '12 at 12:39

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.

share|improve this answer
    
If TextWrangler does not support this: get a real text editor. Even TextMate supports this. –  Daniel Beck May 15 '11 at 21:28

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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