TextWrangler:热键可上下移动行


Answers:


4

对于Mac OS X,它是ctrl+ ctrl+

您可能需要更改“任务控制”热键设置(在“系统偏好设置”中),因为此处已预设了两个键盘按键。


1
已验证,这是正确的答案
Alex

1
在BBEdit中工作相同。文字牧马人是“已停用”的精简版(和的TextWrangler的BBEdit的制造商)。
iaforek

2

手册中没有提及任何内容(仅交换字符交换词)。


如果TextWrangler支持Cocoa Text System(我怀疑它不支持,但仍然可以),则可以创建文件~/Library/Keybindings/DefaultKeyBinding.dict并输入以下内容:

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

这将为Opt-DownArrow支持Cocoa文本系统的每个应用程序添加换行命令的快捷方式(下面的行)。


如果TextWrangler不支持此功能:获取一个真实的文本编辑器。甚至TextMate也支持这一点。
丹尼尔·贝克

2

我不认为TextWrangler具有内置功能。

不过,您可以在TextWrangler中运行applescript,因此可以完成这项工作。我什至找到了一些可以完成此操作的applescripts

您将需要用applescripts中的TextWrangler替换BBEdit。将脚本放在“〜/ Library / Application Support / TextWrangler / Scripts /”中,它们将显示在TextWrangler的脚本菜单中。单击窗口->调色板->脚本以查看脚本调色板,您可以在其中设置自定义键盘快捷键。


如果要将它们分配给Option-Up(⌥↑)和Down,则可以使用Keyboard System Preference。TextWrangler不允许我使用“ Option”(⌥)作为修饰符。现在,它的外观非常时尚。
克拉斯2012年

0

nathangs解决方案效果很好。但是提供的链接不再起作用。所以这是纯文本格式的脚本。只需将它们粘贴到“ AppleScript编辑器”中,然后将其保存到〜/ Library / Application Support / TextWrangler / Scripts /

在Mountain Lion和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
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.