【问题标题】:What useful macros have you created in Netbeans? [closed]您在 Netbeans 中创建了哪些有用的宏? [关闭]
【发布时间】:2010-10-08 17:51:04
【问题描述】:

我使用 Netbeans(夜间构建)进行 Ruby on Rails 开发,并且希望增强我的宏。我自己创建了一些:

复制标识符:

select-identifier copy-to-clipboard

在标识符上粘贴剪贴板:

select-identifier paste-from-clipboard

双引号元素

select-element-next "\""

单引号元素:

select-element-next "'"

但我正在寻找其他有用的,而 Google 什么也没给我。 记录宏功能通常不能很好地工作,所以我宁愿自己“编写”宏,但我什至找不到列出哪些命令(如“select-identifier”)实际可用的参考。

那里有任何 Netbeans 宏专家吗?

【问题讨论】:

  • 看起来还不是很多 :-) 我想知道这是否意味着(1)您不需要它们,因为 NetBeans 已经非常好;或者 (2) 在 NetBeans 中这样做太难了。没有通过判断,我从来没有使用过它(我是一个 Eclipse 人,彻头彻尾)。
  • 我在使用 Java 时也是一名 Eclipse 人;我爱它。但是用于 RoR 的 Eclipse 与 Netbeans IMO 不在同一级别。
  • 我已经使用netbeans 2 年了,我不敢相信我以前没有注意到宏。它肯定会帮助完成重复性任务。从我自己的经验来看,我认为大多数宏都是由其作者针对特定情况量身定制的。

标签: netbeans macros


【解决方案1】:

Here 是带有简短说明的宏代码列表。可能对某人有用。

更新:将旧链接替换为指向 Netbeans 站点的链接,并在此处包含宏列表。

abbrev-debug-line   Debug Filename and Line Number
adjust-caret-bottom Move Insertion Point to Bottom
adjust-caret-center Move Insertion Point to Center
adjust-caret-top    Move Insertion Point to Top
adjust-window-bottom    Scroll Insertion Point to Bottom
adjust-window-center    Scroll Insertion Point to Center
adjust-window-top   Scroll Insertion Point to Top
all-completion-show Show All Code Completion Popup
annotations-cycling Annotations Cycling
beep    Beep
build-popup-menu    Build Popup Menu
build-tool-tip  Build Tool Tip
caret-backward  Insertion Point Backward
caret-begin Insertion Point to Beginning of Document
caret-begin-line    Insertion Point to Beginning of Text on Line
caret-begin-word    Insertion Point to Beginning of Word
caret-down  Insertion Point Down
caret-end   Insertion Point to End of Document
caret-end-line  Insertion Point to End of Line
caret-end-word  Insertion Point to End of Word
caret-forward   Insertion Point Forward
caret-line-first-column Insertion Point to Beginning of Line
caret-next-word caret-next-word
caret-previous-word caret-previous-word
caret-up    Insertion Point Up
collapse-all-code-block-folds   Collapse All Java Code
collapse-all-folds  Collapse All
collapse-all-javadoc-folds  Collapse All Javadoc
collapse-fold   Collapse Fold
comment Comment
complete-line   Complete Line
complete-line-newline   Complete Line and Create New Line
completion-show Show Code Completion Popup
copy-selection-else-line-down   Copy Selection else Line down
copy-selection-else-line-up Copy Selection else Line up
copy-to-clipboard   Copy
cut-to-clipboard    Cut
cut-to-line-begin   Cut from Insertion Point to Line Begining
cut-to-line-end Cut from Insertion Point to Line End
default-typed   Default Typed
delete-next Delete Next Character
delete-previous Delete Previous Character
documentation-show  Show Documentation Popup
dump-view-hierarchy Dump View Hierarchy
expand-all-code-block-folds Expand All Java Code
expand-all-folds    Expand All
expand-all-javadoc-folds    Expand All Javadoc
expand-fold Expand Fold
fast-import Fast Import
find-next   Find Next Occurrence
find-previous   Find Previous Occurrence
find-selection  Find Selection
first-non-white Go to First Non-whitespace Char
fix-imports Fix Imports
format  Format
generate-code   Insert Code
generate-fold-popup Generate Fold Popup
generate-goto-popup Generate Goto Popup
generate-gutter-popup   Margin
goto    Go to Line...
goto-declaration    Go to Declaration
goto-help   Go to Javadoc
goto-implementation Go to Implementation
goto-source Go to Source
goto-super-implementation   Go to Super Implementation
in-place-refactoring    Instant Rename
incremental-search-backward Incremental Search Backward
incremental-search-forward  Incremental Search Forward
insert-break    Insert Newline
insert-date-time    Insert Current Date and Time
insert-tab  Insert Tab
introduce-constant  Introduce Constant...
introduce-field Introduce Field...
introduce-method    Introduce Method...
introduce-variable  Introduce Variable...
java-next-marked-occurrence Navigate to Next Occurrence
java-prev-marked-occurrence Navigate to Previous Occurrence
jump-list-last-edit Last edit
jump-list-next  Forward
jump-list-prev  Back
last-non-white  Go to Last Non-whitespace Char
make-getter Replace Variable With its Getter
make-is Replace Variable With its is* Method
make-setter Replace Variable With its Setter
match-brace Insertion Point to Matching Brace
move-selection-else-line-down   Move Selection else Line down
move-selection-else-line-up Move Selection else Line up
org.openide.actions.PopupAction Show Popup Menu
page-down   Page Down
page-up Page Up
paste-formated  Paste Formatted
paste-from-clipboard    Paste
redo    Redo
reindent-line   Re-indent Current Line or Selection
remove-line Delete Line
remove-line-begin   Delete Preceding Characters in Line
remove-selection    Delete Selection
remove-tab  Delete Tab
remove-trailing-spaces  Remove Trailing Spaces
remove-word-next    remove-word-next
remove-word-previous    remove-word-previous
replace Replace
run-macro   Run Macro
scroll-down Scroll Down
scroll-up   Scroll Up
select-all  Select All
select-element-next Select Next Element
select-element-previous Select Previous Element
select-identifier   Select Identifier
select-line Select Line
select-next-parameter   Select Next Parameter
select-word Select Word
selection-backward  Extend Selection Backward
selection-begin Extend Selection to Beginning of Document
selection-begin-line    Extend Selection to Beginning of Text on Line
selection-begin-word    Extend Selection to Beginning of Word
selection-down  Extend Selection Down
selection-end   Extend Selection to End of Document
selection-end-line  Extend Selection to End of Line
selection-end-word  Extend Selection to End of Word
selection-first-non-white   Extend Selection to First Non-whitespace Char
selection-forward   Extend Selection Forward
selection-last-non-white    Extend Selection to Last Non-whitespace Char
selection-line-first-column Extend Selection to Beginning of Line
selection-match-brace   Extend Selection to Matching Brace
selection-next-word selection-next-word
selection-page-down Extend Selection to Next Page
selection-page-up   Extend Selection to Previous Page
selection-previous-word selection-previous-word
selection-up    Extend Selection Up
shift-line-left Shift Line Left
shift-line-right    Shift Line Right
split-line  Split Line
start-macro-recording   Start Macro Recording
start-new-line  Start New Line
stop-macro-recording    Stop Macro Recording
switch-case Switch Case
to-lower-case   To Lowercase
to-upper-case   To Uppercase
toggle-case-identifier-begin    Switch Capitalization of Identifier
toggle-comment  Toggle Comment
toggle-highlight-search Toggle Highlight Search
toggle-line-numbers Toggle Line Numbers
toggle-non-printable-characters Toggle Non-printable Characters
toggle-toolbar  Toggle Toolbar
toggle-typing-mode  Toggle Typing Mode
tooltip-show    Show Code Completion Tip Popup
uncomment   Uncomment
undo    Undo
word-match-next Next Matching Word
word-match-prev Previous Matching Word

【讨论】:

  • 太完美了!但我后来改用 Rubymine :)
【解决方案2】:

我需要用 HTML 标签包围文本片段,但不知道如何快速完成,所以我想出了这个宏:

cut-to-clipboard "<strong>" paste-from-clipboard "</strong>"

简单,干净,您可以放置​​任何您想要的标签/文本。给它一个快捷键,比如 Alt+B,你就可以快速插入 HTML

【讨论】:

    【解决方案3】:

    为 php 添加分号到结束行(“完整行”)
    但将光标保持在当前点, 这样您就可以继续输入该行的其余部分

    split-line
    caret-down
    caret-end-line ";" 
    caret-begin-line 
    selection-begin-line remove-selection 
    delete-previous
    

    【讨论】:

    • 我这样做:";"删除前一个插入符号结束行“;”跳转列表最后编辑 跳转列表最后编辑
    【解决方案4】:

    这是我的第一个 netbeans 宏。

    "echo '

    ';print_r();die();"
    
    

    我的快捷键 => Alt+A

    为此,您可以使用任何快捷方式

    【讨论】:

      【解决方案5】:

      哦,好吧,只是在用 netbeans 做实验。

      我为 netbeans 添加了一个简单的新宏。 名称:“scrollup_newline” 代码: 插入-中断 向上滚动

      它工作得很好,所以每次我按下回车键,编辑器都会下移一行。这样我就可以编写代码并将插入符号放在编辑器的中间。

      【讨论】:

        【解决方案6】:

        这是针对 HTML 的。我刚做的:

        caret-begin-line "&lt;li&gt;" caret-end-line "&lt;/li&gt;" caret-down

        映射到 ctrl+shift+L 这是我的第一个 netbeans 宏。稍后也许我可以以某种方式使其适用于整个选择。

        编辑:不知道为选择做这件事,但在最后添加“caret-down”几乎一样好。

        【讨论】:

        • cut-to-clipboard 之前添加 paste-from-clipboard 代替您的 caret-end-line
        【解决方案7】:

        这是我今天写的宏。我非常缺少 PHP 中的“提取方法”或“引入方法”重构,所以我编写了这个宏。我知道这远没有 Java 中的重构那么复杂,但它可以使用,并且可以节省一些复制/粘贴和编写重复代码。

        cut-to-clipboard
        "$this->UNNAMED_METHOD();"
        collapse-fold
        caret-end-line caret-backward caret-end-line insert-break
        "private function UNNAMED_METHOD() {"insert-break
        paste-from-clipboard insert-break
        

        【讨论】:

        • 你应该试试 Jetbrains PHPStorm。它有很多重构,包括 Extract Method 和 Introduce Variable。
        • Jetbrains PHPStorm 是商业的。我更喜欢开源项目。我会,但是看看它,我前段时间尝试过,但没有留下深刻的印象。
        【解决方案8】:

        此宏插入 -moz--webkit- 前缀等效的 css3 样式规则:

        caret-end-line selection-begin-line copy-to-clipboard caret-backward insert-break caret-up "-webkit-" paste-from-clipboard insert-break "-moz-" paste-from-clipboard
        

        【讨论】:

          【解决方案9】:
          insert-date-time remove-word-previous remove-word-previous
          

          映射到 CTRL+SHIFT+D 以插入短日期,非常有用,因为我喜欢给我的 cmets / TODO 加上日期,但通常不知道日期!

          虽然我觉得 Code Templates 多有用,例如:

                     // <editor-fold defaultstate="collapsed" desc="${cursor}">
          

                     // </editor-fold>
          

          分别映射到 'fold' 然后 tab 和 'endfold' 然后 tab。

          还有

          JOptionPane.showMessageDialog(null, "${EXP default="Got here"}");
          

          映射到 'jop' 然后 tab 很方便。

          【讨论】:

            【解决方案10】:

            可能不是最有效的,但它可以帮助我大声笑

            "(() ? : );"
            caret-backward
            caret-backward
            caret-backward
            caret-backward
            caret-backward
            caret-backward
            caret-backward
            caret-backward
            

            可以看出,这是针对 PHP 快速条件的。然后,这会将光标放在您开始输入条件的位置。无论你把它扔到哪里都很完美。我把它放在 Ctrl+NUMPAD0 以便快速输入访问。我原本有两个标签,但很快就烦人了哈哈

            【讨论】:

              【解决方案11】:

              我经常喜欢在 JavaScript 中使用逗号作为分隔属性或列表项的第一个字符;像这样:

              var foo = {
                  a : 'a'
                  //, b : 'B' //todo: make lcase
                  , c : 'c'
              };
              

              有时,我要么忘记这样做,要么有大量文本要更新。为了快速解决这些问题,我绑定了键盘快捷键C-, C-,——在按住 CTRL 键的同时按两次“,”——到:

              caret-end-line selection-next-word selection-next-word " " caret-backward caret-backward insert-break
              

              【讨论】:

                【解决方案12】:

                我发现代码模板非常有用,尤其是这个(用于 HTML):

                <${tag}>${cursor}</${tag}>
                

                缩写为“tt”,在代码模板菜单调用时,也可以用自定义标签包围任意文本。

                <${param_name default="tag"}${cursor}>
                ${selection}
                </${param_name default="tag"}>
                

                这个将用任何标签包围任何东西。选择一些东西,然后 Alt+F3,然后从菜单中选择这个模板。之后输入你想要的标签,例如“div”。

                【讨论】:

                • 虽然它是一个很好的代码模板示例,但 OP 要求提供宏。
                【解决方案13】:

                这是一个使用 SLF4J 在类中创建静态记录器的代码模板。我将它绑定到“日志”。

                private static final ${loggerType type="org.slf4j.Logger" default="Logger" editable="false"} log = ${loggerFactoryType type="org.slf4j.LoggerFactory" default="LoggerFactory" editable="false"}.getLogger(${classType editable="false" currClassName default="getClass()"}.class);
                

                这会生成一个 log.debug 行,我将其绑定到“log”:

                log.debug("${message}", "${variables}");
                

                【讨论】:

                • 虽然它是一个很好的代码模板示例,但 OP 要求提供宏。
                猜你喜欢
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 2010-10-04
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多