blob: 7455f2f3d61a3b886d94da842867ded0406a455a [file] [log] [blame]
Bram Moolenaare0fa3742016-02-20 15:47:01 +01001*netbeans.txt* For Vim version 7.4. Last change: 2016 Feb 18
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00004 VIM REFERENCE MANUAL by Gordon Prieur et al.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005
6
Bram Moolenaar298b4402016-01-28 22:38:53 +01007 *netbeans* *netbeans-support*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00008
9Vim NetBeans Protocol: a socket interface for Vim integration into an IDE.
10
Bram Moolenaar071d4272004-06-13 20:20:40 +0000111. Introduction |netbeans-intro|
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000122. Integration features |netbeans-integration|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000133. Configuring Vim for NetBeans |netbeans-configure|
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000144. Error Messages |netbeans-messages|
155. Running Vim in NetBeans mode |netbeans-run|
166. NetBeans protocol |netbeans-protocol|
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200177. NetBeans commands |netbeans-commands|
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000188. Known problems |netbeans-problems|
199. Debugging NetBeans protocol |netbeans-debugging|
2010. NetBeans External Editor
21 10.1. Downloading NetBeans |netbeans-download|
22 10.2. NetBeans Key Bindings |netbeans-keybindings|
23 10.3. Preparing NetBeans for Vim |netbeans-preparation|
24 10.4. Obtaining the External Editor Module |obtaining-exted|
25 10.5. Setting up NetBeans to run with Vim |netbeans-setup|
Bram Moolenaar071d4272004-06-13 20:20:40 +000026
27{Vi does not have any of these features}
28{only available when compiled with the |+netbeans_intg| feature}
29
30==============================================================================
311. Introduction *netbeans-intro*
32
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000033The NetBeans interface was initially developed to integrate Vim into the
34NetBeans Java IDE, using the external editor plugin. This NetBeans plugin no
35longer exists for recent versions of NetBeans but the protocol was developed
36in such a way that any IDE can use it to integrate Vim.
37
38The NetBeans protocol of Vim is a text based communication protocol, over a
39classical TCP socket. There is no dependency on Java or NetBeans. Any language
40or environment providing a socket interface can control Vim using this
41protocol. There are existing implementations in C, C++, Python and Java. The
42name NetBeans is kept today for historical reasons.
43
44Current projects using the NetBeans protocol of Vim are:
45- VimIntegration, description of various projects doing Vim Integration:
46 http://www.freehackers.org/VimIntegration
47- Agide, an IDE for the AAP project, written in Python:
48 http://www.a-a-p.org
49- Clewn, a gdb integration into Vim, written in C:
50 http://clewn.sourceforge.net/
Bram Moolenaarb26e6322010-05-22 21:34:09 +020051- Pyclewn, a gdb integration into Vim, written in Python:
52 http://pyclewn.sourceforge.net/
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000053- VimPlugin, integration of Vim inside Eclipse:
54 http://vimplugin.sourceforge.net/wiki/pmwiki.php
55- PIDA, IDE written in Python integrating Vim:
56 http://pida.co.uk/
57- VimWrapper, library to easy Vim integration into IDE:
58 http://www.freehackers.org/VimWrapper
59
60Check the specific project pages to see how to use Vim with these projects.
61
62In the rest of this help page, we will use the term "Vim Controller" to
63describe the program controlling Vim through the NetBeans socket interface.
64
65
66About the NetBeans IDE ~
67
Bram Moolenaar071d4272004-06-13 20:20:40 +000068NetBeans is an open source Integrated Development Environment developed
69jointly by Sun Microsystems, Inc. and the netbeans.org developer community.
70Initially just a Java IDE, NetBeans has had C, C++, and Fortran support added
71in recent releases.
72
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000073For more information visit the main NetBeans web site http://www.netbeans.org.
Bram Moolenaarc236c162008-07-13 17:41:49 +000074The External Editor is now, unfortunately, declared obsolete. See
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000075 http://externaleditor.netbeans.org.
Bram Moolenaar071d4272004-06-13 20:20:40 +000076
77Sun Microsystems, Inc. also ships NetBeans under the name Sun ONE Studio.
78Visit http://www.sun.com for more information regarding the Sun ONE Studio
79product line.
80
81Current releases of NetBeans provide full support for Java and limited support
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000082for C, C++, and Fortran. Current releases of Sun ONE Studio provide full
Bram Moolenaar071d4272004-06-13 20:20:40 +000083support for Java, C, C++, and Fortran.
84
Bram Moolenaar071d4272004-06-13 20:20:40 +000085==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000862. Integration features *netbeans-integration*
Bram Moolenaar071d4272004-06-13 20:20:40 +000087
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000088The NetBeans socket interface of Vim allows to get information from Vim or to
89ask Vim to perform specific actions:
90- get information about buffer: buffer name, cursor position, buffer content,
91 etc.
92- be notified when buffers are open or closed
93- be notified of how the buffer content is modified
94- load and save files
95- modify the buffer content
96- installing special key bindings
97- raise the window, control the window geometry
Bram Moolenaar071d4272004-06-13 20:20:40 +000098
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000099For sending key strokes to Vim or for evaluating functions in Vim, you must
100use the |clientserver| interface.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000101
Bram Moolenaar071d4272004-06-13 20:20:40 +0000102
103==============================================================================
1043. Configuring Vim for NetBeans *netbeans-configure*
105
Bram Moolenaar06b5d512010-05-22 15:37:44 +0200106For more help about installing Vim, please read |usr_90.txt| in the Vim User
107Manual.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000108
109
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000110On Unix:
111--------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000112
113When running configure without arguments the NetBeans interface should be
114included. That is, if the configure check to find out if your system supports
115the required features succeeds.
116
117In case you do not want the NetBeans interface you can disable it by
118uncommenting a line with "--disable-netbeans" in the Makefile.
119
Bram Moolenaar67c53842010-05-22 18:28:27 +0200120Currently the NetBeans interface is supported by Vim running in a terminal and
Bram Moolenaar173c9852010-09-29 17:27:01 +0200121by GVim when it is run with one of the following GUIs: GTK, GNOME, Windows,
122Athena and Motif.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000123
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000124If Motif support is required the user must supply XPM libraries. See
Bram Moolenaar071d4272004-06-13 20:20:40 +0000125|workshop-xpm| for details on obtaining the latest version of XPM.
126
127
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000128On MS-Windows:
129--------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000130
131The Win32 support is now in beta stage.
132
133To use XPM signs on Win32 (e.g. when using with NetBeans) you can compile
134XPM by yourself or use precompiled libraries from http://iamphet.nm.ru/misc/
135(for MS Visual C++) or http://gnuwin32.sourceforge.net (for MinGW).
136
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000137Enable debugging:
138-----------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000139
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000140To enable debugging of Vim and of the NetBeans protocol, the "NBDEBUG" macro
141needs to be defined. Search in the Makefile of the platform you are using for
142"NBDEBUG" to see what line needs to be uncommented. This effectively adds
143"-DNBDEBUG" to the compile command. Also see |netbeans-debugging|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000144
145==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00001464. Error Messages *netbeans-messages*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000147
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000148These error messages are specific to NetBeans socket protocol:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000149
150 *E463*
151Region is guarded, cannot modify
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000152 The Vim Controller has defined guarded areas in the text,
153 which you cannot change. Also sets the current buffer, if
154 necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000155
Bram Moolenaar67c53842010-05-22 18:28:27 +0200156 *E532*
157The defineAnnoType highlighting color name is too long
158 The maximum length of the "fg" or "bg" color argument in the
159 defineAnnoType command is 32 characters.
160 New in version 2.5.
161
Bram Moolenaar071d4272004-06-13 20:20:40 +0000162 *E656*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000163Writes of unmodified buffers forbidden
164 Writes of unmodified buffers that were opened from the
165 Vim Controller are not possible.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000166
167 *E657*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000168Partial writes disallowed
169 Partial writes for buffers that were opened from the
170 Vim Controller are not allowed.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000171
172 *E658*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000173Connection lost for this buffer
174 The Vim Controller has become confused about the state of
175 this file. Rather than risk data corruption, it has severed
176 the connection for this file. Vim will take over
177 responsibility for saving changes to this file and the
178 Vim Controller will no longer know of these changes.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000179
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000180 *E744*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000181Read-only file
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000182 Vim normally allows changes to a read-only file and only
183 enforces the read-only rule if you try to write the file.
184 However, NetBeans does not let you make changes to a file
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000185 which is read-only and becomes confused if Vim does this.
186 So Vim does not allow modifications to files when run
187 in NetBeans mode.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000188
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000189==============================================================================
1905. Running Vim in NetBeans mode *netbeans-run*
191
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200192There are two different ways to run Vim in NetBeans mode:
193
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200194 + an IDE may start Vim with the |-nb| command line argument
195 + NetBeans can be started from within Vim with the |:nbstart| command
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200196
Bram Moolenaare0fa3742016-02-20 15:47:01 +0100197Vim uses a 3 second timeout on trying to make the connection.
198
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200199 *netbeans-parameters*
200Three forms can be used to setup the NetBeans connection parameters.
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200201When started from the command line, the |-nb| command line argument may be:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202
203 -nb={fname} from a file
204 -nb:{hostname}:{addr}:{password} directly
205 -nb from a file or environment
206
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200207When started from within Vim, the |:nbstart| optional argument may be:
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200208
209 ={fname} from a file
210 :{hostname}:{addr}:{password} directly
211 <MISSING ARGUMENT> from a file or environment
212
Bram Moolenaar071d4272004-06-13 20:20:40 +0000213 *E660* *E668*
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200214When NetBeans is started from the command line, for security reasons, the best
215method is to write the information in a file readable only by the user. The
216name of the file can be passed with the "-nb={fname}" argument or, when "-nb"
217is used without a parameter, the environment variable "__NETBEANS_CONINFO".
218The file must contain these three lines, in any order:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000219
220 host={hostname}
221 port={addr}
222 auth={password}
223
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200224Other lines are ignored. The Vim Controller is responsible for deleting the
Bram Moolenaar071d4272004-06-13 20:20:40 +0000225file afterwards.
226
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000227{hostname} is the name of the machine where Vim Controller is running. When
228omitted the environment variable "__NETBEANS_HOST" is used or the default
229"localhost".
Bram Moolenaar071d4272004-06-13 20:20:40 +0000230
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000231{addr} is the port number for the NetBeans interface. When omitted the
232environment variable "__NETBEANS_SOCKET" is used or the default 3219.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000233
234{password} is the password for connecting to NetBeans. When omitted the
235environment variable "__NETBEANS_VIM_PASSWORD" is used or "changeme".
236
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000237Vim will initiate a socket connection (client side) to the specified host and
238port upon startup. The password will be sent with the AUTH event when the
239connection has been established.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000240
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000241
242==============================================================================
2436. NetBeans protocol *netbeans-protocol*
244
245The communication between the Vim Controller and Vim uses plain text
246messages. This protocol was first designed to work with the external editor
247module of NetBeans. Later it was extended to work with Agide (A-A-P GUI IDE,
248see http://www.a-a-p.org) and then with other IDE. The extensions are marked
249with "version 2.1".
Bram Moolenaar071d4272004-06-13 20:20:40 +0000250
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000251Version 2.2 of the protocol has several minor changes which should only affect
252NetBeans users (ie, not Agide users). However, a bug was fixed which could
253cause confusion. The netbeans_saved() function sent a "save" protocol
254command. In protocol version 2.1 and earlier this was incorrectly interpreted
255as a notification that a write had taken place. In reality, it told NetBeans
256to save the file so multiple writes were being done. This caused various
257problems and has been fixed in 2.2. To decrease the likelihood of this
Bram Moolenaar071d4272004-06-13 20:20:40 +0000258confusion happening again, netbeans_saved() has been renamed to
259netbeans_save_buffer().
260
Bram Moolenaar67c53842010-05-22 18:28:27 +0200261We are now at version 2.5. For the differences between 2.4 and 2.5 search for
262"2.5" below.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000263
Bram Moolenaar071d4272004-06-13 20:20:40 +0000264The messages are currently sent over a socket. Since the messages are in
265plain UTF-8 text this protocol could also be used with any other communication
266mechanism.
267
Bram Moolenaare3cc6d42011-10-20 21:58:34 +0200268Netbeans messages are processed when Vim is idle, waiting for user input.
269When Vim is run in non-interactive mode, for example when running an automated
270test case that sources a Vim script, the idle loop may not be called often
Bram Moolenaarb8ff1fb2012-02-04 21:59:01 +0100271enough. In that case, insert |:sleep| commands in the Vim script. The |:sleep|
Bram Moolenaare3cc6d42011-10-20 21:58:34 +0200272command does invoke Netbeans messages processing.
273
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00002746.1 Kinds of messages |nb-messages|
2756.2 Terms |nb-terms|
2766.3 Commands |nb-commands|
2776.4 Functions and Replies |nb-functions|
2786.5 Events |nb-events|
2796.6 Special messages |nb-special|
2806.7 Protocol errors |nb-protocol_errors|
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000281
282
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00002836.1 Kinds of messages *nb-messages*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000284
285There are four kinds of messages:
286
287kind direction comment ~
288Command IDE -> editor no reply necessary
289Function IDE -> editor editor must send back a reply
290Reply editor -> IDE only in response to a Function
291Event editor -> IDE no reply necessary
292
293The messages are sent as a single line with a terminating newline character.
294Arguments are separated by a single space. The first item of the message
295depends on the kind of message:
296
297kind first item example ~
298Command bufID:name!seqno 11:showBalloon!123 "text"
299Function bufID:name/seqno 11:getLength/123
300Reply seqno 123 5000
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000301Event bufID:name=seqno 11:keyCommand=123 "S-F2"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000302
303
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000304
3056.2 Terms *nb-terms*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000306
307bufID Buffer number. A message may be either for a specific buffer
308 or generic. Generic messages use a bufID of zero. NOTE: this
309 buffer ID is assigned by the IDE, it is not Vim's buffer
310 number. The bufID must be a sequentially rising number,
Bram Moolenaar5837f1f2015-03-21 18:06:14 +0100311 starting at one. When the 'switchbuf' option is set to
312 "usetab" and the "bufID" buffer is not found in the current
313 tab page, the netbeans commands and functions that set this
314 buffer as the current buffer will jump to the first open
315 window that contains this buffer in other tab pages instead of
316 replacing the buffer in the current window.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000317
318seqno The IDE uses a sequence number for Commands and Functions. A
319 Reply must use the sequence number of the Function that it is
320 associated with. A zero sequence number can be used for
321 Events (the seqno of the last received Command or Function can
322 also be used).
323
324string Argument in double quotes. Text is in UTF-8 encoding. This
325 means ASCII is passed as-is. Special characters are
326 represented with a backslash:
327 \" double quote
328 \n newline
329 \r carriage-return
330 \t tab (optional, also works literally)
331 \\ backslash
332 NUL bytes are not allowed!
333
334boolean Argument with two possible values:
335 T true
336 F false
337
338number Argument with a decimal number.
339
Bram Moolenaar67c53842010-05-22 18:28:27 +0200340color Argument with either a decimal number, "none" (without the
341 quotes) or the name of a color (without the quotes) defined
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200342 both in the color list in |highlight-ctermfg| and in the color
343 list in |gui-colors|.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200344 New in version 2.5.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000345
346offset A number argument that indicates a byte position in a buffer.
347 The first byte has offset zero. Line breaks are counted for
348 how they appear in the file (CR/LF counts for two bytes).
349 Note that a multi-byte character is counted for the number of
350 bytes it takes.
351
352lnum/col Argument with a line number and column number position. The
353 line number starts with one, the column is the byte position,
354 starting with zero. Note that a multi-byte character counts
355 for several columns.
356
357pathname String argument: file name with full path.
358
359
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00003606.3 Commands *nb-commands*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000361
362actionMenuItem Not implemented.
363
364actionSensitivity
365 Not implemented.
366
367addAnno serNum typeNum off len
368 Place an annotation in this buffer.
369 Arguments:
370 serNum number serial number of this placed
371 annotation, used to be able to remove
372 it
373 typeNum number sequence number of the annotation
374 defined with defineAnnoType for this
375 buffer
376 off number offset where annotation is to be placed
377 len number not used
378 In version 2.1 "lnum/col" can be used instead of "off".
379
380balloonResult text
381 Not implemented.
382
383close Close the buffer. This leaves us without current buffer, very
384 dangerous to use!
385
386create Creates a buffer without a name. Replaces the current buffer
387 (it's hidden when it was changed).
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000388 The Vim Controller should use this as the first command for a
389 file that is being opened. The sequence of commands could be:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000390 create
391 setCaretListener (ignored)
392 setModified (no effect)
393 setContentType (ignored)
394 startDocumentListen
395 setTitle
396 setFullName
397
398defineAnnoType typeNum typeName tooltip glyphFile fg bg
399 Define a type of annotation for this buffer.
400 Arguments:
401 typeNum number sequence number (not really used)
402 typeName string name that identifies this annotation
403 tooltip string not used
404 glyphFile string name of icon file
Bram Moolenaar67c53842010-05-22 18:28:27 +0200405 fg color foreground color for line highlighting
406 bg color background color for line highlighting
Bram Moolenaar071d4272004-06-13 20:20:40 +0000407 Vim will define a sign for the annotation.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200408 When color is a number, this is the "#rrggbb" Red, Green and
409 Blue values of the color (see |gui-colors|) and the
410 highlighting is only defined for GVim.
411 When color is a name, this color is defined both for Vim
412 running in a color terminal and for GVim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000413 When both "fg" and "bg" are "none" no line highlighting is
414 used (new in version 2.1).
415 When "glyphFile" is empty, no text sign is used (new in
416 version 2.1).
417 When "glyphFile" is one or two characters long, a text sign is
418 defined (new in version 2.1).
419 Note: the annotations will be defined in sequence, and the
420 sequence number is later used with addAnno.
421
422editFile pathname
423 Set the name for the buffer and edit the file "pathname", a
424 string argument.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000425 Normal way for the IDE to tell the editor to edit a file.
426
427 You must set a bufId different of 0 with this command to
428 assign a bufId to the buffer. It will trigger an event
429 fileOpened with a bufId of 0 but the buffer has been assigned.
430
431 If the IDE is going to pass the file text to the editor use
432 these commands instead:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000433 setFullName
434 insert
435 initDone
436 New in version 2.1.
437
438enableBalloonEval
439 Not implemented.
440
441endAtomic End an atomic operation. The changes between "startAtomic"
442 and "endAtomic" can be undone as one operation. But it's not
443 implemented yet. Redraw when necessary.
444
445guard off len
446 Mark an area in the buffer as guarded. This means it cannot
447 be edited. "off" and "len" are numbers and specify the text
448 to be guarded.
449
450initDone Mark the buffer as ready for use. Implicitly makes the buffer
451 the current buffer. Fires the BufReadPost autocommand event.
452
Bram Moolenaar009b2592004-10-24 19:18:58 +0000453insertDone
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000454 Sent by Vim Controller to tell Vim an initial file insert is
455 done. This triggers a read message being printed. Prior to
456 version 2.3, no read messages were displayed after opening a
457 file. New in version 2.3.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000458
Bram Moolenaar071d4272004-06-13 20:20:40 +0000459moveAnnoToFront serNum
460 Not implemented.
461
462netbeansBuffer isNetbeansBuffer
Bram Moolenaarc236c162008-07-13 17:41:49 +0000463 If "isNetbeansBuffer" is "T" then this buffer is "owned" by
Bram Moolenaar071d4272004-06-13 20:20:40 +0000464 NetBeans.
465 New in version 2.2.
466
467putBufferNumber pathname
468 Associate a buffer number with the Vim buffer by the name
469 "pathname", a string argument. To be used when the editor
470 reported editing another file to the IDE and the IDE needs to
471 tell the editor what buffer number it will use for this file.
472 Also marks the buffer as initialized.
473 New in version 2.1.
474
475raise Bring the editor to the foreground.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200476 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000477 New in version 2.1.
478
479removeAnno serNum
Bram Moolenaar3a991dd2014-10-02 01:41:41 +0200480 Remove a previously placed annotation for this buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000481 "serNum" is the same number used in addAnno.
482
483save Save the buffer when it was modified. The other side of the
484 interface is expected to write the buffer and invoke
485 "setModified" to reset the "changed" flag of the buffer.
486 The writing is skipped when one of these conditions is true:
487 - 'write' is not set
488 - the buffer is read-only
489 - the buffer does not have a file name
490 - 'buftype' disallows writing
491 New in version 2.2.
492
Bram Moolenaar009b2592004-10-24 19:18:58 +0000493saveDone
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000494 Sent by Vim Controller to tell Vim a save is done. This
495 triggers a save message being printed. Prior to version 2.3,
496 no save messages were displayed after a save.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000497 New in version 2.3.
498
Bram Moolenaar071d4272004-06-13 20:20:40 +0000499setAsUser Not implemented.
500
501setBufferNumber pathname
502 Associate a buffer number with Vim buffer by the name
503 "pathname". To be used when the editor reported editing
504 another file to the IDE and the IDE needs to tell the editor
505 what buffer number it will use for this file.
506 Has the side effect of making the buffer the current buffer.
507 See "putBufferNumber" for a more useful command.
508
509setContentType
510 Not implemented.
511
512setDot off Make the buffer the current buffer and set the cursor at the
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000513 specified position. If the buffer is open in another window
514 than make that window the current window.
515 If there are folds they are opened to make the cursor line
516 visible.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000517 In version 2.1 "lnum/col" can be used instead of "off".
518
519setExitDelay seconds
520 Set the delay for exiting to "seconds", a number.
521 This delay is used to give the IDE a chance to handle things
522 before really exiting. The default delay is two seconds.
523 New in version 2.1.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000524 Obsolete in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000525
526setFullName pathname
527 Set the file name to be used for a buffer to "pathname", a
528 string argument.
529 Used when the IDE wants to edit a file under control of the
530 IDE. This makes the buffer the current buffer, but does not
531 read the file. "insert" commands will be used next to set the
532 contents.
533
534setLocAndSize Not implemented.
535
536setMark Not implemented.
537
538setModified modified
539 When the boolean argument "modified" is "T" mark the buffer as
540 modified, when it is "F" mark it as unmodified.
541
Bram Moolenaar009b2592004-10-24 19:18:58 +0000542setModtime time
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000543 Update a buffers modification time after the file has been
544 saved directly by the Vim Controller.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000545 New in version 2.3.
546
547setReadOnly
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000548 Set a file as readonly
549 Implemented in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000550
551setStyle Not implemented.
552
553setTitle name
554 Set the title for the buffer to "name", a string argument.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000555 The title is only used for the Vim Controller functions, not
556 by Vim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000557
558setVisible visible
559 When the boolean argument "visible" is "T", goto the buffer.
560 The "F" argument does nothing.
561
562showBalloon text
563 Show a balloon (popup window) at the mouse pointer position,
564 containing "text", a string argument. The balloon should
565 disappear when the mouse is moved more than a few pixels.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200566 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000567 New in version 2.1.
568
Bram Moolenaar009b2592004-10-24 19:18:58 +0000569specialKeys
570 Map a set of keys (mostly function keys) to be passed back
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000571 to the Vim Controller for processing. This lets regular IDE
572 hotkeys be used from Vim.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000573 Implemented in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000574
575startAtomic Begin an atomic operation. The screen will not be updated
576 until "endAtomic" is given.
577
578startCaretListen
579 Not implemented.
580
581startDocumentListen
582 Mark the buffer to report changes to the IDE with the
583 "insert" and "remove" events. The default is to report
584 changes.
585
586stopCaretListen
587 Not implemented.
588
589stopDocumentListen
590 Mark the buffer to stop reporting changes to the IDE.
591 Opposite of startDocumentListen.
Bram Moolenaar748bf032005-02-02 23:04:36 +0000592 NOTE: if "netbeansBuffer" was used to mark this buffer as a
593 NetBeans buffer, then the buffer is deleted in Vim. This is
594 for compatibility with Sun Studio 10.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000595
596unguard off len
597 Opposite of "guard", remove guarding for a text area.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000598 Also sets the current buffer, if necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000599
600version Not implemented.
601
602
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00006036.4 Functions and Replies *nb-functions*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000604
605getDot Not implemented.
606
607getCursor Return the current buffer and cursor position.
608 The reply is:
609 seqno bufID lnum col off
610 seqno = sequence number of the function
611 bufID = buffer ID of the current buffer (if this is unknown -1
612 is used)
613 lnum = line number of the cursor (first line is one)
614 col = column number of the cursor (in bytes, zero based)
615 off = offset of the cursor in the buffer (in bytes)
616 New in version 2.1.
617
618getLength Return the length of the buffer in bytes.
619 Reply example for a buffer with 5000 bytes:
620 123 5000
621 TODO: explain use of partial line.
622
623getMark Not implemented.
624
Bram Moolenaarc65c4912006-11-14 17:29:46 +0000625getAnno serNum
626 Return the line number of the annotation in the buffer.
627 Argument:
628 serNum serial number of this placed annotation
629 The reply is:
630 123 lnum line number of the annotation
631 123 0 invalid annotation serial number
632 New in version 2.4.
633
Bram Moolenaar071d4272004-06-13 20:20:40 +0000634getModified When a buffer is specified: Return zero if the buffer does not
635 have changes, one if it does have changes.
636 When no buffer is specified (buffer number zero): Return the
637 number of buffers with changes. When the result is zero it's
638 safe to tell Vim to exit.
639 New in version 2.1.
640
641getText Return the contents of the buffer as a string.
642 Reply example for a buffer with two lines
643 123 "first line\nsecond line\n"
644 NOTE: docs indicate an offset and length argument, but this is
645 not implemented.
646
647insert off text
648 Insert "text" before position "off". "text" is a string
649 argument, "off" a number.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000650 "text" should have a "\n" (newline) at the end of each line.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000651 Or "\r\n" when 'fileformat' is "dos". When using "insert" in
652 an empty buffer Vim will set 'fileformat' accordingly.
653 When "off" points to the start of a line the text is inserted
654 above this line. Thus when "off" is zero lines are inserted
655 before the first line.
656 When "off" points after the start of a line, possibly on the
657 NUL at the end of a line, the first line of text is appended
658 to this line. Further lines come below it.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000659 Possible replies:
660 123 no problem
661 123 !message failed
662 Note that the message in the reply is not quoted.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000663 Also sets the current buffer, if necessary.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000664 Does not move the cursor to the changed text.
665 Resets undo information.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000666
667remove off length
668 Delete "length" bytes of text at position "off". Both
669 arguments are numbers.
670 Possible replies:
671 123 no problem
672 123 !message failed
673 Note that the message in the reply is not quoted.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000674 Also sets the current buffer, if necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000675
676saveAndExit Perform the equivalent of closing Vim: ":confirm qall".
677 If there are no changed files or the user does not cancel the
678 operation Vim exits and no result is sent back. The IDE can
679 consider closing the connection as a successful result.
680 If the user cancels the operation the number of modified
681 buffers that remains is returned and Vim does not exit.
682 New in version 2.1.
683
684
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00006856.5 Events *nb-events*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000686
687balloonEval off len type
688 The mouse pointer rests on text for a short while. When "len"
689 is zero, there is no selection and the pointer is at position
690 "off". When "len" is non-zero the text from position "off" to
691 "off" + "len" is selected.
692 Only sent after "enableBalloonEval" was used for this buffer.
693 "type" is not yet defined.
694 Not implemented yet.
695
696balloonText text
697 Used when 'ballooneval' is set and the mouse pointer rests on
698 some text for a moment. "text" is a string, the text under
699 the mouse pointer.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200700 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000701 New in version 2.1.
702
703buttonRelease button lnum col
704 Report which button was pressed and the location of the cursor
705 at the time of the release. Only for buffers that are owned
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000706 by the Vim Controller. This event is not sent if the button
707 was released while the mouse was in the status line or in a
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000708 separator line. If col is less than 1 the button release was
Bram Moolenaar071d4272004-06-13 20:20:40 +0000709 in the sign area.
710 New in version 2.2.
711
Bram Moolenaar009b2592004-10-24 19:18:58 +0000712disconnect
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000713 Tell the Vim Controller that Vim is exiting and not to try and
714 read or write more commands.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000715 New in version 2.3.
716
Bram Moolenaar071d4272004-06-13 20:20:40 +0000717fileClosed Not implemented.
718
719fileModified Not implemented.
720
721fileOpened pathname open modified
722 A file was opened by the user.
723 Arguments:
724 pathname string name of the file
725 open boolean always "T"
726 modified boolean always "F"
727
728geometry cols rows x y
729 Report the size and position of the editor window.
730 Arguments:
731 cols number number of text columns
732 rows number number of text rows
733 x number pixel position on screen
734 y number pixel position on screen
735 Only works for Motif.
736
737insert off text
738 Text "text" has been inserted in Vim at position "off".
739 Only fired when enabled, see "startDocumentListen".
740
741invokeAction Not implemented.
742
743keyCommand keyName
744 Reports a special key being pressed with name "keyName", which
745 is a string.
746 Supported key names:
747 F1 function key 1
748 F2 function key 2
749 ...
750 F12 function key 12
751
752 ' ' space (without the quotes)
753 ! exclamation mark
754 ... any other ASCII printable character
755 ~ tilde
756
757 X any unrecognized key
758
759 The key may be prepended by "C", "S" and/or "M" for Control,
760 Shift and Meta (Alt) modifiers. If there is a modifier a dash
761 is used to separate it from the key name. For example:
762 "C-F2".
763 ASCII characters are new in version 2.1.
764
765keyAtPos keyName lnum/col
766 Like "keyCommand" and also report the line number and column
767 of the cursor.
768 New in version 2.1.
769
Bram Moolenaard7f8f5c2009-01-06 15:14:30 +0000770killed A file was deleted or wiped out by the user and the buffer
771 annotations have been removed. The bufID number for this
772 buffer has become invalid. Only for files that have been
773 assigned a bufID number by the IDE.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000774
775newDotAndMark off off
776 Reports the position of the cursor being at "off" bytes into
777 the buffer. Only sent just before a "keyCommand" event.
778
779quit Not implemented.
780
781remove off len
782 Text was deleted in Vim at position "off" with byte length
783 "len".
784 Only fired when enabled, see "startDocumentListen".
785
786revert Not implemented.
787
788save The buffer has been saved and is now unmodified.
789 Only fired when enabled, see "startDocumentListen".
790
791startupDone The editor has finished its startup work and is ready for
792 editing files.
793 New in version 2.1.
794
795unmodified The buffer is now unmodified.
796 Only fired when enabled, see "startDocumentListen".
797
798version vers Report the version of the interface implementation. Vim
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000799 reports "2.4" (including the quotes).
Bram Moolenaar071d4272004-06-13 20:20:40 +0000800
801
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00008026.6 Special messages *nb-special*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000803
804These messages do not follow the style of the messages above. They are
805terminated by a newline character.
806
807ACCEPT Not used.
808
809AUTH password editor -> IDE: First message that the editor sends to the IDE.
810 Must contain the password for the socket server, as specified
811 with the |-nb| argument. No quotes are used!
812
813DISCONNECT IDE -> editor: break the connection. The editor will exit.
814 The IDE must only send this message when there are no unsaved
815 changes!
816
817DETACH IDE -> editor: break the connection without exiting the
818 editor. Used when the IDE exits without bringing down the
819 editor as well.
820 New in version 2.1.
821
822REJECT Not used.
823
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000824
8256.7 Protocol errors *nb-protocol_errors*
826
827These errors occur when a message violates the protocol:
Bram Moolenaar5e9b2fa2016-02-01 22:37:05 +0100828*E627* *E628* *E629* *E632* *E633* *E634* *E635* *E636*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000829*E637* *E638* *E639* *E640* *E641* *E642* *E643* *E644* *E645* *E646*
Bram Moolenaaraa3b15d2016-04-21 08:53:19 +0200830*E647* *E648* *E649* *E650* *E651* *E652*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000831
832
Bram Moolenaar071d4272004-06-13 20:20:40 +0000833==============================================================================
Bram Moolenaarb26e6322010-05-22 21:34:09 +02008347. NetBeans commands *netbeans-commands*
835
Bram Moolenaar4a748032010-09-30 21:47:56 +0200836 *:nbstart* *E511* *E838*
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200837:nbs[tart] {connection} Start a new Netbeans session with {connection} as the
838 socket connection parameters. The format of
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200839 {connection} is described in |netbeans-parameters|.
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200840 At any time, one may check if the netbeans socket is
841 connected by running the command:
842 ':echo has("netbeans_enabled")'
843
844 *:nbclose*
845:nbc[lose] Close the current NetBeans session. Remove all placed
846 signs.
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000847
848 *:nbkey*
Bram Moolenaare3cc6d42011-10-20 21:58:34 +0200849:nb[key] {key} Pass the {key} to the Vim Controller for processing.
850 When a hot-key has been installed with the specialKeys
851 command, this command can be used to generate a hotkey
852 message to the Vim Controller.
853 This command can also be used to pass any text to the
854 Vim Controller. It is used by Pyclewn, for example,
855 to build the complete set of gdb commands as Vim user
856 commands.
857 The events newDotAndMark, keyCommand and keyAtPos are
858 generated (in this order).
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000859
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000860
861==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00008628. Known problems *netbeans-problems*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000863
864NUL bytes are not possible. For editor -> IDE they will appear as NL
865characters. For IDE -> editor they cannot be inserted.
866
Bram Moolenaar67c53842010-05-22 18:28:27 +0200867A NetBeans session may be initiated with Vim running in a terminal, and
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200868continued later in a GUI environment after running the |:gui| command. In this
Bram Moolenaar67c53842010-05-22 18:28:27 +0200869case, the highlighting defined for the NetBeans annotations may be cleared
870when the ":gui" command sources .gvimrc and this file loads a colorscheme
871that runs the command ":highlight clear".
872New in version 2.5.
873
Bram Moolenaar071d4272004-06-13 20:20:40 +0000874
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000875==============================================================================
8769. Debugging NetBeans protocol *netbeans-debugging*
877
878To debug the Vim protocol, you must first compile Vim with debugging support
879and NetBeans debugging support. See |netbeans-configure| for instructions
880about Vim compiling and how to enable debug support.
881
882When running Vim, set the following environment variables:
883
884 export SPRO_GVIM_DEBUG=netbeans.log
885 export SPRO_GVIM_DLEVEL=0xffffffff
886
887Vim will then log all the incoming and outgoing messages of the NetBeans
888protocol to the file netbeans.log .
889
890The content of netbeans.log after a session looks like this:
891Tue May 20 17:19:27 2008
892EVT: 0:startupDone=0
893CMD 1: (1) create
894CMD 2: (1) setTitle "testfile1.txt"
895CMD 3: (1) setFullName "testfile1.txt"
896EVT(suppressed): 1:remove=3 0 -1
897EVT: 1:fileOpened=0 "d:\\work\\vimWrapper\\vimWrapper2\\pyvimwrapper\\tests\\testfile1.txt" T F
898CMD 4: (1) initDone
899FUN 5: (0) getCursor
900REP 5: 1 1 0 0
901CMD 6: (2) create
902CMD 7: (2) setTitle "testfile2.txt"
903CMD 8: (2) setFullName "testfile2.txt"
904EVT(suppressed): 2:remove=8 0 -1
905EVT: 2:fileOpened=0 "d:\\work\\vimWrapper\\vimWrapper2\\pyvimwrapper\\tests\\testfile2.txt" T F
906CMD 9: (2) initDone
907
908
909==============================================================================
91010. NetBeans External Editor
911
912NOTE: This information is obsolete! Only relevant if you are using an old
913version of NetBeans.
914
915
91610.1. Downloading NetBeans *netbeans-download*
917
918The NetBeans IDE is available for download from netbeans.org. You can download
919a released version, download sources, or use CVS to download the current
920source tree. If you choose to download sources, follow directions from
921netbeans.org on building NetBeans.
922
923Depending on the version of NetBeans you download, you may need to do further
924work to get the required External Editor module. This is the module which lets
925NetBeans work with gvim (or xemacs :-). See http://externaleditor.netbeans.org
926for details on downloading this module if your NetBeans release does not have
927it.
928
929For C, C++, and Fortran support you will also need the cpp module. See
930http://cpp.netbeans.org for information regarding this module.
931
932You can also download Sun ONE Studio from Sun Microsystems, Inc for a 30 day
933free trial. See http://www.sun.com for further details.
934
935
93610.2. NetBeans Key Bindings *netbeans-keybindings*
937
938Vim understands a number of key bindings that execute NetBeans commands.
939These are typically all the Function key combinations. To execute a NetBeans
940command, the user must press the Pause key followed by a NetBeans key binding.
941For example, in order to compile a Java file, the NetBeans key binding is
942"F9". So, while in vim, press "Pause F9" to compile a java file. To toggle a
943breakpoint at the current line, press "Pause Shift F8".
944
945The Pause key is Function key 21. If you don't have a working Pause key and
946want to use F8 instead, use: >
947
948 :map <F8> <F21>
949
950The External Editor module dynamically reads the NetBeans key bindings so vim
951should always have the latest key bindings, even when NetBeans changes them.
952
953
95410.3. Preparing NetBeans for Vim *netbeans-preparation*
955
956In order for NetBeans to work with vim, the NetBeans External Editor module
957must be loaded and enabled. If you have a Sun ONE Studio Enterprise Edition
958then this module should be loaded and enabled. If you have a NetBeans release
959you may need to find another way of obtaining this open source module.
960
961You can check if you have this module by opening the Tools->Options dialog
962and drilling down to the "Modules" list (IDE Configuration->System->Modules).
963If your Modules list has an entry for "External Editor" you must make sure
964it is enabled (the "Enabled" property should have the value "True"). If your
965Modules list has no External Editor see the next section on |obtaining-exted|.
966
967
96810.4. Obtaining the External Editor Module *obtaining-exted*
969
970There are 2 ways of obtaining the External Editor module. The easiest way
971is to use the NetBeans Update Center to download and install the module.
972Unfortunately, some versions do not have this module in their update
973center. If you cannot download via the update center you will need to
974download sources and build the module. I will try and get the module
975available from the NetBeans Update Center so building will be unnecessary.
976Also check http://externaleditor.netbeans.org for other availability options.
977
978To download the External Editor sources via CVS and build your own module,
979see http://externaleditor.netbeans.org and http://www.netbeans.org.
980Unfortunately, this is not a trivial procedure.
981
982
98310.5. Setting up NetBeans to run with Vim *netbeans-setup*
984
985Assuming you have loaded and enabled the NetBeans External Editor module
986as described in |netbeans-preparation| all you need to do is verify that
987the gvim command line is properly configured for your environment.
988
989Open the Tools->Options dialog and open the Editing category. Select the
990External Editor. The right hand pane should contain a Properties tab and
991an Expert tab. In the Properties tab make sure the "Editor Type" is set
992to "Vim". In the Expert tab make sure the "Vim Command" is correct.
993
994You should be careful if you change the "Vim Command". There are command
995line options there which must be there for the connection to be properly
996set up. You can change the command name but that's about it. If your gvim
997can be found by your $PATH then the VIM Command can start with "gvim". If
998you don't want gvim searched from your $PATH then hard code in the full
999Unix path name. At this point you should get a gvim for any source file
1000you open in NetBeans.
1001
1002If some files come up in gvim and others (with different file suffixes) come
1003up in the default NetBeans editor you should verify the MIME type in the
1004Expert tab MIME Type property. NetBeans is MIME oriented and the External
1005Editor will only open MIME types specified in this property.
1006
1007
Bram Moolenaar071d4272004-06-13 20:20:40 +00001008 vim:tw=78:ts=8:ft=help:norl: