1 *netbeans.txt* For Vim version 7.1. Last change: 2006 Nov 14
4 VIM REFERENCE MANUAL by Gordon Prieur
7 NetBeans ExternalEditor Integration Features *netbeans*
9 1. Introduction |netbeans-intro|
10 2. NetBeans Key Bindings |netbeans-keybindings|
11 3. Configuring Vim for NetBeans |netbeans-configure|
12 4. Downloading NetBeans |netbeans-download|
13 5. Preparing NetBeans for Vim |netbeans-preparation|
14 6. Obtaining the External Editor Module |obtaining-exted|
15 7. Setting up NetBeans to run with Vim |netbeans-setup|
16 8. Messages |netbeans-messages|
17 9. Running Vim from NetBeans |netbeans-run|
18 10. NetBeans protocol |netbeans-protocol|
19 11. NetBeans commands |netbeans-commands|
20 12. Known problems |netbeans-problems|
22 {Vi does not have any of these features}
23 {only available when compiled with the |+netbeans_intg| feature}
25 ==============================================================================
26 1. Introduction *netbeans-intro*
28 NetBeans is an open source Integrated Development Environment developed
29 jointly by Sun Microsystems, Inc. and the netbeans.org developer community.
30 Initially just a Java IDE, NetBeans has had C, C++, and Fortran support added
33 For more information visit the main NetBeans web site http://www.netbeans.org
34 or the NetBeans External Editor site at http://externaleditor.netbeans.org.
36 Sun Microsystems, Inc. also ships NetBeans under the name Sun ONE Studio.
37 Visit http://www.sun.com for more information regarding the Sun ONE Studio
40 Current releases of NetBeans provide full support for Java and limited support
41 for C, C++, and Fortran. Current releases of Sun ONE Studio provide full
42 support for Java, C, C++, and Fortran.
44 The interface to NetBeans is also supported by Agide, the A-A-P GUI IDE.
45 Agide is very different from NetBeans:
46 - Based on Python instead of Java, much smaller footprint and fast startup.
47 - Agide is a framework in which many different tools can work together.
48 See the A-A-P website for information: http://www.A-A-P.org.
50 ==============================================================================
51 2. NetBeans Key Bindings *netbeans-keybindings*
53 Vim understands a number of key bindings that execute NetBeans commands.
54 These are typically all the Function key combinations. To execute a NetBeans
55 command, the user must press the Pause key followed by a NetBeans key binding.
56 For example, in order to compile a Java file, the NetBeans key binding is
57 "F9". So, while in vim, press "Pause F9" to compile a java file. To toggle a
58 breakpoint at the current line, press "Pause Shift F8".
60 The Pause key is Function key 21. If you don't have a working Pause key and
61 want to use F8 instead, use: >
65 The External Editor module dynamically reads the NetBeans key bindings so vim
66 should always have the latest key bindings, even when NetBeans changes them.
68 ==============================================================================
69 3. Configuring Vim for NetBeans *netbeans-configure*
71 For more help installing vim, please read |usr_90.txt| in the Vim User Manual.
76 When running configure without arguments the NetBeans interface should be
77 included. That is, if the configure check to find out if your system supports
78 the required features succeeds.
80 In case you do not want the NetBeans interface you can disable it by
81 uncommenting a line with "--disable-netbeans" in the Makefile.
83 Currently, only gvim is supported in this integration as NetBeans does not
84 have means to supply a terminal emulator for the vim command. Furthermore,
85 there is only GUI support for GTK, GNOME, and Motif.
87 If Motif support is required the user must supply XPM libraries. See
88 |workshop-xpm| for details on obtaining the latest version of XPM.
93 The Win32 support is now in beta stage.
95 To use XPM signs on Win32 (e.g. when using with NetBeans) you can compile
96 XPM by yourself or use precompiled libraries from http://iamphet.nm.ru/misc/
97 (for MS Visual C++) or http://gnuwin32.sourceforge.net (for MinGW).
99 ==============================================================================
100 4. Downloading NetBeans *netbeans-download*
102 The NetBeans IDE is available for download from netbeans.org. You can download
103 a released version, download sources, or use CVS to download the current
104 source tree. If you choose to download sources, follow directions from
105 netbeans.org on building NetBeans.
107 Depending on the version of NetBeans you download, you may need to do further
108 work to get the required External Editor module. This is the module which lets
109 NetBeans work with gvim (or xemacs :-). See http://externaleditor.netbeans.org
110 for details on downloading this module if your NetBeans release does not have
113 For C, C++, and Fortran support you will also need the cpp module. See
114 http://cpp.netbeans.org for information regarding this module.
116 You can also download Sun ONE Studio from Sun Microsystems, Inc for a 30 day
117 free trial. See http://www.sun.com for further details.
119 ==============================================================================
120 5. Preparing NetBeans for Vim *netbeans-preparation*
122 In order for NetBeans to work with vim, the NetBeans External Editor module
123 must be loaded and enabled. If you have a Sun ONE Studio Enterprise Edition
124 then this module should be loaded and enabled. If you have a NetBeans release
125 you may need to find another way of obtaining this open source module.
127 You can check if you have this module by opening the Tools->Options dialog
128 and drilling down to the "Modules" list (IDE Configuration->System->Modules).
129 If your Modules list has an entry for "External Editor" you must make sure
130 it is enabled (the "Enabled" property should have the value "True"). If your
131 Modules list has no External Editor see the next section on |obtaining-exted|.
133 ==============================================================================
134 6. Obtaining the External Editor Module *obtaining-exted*
136 There are 2 ways of obtaining the External Editor module. The easiest way
137 is to use the NetBeans Update Center to download and install the module.
138 Unfortunately, some versions do not have this module in their update
139 center. If you cannot download via the update center you will need to
140 download sources and build the module. I will try and get the module
141 available from the NetBeans Update Center so building will be unnecessary.
142 Also check http://externaleditor.netbeans.org for other availability options.
144 To download the External Editor sources via CVS and build your own module,
145 see http://externaleditor.netbeans.org and http://www.netbeans.org.
146 Unfortunately, this is not a trivial procedure.
148 ==============================================================================
149 7. Setting up NetBeans to run with Vim *netbeans-setup*
151 Assuming you have loaded and enabled the NetBeans External Editor module
152 as described in |netbeans-preparation| all you need to do is verify that
153 the gvim command line is properly configured for your environment.
155 Open the Tools->Options dialog and open the Editing category. Select the
156 External Editor. The right hand pane should contain a Properties tab and
157 an Expert tab. In the Properties tab make sure the "Editor Type" is set
158 to "Vim". In the Expert tab make sure the "Vim Command" is correct.
160 You should be careful if you change the "Vim Command". There are command
161 line options there which must be there for the connection to be properly
162 set up. You can change the command name but that's about it. If your gvim
163 can be found by your $PATH then the VIM Command can start with "gvim". If
164 you don't want gvim searched from your $PATH then hard code in the full
165 Unix path name. At this point you should get a gvim for any source file
166 you open in NetBeans.
168 If some files come up in gvim and others (with different file suffixes) come
169 up in the default NetBeans editor you should verify the MIME type in the
170 Expert tab MIME Type property. NetBeans is MIME oriented and the External
171 Editor will only open MIME types specified in this property.
173 ==============================================================================
174 8. Messages *netbeans-messages*
176 These messages are specific for NetBeans:
179 Region is guarded, cannot modify
180 NetBeans defines guarded areas in the text, which you cannot
182 Also sets the current buffer, if necessary.
185 NetBeans disallows writes of unmodified buffers
186 NetBeans does not support writes of unmodified buffers that
187 were opened from NetBeans.
190 Partial writes disallowed for NetBeans buffers
191 NetBeans does not support partial writes for buffers that were
192 opened from NetBeans.
195 NetBeans connection lost for this buffer
196 NetBeans has become confused about the state of this file.
197 Rather than risk data corruption, NetBeans has severed the
198 connection for this file. Vim will take over responsibility
199 for saving changes to this file and NetBeans will no longer
200 know of these changes.
203 NetBeans does not allow changes in read-only files
204 Vim normally allows changes to a read-only file and only
205 enforces the read-only rule if you try to write the file.
206 However, NetBeans does not let you make changes to a file
207 which is read-only and becomes confused if vim does this.
208 So vim does not allow modifications to files when run with
210 ==============================================================================
211 9. Running Vim from NetBeans *netbeans-run*
213 NetBeans starts Vim with the |-nb| argument. Three forms can be used, that
214 differ in the way the information for the connection is specified:
216 -nb={fname} from a file
217 -nb:{hostname}:{addr}:{password} directly
218 -nb from a file or environment
221 For security reasons, the best method is to write the information in a file
222 readable only by the user. The name of the file can be passed with the
223 "-nb={fname}" argument or, when "-nb" is used without a parameter, the
224 environment variable "__NETBEANS_CONINFO". The file must contain these three
231 Other lines are ignored. The caller of Vim is responsible for deleting the
234 {hostname} is the name of the machine where NetBeans is running. When omitted
235 the environment variable "__NETBEANS_HOST" is used or the default "localhost".
237 {addr} is the port number for NetBeans. When omitted the environment variable
238 "__NETBEANS_SOCKET" is used or the default 3219.
240 {password} is the password for connecting to NetBeans. When omitted the
241 environment variable "__NETBEANS_VIM_PASSWORD" is used or "changeme".
243 ==============================================================================
244 10. NetBeans protocol *netbeans-protocol*
246 The communication between NetBeans and Vim uses plain text messages. This
247 protocol was first designed to work with the external editor module of
248 NetBeans (see http://externaleditor.netbeans.org). Later it was extended to
249 work with Agide (A-A-P GUI IDE, see http://www.a-a-p.org). The extensions are
250 marked with "version 2.1".
252 Version 2.2 of the protocol has several minor changes which should only affect
253 NetBeans users (ie, not Agide users). However, a bug was fixed which could
254 cause confusion. The netbeans_saved() function sent a "save" protocol
255 command. In protocol version 2.1 and earlier this was incorrectly interpreted
256 as a notification that a write had taken place. In reality, it told NetBeans
257 to save the file so multiple writes were being done. This caused various
258 problems and has been fixed in 2.2. To decrease the likelihood of this
259 confusion happening again, netbeans_saved() has been renamed to
260 netbeans_save_buffer().
262 We are now at version 2.4. For the differences between 2.3 and 2.4 search for
265 The messages are currently sent over a socket. Since the messages are in
266 plain UTF-8 text this protocol could also be used with any other communication
269 To see an example implementation look at the gvim tool in Agide. Currently
271 http://cvs.sf.net/viewcvs.py/a-a-p/Agide/Tools/GvimTool.py?view=markup
275 10.1 Kinds of messages |nb-messages|
276 10.2 Terms |nb-terms|
277 10.3 Commands |nb-commands|
278 10.4 Functions and Replies |nb-functions|
279 10.5 Events |nb-events|
280 10.6 Special messages |nb-special|
282 *E627* *E628* *E629* *E630* *E631* *E632* *E633* *E634* *E635* *E636*
283 *E637* *E638* *E639* *E640* *E641* *E642* *E643* *E644* *E645* *E646*
284 *E647* *E648* *E649* *E650* *E651* *E652* *E653* *E654*
285 These errors occur when a message violates the protocol.
288 10.1 Kinds of messages *nb-messages*
290 There are four kinds of messages:
292 kind direction comment ~
293 Command IDE -> editor no reply necessary
294 Function IDE -> editor editor must send back a reply
295 Reply editor -> IDE only in response to a Function
296 Event editor -> IDE no reply necessary
298 The messages are sent as a single line with a terminating newline character.
299 Arguments are separated by a single space. The first item of the message
300 depends on the kind of message:
302 kind first item example ~
303 Command bufID:name!seqno 11:showBalloon!123 "text"
304 Function bufID:name/seqno 11:getLength/123
306 Event bufID:name=123 11:keyCommand=123 "S-F2"
309 10.2 Terms *nb-terms*
311 bufID Buffer number. A message may be either for a specific buffer
312 or generic. Generic messages use a bufID of zero. NOTE: this
313 buffer ID is assigned by the IDE, it is not Vim's buffer
314 number. The bufID must be a sequentially rising number,
317 seqno The IDE uses a sequence number for Commands and Functions. A
318 Reply must use the sequence number of the Function that it is
319 associated with. A zero sequence number can be used for
320 Events (the seqno of the last received Command or Function can
323 string Argument in double quotes. Text is in UTF-8 encoding. This
324 means ASCII is passed as-is. Special characters are
325 represented with a backslash:
329 \t tab (optional, also works literally)
331 NUL bytes are not allowed!
333 boolean Argument with two possible values:
337 number Argument with a decimal number.
339 optnum Argument with either a decimal number or "none" (without the
342 offset A number argument that indicates a byte position in a buffer.
343 The first byte has offset zero. Line breaks are counted for
344 how they appear in the file (CR/LF counts for two bytes).
345 Note that a multi-byte character is counted for the number of
348 lnum/col Argument with a line number and column number position. The
349 line number starts with one, the column is the byte position,
350 starting with zero. Note that a multi-byte character counts
353 pathname String argument: file name with full path.
356 10.3 Commands *nb-commands*
358 actionMenuItem Not implemented.
363 addAnno serNum typeNum off len
364 Place an annotation in this buffer.
366 serNum number serial number of this placed
367 annotation, used to be able to remove
369 typeNum number sequence number of the annotation
370 defined with defineAnnoType for this
372 off number offset where annotation is to be placed
374 In version 2.1 "lnum/col" can be used instead of "off".
379 close Close the buffer. This leaves us without current buffer, very
382 create Creates a buffer without a name. Replaces the current buffer
383 (it's hidden when it was changed).
384 NetBeans uses this as the first command for a file that is
385 being opened. The sequence of commands could be:
387 setCaretListener (ignored)
388 setModified (no effect)
389 setContentType (ignored)
394 defineAnnoType typeNum typeName tooltip glyphFile fg bg
395 Define a type of annotation for this buffer.
397 typeNum number sequence number (not really used)
398 typeName string name that identifies this annotation
399 tooltip string not used
400 glyphFile string name of icon file
401 fg optnum foreground color for line highlighting
402 bg optnum background color for line highlighting
403 Vim will define a sign for the annotation.
404 When both "fg" and "bg" are "none" no line highlighting is
405 used (new in version 2.1).
406 When "glyphFile" is empty, no text sign is used (new in
408 When "glyphFile" is one or two characters long, a text sign is
409 defined (new in version 2.1).
410 Note: the annotations will be defined in sequence, and the
411 sequence number is later used with addAnno.
414 Set the name for the buffer and edit the file "pathname", a
416 Normal way for the IDE to tell the editor to edit a file. If
417 the IDE is going to pass the file text to the editor use these
427 endAtomic End an atomic operation. The changes between "startAtomic"
428 and "endAtomic" can be undone as one operation. But it's not
429 implemented yet. Redraw when necessary.
432 Mark an area in the buffer as guarded. This means it cannot
433 be edited. "off" and "len" are numbers and specify the text
436 initDone Mark the buffer as ready for use. Implicitly makes the buffer
437 the current buffer. Fires the BufReadPost autocommand event.
440 Sent by NetBeans to tell vim an initial file insert is done.
441 This triggers a read message being printed. Prior to version
442 2.3, no read messages were displayed after opening a file.
445 moveAnnoToFront serNum
448 netbeansBuffer isNetbeansBuffer
449 If "isNetbeansBuffer" is "T" then this buffer is ``owned'' by
453 putBufferNumber pathname
454 Associate a buffer number with the Vim buffer by the name
455 "pathname", a string argument. To be used when the editor
456 reported editing another file to the IDE and the IDE needs to
457 tell the editor what buffer number it will use for this file.
458 Also marks the buffer as initialized.
461 raise Bring the editor to the foreground.
465 Remove a previously place annotation for this buffer.
466 "serNum" is the same number used in addAnno.
468 save Save the buffer when it was modified. The other side of the
469 interface is expected to write the buffer and invoke
470 "setModified" to reset the "changed" flag of the buffer.
471 The writing is skipped when one of these conditions is true:
473 - the buffer is read-only
474 - the buffer does not have a file name
475 - 'buftype' disallows writing
479 Sent by NetBeans to tell vim a save is done. This triggers
480 a save message being printed. Prior to version 2.3, no save
481 messages were displayed after a save.
484 setAsUser Not implemented.
486 setBufferNumber pathname
487 Associate a buffer number with Vim buffer by the name
488 "pathname". To be used when the editor reported editing
489 another file to the IDE and the IDE needs to tell the editor
490 what buffer number it will use for this file.
491 Has the side effect of making the buffer the current buffer.
492 See "putBufferNumber" for a more useful command.
497 setDot off Make the buffer the current buffer and set the cursor at the
498 specified position. If the buffer is open in another window
499 than make that window the current window.
500 If there are folds they are opened to make the cursor line
502 In version 2.1 "lnum/col" can be used instead of "off".
505 Set the delay for exiting to "seconds", a number.
506 This delay is used to give the IDE a chance to handle things
507 before really exiting. The default delay is two seconds.
509 Obsolete in version 2.3.
512 Set the file name to be used for a buffer to "pathname", a
514 Used when the IDE wants to edit a file under control of the
515 IDE. This makes the buffer the current buffer, but does not
516 read the file. "insert" commands will be used next to set the
519 setLocAndSize Not implemented.
521 setMark Not implemented.
524 When the boolean argument "modified" is "T" mark the buffer as
525 modified, when it is "F" mark it as unmodified.
528 Update a buffers modification time after NetBeans saves the
533 Passed by NetBeans to tell vim a file is readonly.
534 Implemented in verion 2.3.
536 setStyle Not implemented.
539 Set the title for the buffer to "name", a string argument.
540 The title is only used for NetBeans functions, not by Vim.
543 When the boolean argument "visible" is "T", goto the buffer.
544 The "F" argument does nothing.
547 Show a balloon (popup window) at the mouse pointer position,
548 containing "text", a string argument. The balloon should
549 disappear when the mouse is moved more than a few pixels.
553 Map a set of keys (mostly function keys) to be passed back
554 to NetBeans for processing. This lets NetBeans hotkeys be
556 Implemented in version 2.3.
558 startAtomic Begin an atomic operation. The screen will not be updated
559 until "endAtomic" is given.
565 Mark the buffer to report changes to the IDE with the
566 "insert" and "remove" events. The default is to report
573 Mark the buffer to stop reporting changes to the IDE.
574 Opposite of startDocumentListen.
575 NOTE: if "netbeansBuffer" was used to mark this buffer as a
576 NetBeans buffer, then the buffer is deleted in Vim. This is
577 for compatibility with Sun Studio 10.
580 Opposite of "guard", remove guarding for a text area.
581 Also sets the current buffer, if necessary.
583 version Not implemented.
586 10.4 Functions and Replies *nb-functions*
588 getDot Not implemented.
590 getCursor Return the current buffer and cursor position.
592 seqno bufID lnum col off
593 seqno = sequence number of the function
594 bufID = buffer ID of the current buffer (if this is unknown -1
596 lnum = line number of the cursor (first line is one)
597 col = column number of the cursor (in bytes, zero based)
598 off = offset of the cursor in the buffer (in bytes)
601 getLength Return the length of the buffer in bytes.
602 Reply example for a buffer with 5000 bytes:
604 TODO: explain use of partial line.
606 getMark Not implemented.
609 Return the line number of the annotation in the buffer.
611 serNum serial number of this placed annotation
613 123 lnum line number of the annotation
614 123 0 invalid annotation serial number
617 getModified When a buffer is specified: Return zero if the buffer does not
618 have changes, one if it does have changes.
619 When no buffer is specified (buffer number zero): Return the
620 number of buffers with changes. When the result is zero it's
621 safe to tell Vim to exit.
624 getText Return the contents of the buffer as a string.
625 Reply example for a buffer with two lines
626 123 "first line\nsecond line\n"
627 NOTE: docs indicate an offset and length argument, but this is
631 Insert "text" before position "off". "text" is a string
632 argument, "off" a number.
633 "off" should have a "\n" (newline) at the end of each line.
634 Or "\r\n" when 'fileformat' is "dos". When using "insert" in
635 an empty buffer Vim will set 'fileformat' accordingly.
636 When "off" points to the start of a line the text is inserted
637 above this line. Thus when "off" is zero lines are inserted
638 before the first line.
639 When "off" points after the start of a line, possibly on the
640 NUL at the end of a line, the first line of text is appended
641 to this line. Further lines come below it.
645 Note that the message in the reply is not quoted.
646 Also sets the current buffer, if necessary.
647 Does not move the cursor to the changed text.
648 Resets undo information.
651 Delete "length" bytes of text at position "off". Both
652 arguments are numbers.
656 Note that the message in the reply is not quoted.
657 Also sets the current buffer, if necessary.
659 saveAndExit Perform the equivalent of closing Vim: ":confirm qall".
660 If there are no changed files or the user does not cancel the
661 operation Vim exits and no result is sent back. The IDE can
662 consider closing the connection as a successful result.
663 If the user cancels the operation the number of modified
664 buffers that remains is returned and Vim does not exit.
668 10.5 Events *nb-events*
670 balloonEval off len type
671 The mouse pointer rests on text for a short while. When "len"
672 is zero, there is no selection and the pointer is at position
673 "off". When "len" is non-zero the text from position "off" to
674 "off" + "len" is selected.
675 Only sent after "enableBalloonEval" was used for this buffer.
676 "type" is not yet defined.
680 Used when 'ballooneval' is set and the mouse pointer rests on
681 some text for a moment. "text" is a string, the text under
685 buttonRelease button lnum col
686 Report which button was pressed and the location of the cursor
687 at the time of the release. Only for buffers that are owned
688 by NetBeans. This event is not sent if the button was
689 released while the mouse was in the status line or in a
690 separator line. If col is less than 1 the button release was
695 Tell NetBeans that vim is exiting and not to try and read or
699 fileClosed Not implemented.
701 fileModified Not implemented.
703 fileOpened pathname open modified
704 A file was opened by the user.
706 pathname string name of the file
707 open boolean always "T"
708 modified boolean always "F"
710 geometry cols rows x y
711 Report the size and position of the editor window.
713 cols number number of text columns
714 rows number number of text rows
715 x number pixel position on screen
716 y number pixel position on screen
717 Only works for Motif.
720 Text "text" has been inserted in Vim at position "off".
721 Only fired when enabled, see "startDocumentListen".
723 invokeAction Not implemented.
726 Reports a special key being pressed with name "keyName", which
734 ' ' space (without the quotes)
736 ... any other ASCII printable character
739 X any unrecognized key
741 The key may be prepended by "C", "S" and/or "M" for Control,
742 Shift and Meta (Alt) modifiers. If there is a modifier a dash
743 is used to separate it from the key name. For example:
745 ASCII characters are new in version 2.1.
747 keyAtPos keyName lnum/col
748 Like "keyCommand" and also report the line number and column
752 killed A file was closed by the user. Only for files that have been
753 assigned a number by the IDE.
755 newDotAndMark off off
756 Reports the position of the cursor being at "off" bytes into
757 the buffer. Only sent just before a "keyCommand" event.
759 quit Not implemented.
762 Text was deleted in Vim at position "off" with byte length
764 Only fired when enabled, see "startDocumentListen".
766 revert Not implemented.
768 save The buffer has been saved and is now unmodified.
769 Only fired when enabled, see "startDocumentListen".
771 startupDone The editor has finished its startup work and is ready for
775 unmodified The buffer is now unmodified.
776 Only fired when enabled, see "startDocumentListen".
778 version vers Report the version of the interface implementation. Vim
779 reports "2.2" (including the quotes).
782 10.6 Special messages *nb-special*
784 These messages do not follow the style of the messages above. They are
785 terminated by a newline character.
789 AUTH password editor -> IDE: First message that the editor sends to the IDE.
790 Must contain the password for the socket server, as specified
791 with the |-nb| argument. No quotes are used!
793 DISCONNECT IDE -> editor: break the connection. The editor will exit.
794 The IDE must only send this message when there are no unsaved
797 DETACH IDE -> editor: break the connection without exiting the
798 editor. Used when the IDE exits without bringing down the
804 ==============================================================================
805 11. NetBeans Commands *netbeans-commands*
808 :nbkey key Pass the key to NetBeans for processing
810 Pass the key to NetBeans for hot-key processing. You should not need to use
811 this command directly. However, NetBeans passes a list of hot-keys to Vim at
812 startup and when one of these keys is pressed, this command is generated to
813 send the key press back to NetBeans.
815 ==============================================================================
816 12. Known problems *netbeans-problems*
818 NUL bytes are not possible. For editor -> IDE they will appear as NL
819 characters. For IDE -> editor they cannot be inserted.
822 vim:tw=78:ts=8:ft=help:norl: