*netbeans.txt*  For Vim version 7.0b.  Last change: 2006 Mar 09


		  VIM REFERENCE MANUAL    by Gordon Prieur


NetBeans ExternalEditor Integration Features		*netbeans*
							*netbeans-support*
1.  Introduction				|netbeans-intro|
2.  NetBeans Key Bindings			|netbeans-keybindings|
3.  Configuring Vim for NetBeans		|netbeans-configure|
4.  Downloading NetBeans			|netbeans-download|
5.  Preparing NetBeans for Vim			|netbeans-preparation|
6.  Obtaining the External Editor Module	|obtaining-exted|
7.  Setting up NetBeans to run with Vim		|netbeans-setup|
8.  Messages					|netbeans-messages|
9.  Running Vim from NetBeans			|netbeans-run|
10. NetBeans protocol				|netbeans-protocol|
11. NetBeans commands				|netbeans-commands|
12. Known problems				|netbeans-problems|

{Vi does not have any of these features}
{only available when compiled with the |+netbeans_intg| feature}

==============================================================================
1. Introduction						*netbeans-intro*

NetBeans is an open source Integrated Development Environment developed
jointly by Sun Microsystems, Inc. and the netbeans.org developer community.
Initially just a Java IDE, NetBeans has had C, C++, and Fortran support added
in recent releases.

For more information visit the main NetBeans web site http://www.netbeans.org
or the NetBeans External Editor site at http://externaleditor.netbeans.org.

Sun Microsystems, Inc. also ships NetBeans under the name Sun ONE Studio.
Visit http://www.sun.com for more information regarding the Sun ONE Studio
product line.

Current releases of NetBeans provide full support for Java and limited support
for C, C++, and Fortran.  Current releases of Sun ONE Studio provide full
support for Java, C, C++, and Fortran.

The interface to NetBeans is also supported by Agide, the A-A-P GUI IDE.
Agide is very different from NetBeans:
- Based on Python instead of Java, much smaller footprint and fast startup.
- Agide is a framework in which many different tools can work together.
See the A-A-P website for information: http://www.A-A-P.org.

==============================================================================
2. NetBeans Key Bindings				*netbeans-keybindings*

Vim understands a number of key bindings that execute NetBeans commands.
These are typically all the Function key combinations.  To execute a NetBeans
command, the user must press the Pause key followed by a NetBeans key binding.
For example, in order to compile a Java file, the NetBeans key binding is
"F9".  So, while in vim, press "Pause F9" to compile a java file.  To toggle a
breakpoint at the current line, press "Pause Shift F8".

The Pause key is Function key 21.  If you don't have a working Pause key and
want to use F8 instead, use: >

	:map <F8> <F21>

The External Editor module dynamically reads the NetBeans key bindings so vim
should always have the latest key bindings, even when NetBeans changes them.

==============================================================================
3. Configuring Vim for NetBeans			*netbeans-configure*

For more help installing vim, please read |usr_90.txt| in the Vim User Manual.


On Unix

When running configure without arguments the NetBeans interface should be
included.  That is, if the configure check to find out if your system supports
the required features succeeds.

In case you do not want the NetBeans interface you can disable it by
uncommenting a line with "--disable-netbeans" in the Makefile.

Currently, only gvim is supported in this integration as NetBeans does not
have means to supply a terminal emulator for the vim command.  Furthermore,
there is only GUI support for GTK, GNOME, and Motif.

If Motif support is required the user must supply XPM libraries.  See
|workshop-xpm| for details on obtaining the latest version of XPM.


On MS-Windows

The Win32 support is now in beta stage.

To use XPM signs on Win32 (e.g. when using with NetBeans) you can compile
XPM by yourself or use precompiled libraries from http://iamphet.nm.ru/misc/
(for MS Visual C++) or http://gnuwin32.sourceforge.net (for MinGW).

==============================================================================
4. Downloading NetBeans					*netbeans-download*

The NetBeans IDE is available for download from netbeans.org.  You can download
a released version, download sources, or use CVS to download the current
source tree.  If you choose to download sources, follow directions from
netbeans.org on building NetBeans.

Depending on the version of NetBeans you download, you may need to do further
work to get the required External Editor module.  This is the module which lets
NetBeans work with gvim (or xemacs :-).  See http://externaleditor.netbeans.org
for details on downloading this module if your NetBeans release does not have
it.

For C, C++, and Fortran support you will also need the cpp module.  See
http://cpp.netbeans.org for information regarding this module.

You can also download Sun ONE Studio from Sun Microsystems, Inc for a 30 day
free trial.  See http://www.sun.com for further details.

==============================================================================
5. Preparing NetBeans for Vim				*netbeans-preparation*

In order for NetBeans to work with vim, the NetBeans External Editor module
must be loaded and enabled.  If you have a Sun ONE Studio Enterprise Edition
then this module should be loaded and enabled.  If you have a NetBeans release
you may need to find another way of obtaining this open source module.

You can check if you have this module by opening the Tools->Options dialog
and drilling down to the "Modules" list (IDE Configuration->System->Modules).
If your Modules list has an entry for "External Editor" you must make sure
it is enabled (the "Enabled" property should have the value "True").  If your
Modules list has no External Editor see the next section on |obtaining-exted|.

==============================================================================
6. Obtaining the External Editor Module			    *obtaining-exted*

There are 2 ways of obtaining the External Editor module.  The easiest way
is to use the NetBeans Update Center to download and install the module.
Unfortunately, some versions do not have this module in their update
center.  If you cannot download via the update center you will need to
download sources and build the module.  I will try and get the module
available from the NetBeans Update Center so building will be unnecessary.
Also check http://externaleditor.netbeans.org for other availability options.

To download the External Editor sources via CVS and build your own module,
see http://externaleditor.netbeans.org and http://www.netbeans.org.
Unfortunately, this is not a trivial procedure.

==============================================================================
7. Setting up NetBeans to run with Vim			    *netbeans-setup*

Assuming you have loaded and enabled the NetBeans External Editor module
as described in |netbeans-preparation| all you need to do is verify that
the gvim command line is properly configured for your environment.

Open the Tools->Options dialog and open the Editing category.  Select the
External Editor.  The right hand pane should contain a Properties tab and
an Expert tab.  In the Properties tab make sure the "Editor Type" is set
to "Vim".  In the Expert tab make sure the "Vim Command" is correct.

You should be careful if you change the "Vim Command".  There are command
line options there which must be there for the connection to be properly
set up.  You can change the command name but that's about it.  If your gvim
can be found by your $PATH then the VIM Command can start with "gvim".  If
you don't want gvim searched from your $PATH then hard code in the full
Unix path name.  At this point you should get a gvim for any source file
you open in NetBeans.

If some files come up in gvim and others (with different file suffixes) come
up in the default NetBeans editor you should verify the MIME type in the
Expert tab MIME Type property.  NetBeans is MIME oriented and the External
Editor will only open MIME types specified in this property.

==============================================================================
8. Messages						*netbeans-messages*

These messages are specific for NetBeans:

							*E463*
Region is guarded, cannot modify
		NetBeans defines guarded areas in the text, which you cannot
		change.
		Also sets the current buffer, if necessary.

							*E656*
NetBeans disallows writes of unmodified buffers
		NetBeans does not support writes of unmodified buffers that
		were opened from NetBeans.

							*E657*
Partial writes disallowed for NetBeans buffers
		NetBeans does not support partial writes for buffers that were
		opened from NetBeans.

							*E658*
NetBeans connection lost for this buffer
		NetBeans has become confused about the state of this file.
		Rather than risk data corruption, NetBeans has severed the
		connection for this file.  Vim will take over responsibility
		for saving changes to this file and NetBeans will no longer
		know of these changes.

							*E744*
NetBeans does not allow changes in read-only files
		Vim normally allows changes to a read-only file and only
		enforces the read-only rule if you try to write the file.
		However, NetBeans does not let you make changes to a file
		which is read-only and becomes confused if vim does this.
		So vim does not allow modifications to files when run with
		NetBeans.
==============================================================================
9. Running Vim from NetBeans				*netbeans-run*

NetBeans starts Vim with the |-nb| argument.  Three forms can be used, that
differ in the way the information for the connection is specified:

	-nb={fname}				from a file
	-nb:{hostname}:{addr}:{password}	directly
	-nb					from a file or environment

							*E660* *E668*
For security reasons, the best method is to write the information in a file
readable only by the user.  The name of the file can be passed with the
"-nb={fname}" argument or, when "-nb" is used without a parameter, the
environment variable "__NETBEANS_CONINFO".  The file must contain these three
lines, in any order:

	host={hostname}
	port={addr}
	auth={password}

Other lines are ignored.  The caller of Vim is responsible for deleting the
file afterwards.

{hostname} is the name of the machine where NetBeans is running.  When omitted
the environment variable "__NETBEANS_HOST" is used or the default "localhost".

{addr} is the port number for NetBeans.  When omitted the environment variable
"__NETBEANS_SOCKET" is used or the default 3219.

{password} is the password for connecting to NetBeans.  When omitted the
environment variable "__NETBEANS_VIM_PASSWORD" is used or "changeme".

==============================================================================
10. NetBeans protocol					*netbeans-protocol*

The communication between NetBeans and Vim uses plain text messages.  This
protocol was first designed to work with the external editor module of
NetBeans (see http://externaleditor.netbeans.org).  Later it was extended to
work with Agide (A-A-P GUI IDE, see http://www.a-a-p.org).  The extensions are
marked with "version 2.1".

Version 2.2 of the protocol has several minor changes which should only affect
NetBeans users (ie, not Agide users).  However, a bug was fixed which could
cause confusion.  The netbeans_saved() function sent a "save" protocol
command.  In protocol version 2.1 and earlier this was incorrectly interpreted
as a notification that a write had taken place.  In reality, it told NetBeans
to save the file so multiple writes were being done.  This caused various
problems and has been fixed in 2.2.  To decrease the likelihood of this
confusion happening again, netbeans_saved() has been renamed to
netbeans_save_buffer().

We are now at version 2.3.  For the differences between 2.2 and 2.3 search for
"2.3" below.

The messages are currently sent over a socket.  Since the messages are in
plain UTF-8 text this protocol could also be used with any other communication
mechanism.

To see an example implementation look at the gvim tool in Agide.  Currently
found here:
	http://cvs.sf.net/viewcvs.py/a-a-p/Agide/Tools/GvimTool.py?view=markup



10.1 Kinds of messages		|nb-messages|
10.2 Terms			|nb-terms|
10.3 Commands			|nb-commands|
10.4 Functions and Replies	|nb-functions|
10.5 Events			|nb-events|
10.6 Special messages		|nb-special|

*E627* *E628* *E629* *E630* *E631* *E632* *E633* *E634* *E635* *E636*
*E637* *E638* *E639* *E640* *E641* *E642* *E643* *E644* *E645* *E646*
*E647* *E648* *E649* *E650* *E651* *E652* *E653* *E654*
These errors occur when a message violates the protocol.


10.1 Kinds of messages					*nb-messages*

There are four kinds of messages:

kind		direction	comment ~
Command		IDE -> editor	no reply necessary
Function	IDE -> editor	editor must send back a reply
Reply		editor -> IDE	only in response to a Function
Event		editor -> IDE	no reply necessary

The messages are sent as a single line with a terminating newline character.
Arguments are separated by a single space.  The first item of the message
depends on the kind of message:

kind		first item		example ~
Command		bufID:name!seqno	11:showBalloon!123 "text"
Function	bufID:name/seqno	11:getLength/123
Reply		seqno			123 5000
Event		bufID:name=123		11:keyCommand=123 "S-F2"


10.2 Terms						*nb-terms*

bufID		Buffer number.  A message may be either for a specific buffer
		or generic.  Generic messages use a bufID of zero.  NOTE: this
		buffer ID is assigned by the IDE, it is not Vim's buffer
		number.  The bufID must be a sequentially rising number,
		start                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            