Geertjan is a DZone Zone Leader and has posted 468 posts at DZone. You can read more from them at their website. View Full User Profile

Complete List of Macro Keywords for the NetBeans Java Editor

  • submit to reddit

In NetBeans IDE's Java editor, you can create macros by clicking the "Start Macro Recording" button, performing some actions you'd like to record, then clicking the "Stop Macro Recording" button. The Macro Editor then pops up and you can finetune the macro and also assign a keyboard shortcut to it. (You can also edit macros in the Options window, in the Editor | Macros tab.)

A special macro syntax is used to define these macros. For example, if you want to clear the current line in the editor from the cursor, your macro definition would be as follows:

selection-end-line remove-selection

Then you could assign "Ctrl+L" as the keyboard shortcut for this macro. Whenever you'd then press that key combination, the whole line, from the position of the cursor, would be deleted.

But the only way for the syntax to be useful is for it to be made publicly available. I've seen in various places on-line that people are complaining about a lack of documentation in this area. I asked the developers from the NetBeans Java editor team and their advice was: "it should not be that hard to create an action, which will get EditorKit from the JEditorPane in an opened editor, call EK.getActions() and dump Action.NAME property of each action to System.out".

That's what I did (together with Action.SHORT_DESCRIPTION) and here is the result:

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

Now that this list is public, I am looking forward to many new and interesting (and useful) macros being published (maybe even here on NetBeans Zone).


Published at DZone with permission of its author, Geertjan Wielenga.


Tom Wheeler replied on Wed, 2010/03/31 - 12:11pm

It's great to have a list of these.  I save so much time using Code Templates already and am starting to use macros more now.

I've set up a macro called 'transpose' (selection-backward cut-to-clipboard caret-forward paste-from-clipboard) and bound it to Ctrl+T.  This lets me swap letters on either side of the cursors, just as I can do in emacs or the bash shell. 

Adam Metzler replied on Wed, 2010/03/31 - 11:56pm

This something that I have always wondered about in netbeans and it is nice to finally see the full list. I would have never thought that there were so many!

My only question now is, 'Will this be making it into the 6.9 docs or the wiki?' This could easily fit split into two pages in the docs, maybe in a table form like the ant docs have.

Geertjan Wielenga replied on Thu, 2010/04/01 - 4:04am

Tomás Lázaro replied on Thu, 2010/04/01 - 10:12am

Once during a Sun evangelization conference regarding Java and Netbeans a few years ago, Tim Boudreau showed off the cool "insert semicolon at end of line" feature among many others.

I use Netbeans since that day but that feature wasn't there XD. So:


 caret-end-line ";"

 And I trigger it with ALT+";" keys.

A really friendly companion to that is "insert close parent at eol - 1" (before a semicolon usually):

 caret-end-line caret-backward ")"

 Trigger with ALT+")" --> ALT+9 in my keyboard ALT+0 in a US keyboard probably. It might look farfetched but give it a try and you will find yourself using it a lot to add that missing close parenthesis on the far end of the line. (not verified) replied on Wed, 2010/04/07 - 3:13am

Tomás, insert semicolon at the end of the line is available out-of-the box, using CTRL-;

As far as I remember that shortcut is available since NetBeans 6.0

Stork Club replied on Fri, 2012/10/19 - 1:59am

what a list of is very helpful indeed when i do my codes

 club stork

Matt Coleman replied on Fri, 2012/11/16 - 12:37am

Hey Geertjan,

Thanks for sharing the list of NB Java Editor macro syntax...much appreciate it for my sell sheet designer 

Cata Nic replied on Tue, 2013/09/03 - 3:37am

A complete post which offer to developers the dictionary able to generate more stable applications

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.