blob: 4d109a5bab5391f7be154b9cb1c3b171a5886d14 [file] [log] [blame]
Bram Moolenaar7f036442010-08-15 15:24:20 +02001*netbeans.txt* For Vim version 7.3. Last change: 2010 Jul 20
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 Moolenaar3577c6f2008-06-24 21:16:56 +00007 *socket-interface* *netbeans* *netbeans-support*
8
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
121by GVim when it is run with one of the following GUIs: GTK, GNOME, and Motif.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000122
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000123If Motif support is required the user must supply XPM libraries. See
Bram Moolenaar071d4272004-06-13 20:20:40 +0000124|workshop-xpm| for details on obtaining the latest version of XPM.
125
126
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000127On MS-Windows:
128--------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000129
130The Win32 support is now in beta stage.
131
132To use XPM signs on Win32 (e.g. when using with NetBeans) you can compile
133XPM by yourself or use precompiled libraries from http://iamphet.nm.ru/misc/
134(for MS Visual C++) or http://gnuwin32.sourceforge.net (for MinGW).
135
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000136Enable debugging:
137-----------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000138
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000139To enable debugging of Vim and of the NetBeans protocol, the "NBDEBUG" macro
140needs to be defined. Search in the Makefile of the platform you are using for
141"NBDEBUG" to see what line needs to be uncommented. This effectively adds
142"-DNBDEBUG" to the compile command. Also see |netbeans-debugging|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000143
144==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00001454. Error Messages *netbeans-messages*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000146
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000147These error messages are specific to NetBeans socket protocol:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148
149 *E463*
150Region is guarded, cannot modify
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000151 The Vim Controller has defined guarded areas in the text,
152 which you cannot change. Also sets the current buffer, if
153 necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000154
Bram Moolenaar67c53842010-05-22 18:28:27 +0200155 *E532*
156The defineAnnoType highlighting color name is too long
157 The maximum length of the "fg" or "bg" color argument in the
158 defineAnnoType command is 32 characters.
159 New in version 2.5.
160
Bram Moolenaar071d4272004-06-13 20:20:40 +0000161 *E656*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000162Writes of unmodified buffers forbidden
163 Writes of unmodified buffers that were opened from the
164 Vim Controller are not possible.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000165
166 *E657*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000167Partial writes disallowed
168 Partial writes for buffers that were opened from the
169 Vim Controller are not allowed.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000170
171 *E658*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000172Connection lost for this buffer
173 The Vim Controller has become confused about the state of
174 this file. Rather than risk data corruption, it has severed
175 the connection for this file. Vim will take over
176 responsibility for saving changes to this file and the
177 Vim Controller will no longer know of these changes.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000178
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000179 *E744*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000180Read-only file
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000181 Vim normally allows changes to a read-only file and only
182 enforces the read-only rule if you try to write the file.
183 However, NetBeans does not let you make changes to a file
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000184 which is read-only and becomes confused if Vim does this.
185 So Vim does not allow modifications to files when run
186 in NetBeans mode.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000187
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000188==============================================================================
1895. Running Vim in NetBeans mode *netbeans-run*
190
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200191There are two different ways to run Vim in NetBeans mode:
192
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200193 + an IDE may start Vim with the |-nb| command line argument
194 + NetBeans can be started from within Vim with the |:nbstart| command
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200195
196 *netbeans-parameters*
197Three forms can be used to setup the NetBeans connection parameters.
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200198When started from the command line, the |-nb| command line argument may be:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000199
200 -nb={fname} from a file
201 -nb:{hostname}:{addr}:{password} directly
202 -nb from a file or environment
203
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200204When started from within Vim, the |:nbstart| optional argument may be:
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200205
206 ={fname} from a file
207 :{hostname}:{addr}:{password} directly
208 <MISSING ARGUMENT> from a file or environment
209
Bram Moolenaar071d4272004-06-13 20:20:40 +0000210 *E660* *E668*
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200211When NetBeans is started from the command line, for security reasons, the best
212method is to write the information in a file readable only by the user. The
213name of the file can be passed with the "-nb={fname}" argument or, when "-nb"
214is used without a parameter, the environment variable "__NETBEANS_CONINFO".
215The file must contain these three lines, in any order:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000216
217 host={hostname}
218 port={addr}
219 auth={password}
220
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200221Other lines are ignored. The Vim Controller is responsible for deleting the
Bram Moolenaar071d4272004-06-13 20:20:40 +0000222file afterwards.
223
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000224{hostname} is the name of the machine where Vim Controller is running. When
225omitted the environment variable "__NETBEANS_HOST" is used or the default
226"localhost".
Bram Moolenaar071d4272004-06-13 20:20:40 +0000227
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000228{addr} is the port number for the NetBeans interface. When omitted the
229environment variable "__NETBEANS_SOCKET" is used or the default 3219.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000230
231{password} is the password for connecting to NetBeans. When omitted the
232environment variable "__NETBEANS_VIM_PASSWORD" is used or "changeme".
233
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000234Vim will initiate a socket connection (client side) to the specified host and
235port upon startup. The password will be sent with the AUTH event when the
236connection has been established.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000237
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000238
239==============================================================================
2406. NetBeans protocol *netbeans-protocol*
241
242The communication between the Vim Controller and Vim uses plain text
243messages. This protocol was first designed to work with the external editor
244module of NetBeans. Later it was extended to work with Agide (A-A-P GUI IDE,
245see http://www.a-a-p.org) and then with other IDE. The extensions are marked
246with "version 2.1".
Bram Moolenaar071d4272004-06-13 20:20:40 +0000247
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000248Version 2.2 of the protocol has several minor changes which should only affect
249NetBeans users (ie, not Agide users). However, a bug was fixed which could
250cause confusion. The netbeans_saved() function sent a "save" protocol
251command. In protocol version 2.1 and earlier this was incorrectly interpreted
252as a notification that a write had taken place. In reality, it told NetBeans
253to save the file so multiple writes were being done. This caused various
254problems and has been fixed in 2.2. To decrease the likelihood of this
Bram Moolenaar071d4272004-06-13 20:20:40 +0000255confusion happening again, netbeans_saved() has been renamed to
256netbeans_save_buffer().
257
Bram Moolenaar67c53842010-05-22 18:28:27 +0200258We are now at version 2.5. For the differences between 2.4 and 2.5 search for
259"2.5" below.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000260
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261The messages are currently sent over a socket. Since the messages are in
262plain UTF-8 text this protocol could also be used with any other communication
263mechanism.
264
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00002656.1 Kinds of messages |nb-messages|
2666.2 Terms |nb-terms|
2676.3 Commands |nb-commands|
2686.4 Functions and Replies |nb-functions|
2696.5 Events |nb-events|
2706.6 Special messages |nb-special|
2716.7 Protocol errors |nb-protocol_errors|
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000272
273
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00002746.1 Kinds of messages *nb-messages*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000275
276There are four kinds of messages:
277
278kind direction comment ~
279Command IDE -> editor no reply necessary
280Function IDE -> editor editor must send back a reply
281Reply editor -> IDE only in response to a Function
282Event editor -> IDE no reply necessary
283
284The messages are sent as a single line with a terminating newline character.
285Arguments are separated by a single space. The first item of the message
286depends on the kind of message:
287
288kind first item example ~
289Command bufID:name!seqno 11:showBalloon!123 "text"
290Function bufID:name/seqno 11:getLength/123
291Reply seqno 123 5000
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000292Event bufID:name=seqno 11:keyCommand=123 "S-F2"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000293
294
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000295
2966.2 Terms *nb-terms*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000297
298bufID Buffer number. A message may be either for a specific buffer
299 or generic. Generic messages use a bufID of zero. NOTE: this
300 buffer ID is assigned by the IDE, it is not Vim's buffer
301 number. The bufID must be a sequentially rising number,
302 starting at one.
303
304seqno The IDE uses a sequence number for Commands and Functions. A
305 Reply must use the sequence number of the Function that it is
306 associated with. A zero sequence number can be used for
307 Events (the seqno of the last received Command or Function can
308 also be used).
309
310string Argument in double quotes. Text is in UTF-8 encoding. This
311 means ASCII is passed as-is. Special characters are
312 represented with a backslash:
313 \" double quote
314 \n newline
315 \r carriage-return
316 \t tab (optional, also works literally)
317 \\ backslash
318 NUL bytes are not allowed!
319
320boolean Argument with two possible values:
321 T true
322 F false
323
324number Argument with a decimal number.
325
Bram Moolenaar67c53842010-05-22 18:28:27 +0200326color Argument with either a decimal number, "none" (without the
327 quotes) or the name of a color (without the quotes) defined
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200328 both in the color list in |highlight-ctermfg| and in the color
329 list in |gui-colors|.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200330 New in version 2.5.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000331
332offset A number argument that indicates a byte position in a buffer.
333 The first byte has offset zero. Line breaks are counted for
334 how they appear in the file (CR/LF counts for two bytes).
335 Note that a multi-byte character is counted for the number of
336 bytes it takes.
337
338lnum/col Argument with a line number and column number position. The
339 line number starts with one, the column is the byte position,
340 starting with zero. Note that a multi-byte character counts
341 for several columns.
342
343pathname String argument: file name with full path.
344
345
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00003466.3 Commands *nb-commands*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000347
348actionMenuItem Not implemented.
349
350actionSensitivity
351 Not implemented.
352
353addAnno serNum typeNum off len
354 Place an annotation in this buffer.
355 Arguments:
356 serNum number serial number of this placed
357 annotation, used to be able to remove
358 it
359 typeNum number sequence number of the annotation
360 defined with defineAnnoType for this
361 buffer
362 off number offset where annotation is to be placed
363 len number not used
364 In version 2.1 "lnum/col" can be used instead of "off".
365
366balloonResult text
367 Not implemented.
368
369close Close the buffer. This leaves us without current buffer, very
370 dangerous to use!
371
372create Creates a buffer without a name. Replaces the current buffer
373 (it's hidden when it was changed).
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000374 The Vim Controller should use this as the first command for a
375 file that is being opened. The sequence of commands could be:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000376 create
377 setCaretListener (ignored)
378 setModified (no effect)
379 setContentType (ignored)
380 startDocumentListen
381 setTitle
382 setFullName
383
384defineAnnoType typeNum typeName tooltip glyphFile fg bg
385 Define a type of annotation for this buffer.
386 Arguments:
387 typeNum number sequence number (not really used)
388 typeName string name that identifies this annotation
389 tooltip string not used
390 glyphFile string name of icon file
Bram Moolenaar67c53842010-05-22 18:28:27 +0200391 fg color foreground color for line highlighting
392 bg color background color for line highlighting
Bram Moolenaar071d4272004-06-13 20:20:40 +0000393 Vim will define a sign for the annotation.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200394 When color is a number, this is the "#rrggbb" Red, Green and
395 Blue values of the color (see |gui-colors|) and the
396 highlighting is only defined for GVim.
397 When color is a name, this color is defined both for Vim
398 running in a color terminal and for GVim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000399 When both "fg" and "bg" are "none" no line highlighting is
400 used (new in version 2.1).
401 When "glyphFile" is empty, no text sign is used (new in
402 version 2.1).
403 When "glyphFile" is one or two characters long, a text sign is
404 defined (new in version 2.1).
405 Note: the annotations will be defined in sequence, and the
406 sequence number is later used with addAnno.
407
408editFile pathname
409 Set the name for the buffer and edit the file "pathname", a
410 string argument.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000411 Normal way for the IDE to tell the editor to edit a file.
412
413 You must set a bufId different of 0 with this command to
414 assign a bufId to the buffer. It will trigger an event
415 fileOpened with a bufId of 0 but the buffer has been assigned.
416
417 If the IDE is going to pass the file text to the editor use
418 these commands instead:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000419 setFullName
420 insert
421 initDone
422 New in version 2.1.
423
424enableBalloonEval
425 Not implemented.
426
427endAtomic 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.
430
431guard off len
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
434 to be guarded.
435
436initDone Mark the buffer as ready for use. Implicitly makes the buffer
437 the current buffer. Fires the BufReadPost autocommand event.
438
Bram Moolenaar009b2592004-10-24 19:18:58 +0000439insertDone
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000440 Sent by Vim Controller to tell Vim an initial file insert is
441 done. This triggers a read message being printed. Prior to
442 version 2.3, no read messages were displayed after opening a
443 file. New in version 2.3.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000444
Bram Moolenaar071d4272004-06-13 20:20:40 +0000445moveAnnoToFront serNum
446 Not implemented.
447
448netbeansBuffer isNetbeansBuffer
Bram Moolenaarc236c162008-07-13 17:41:49 +0000449 If "isNetbeansBuffer" is "T" then this buffer is "owned" by
Bram Moolenaar071d4272004-06-13 20:20:40 +0000450 NetBeans.
451 New in version 2.2.
452
453putBufferNumber 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.
459 New in version 2.1.
460
461raise Bring the editor to the foreground.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200462 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000463 New in version 2.1.
464
465removeAnno serNum
466 Remove a previously place annotation for this buffer.
467 "serNum" is the same number used in addAnno.
468
469save Save the buffer when it was modified. The other side of the
470 interface is expected to write the buffer and invoke
471 "setModified" to reset the "changed" flag of the buffer.
472 The writing is skipped when one of these conditions is true:
473 - 'write' is not set
474 - the buffer is read-only
475 - the buffer does not have a file name
476 - 'buftype' disallows writing
477 New in version 2.2.
478
Bram Moolenaar009b2592004-10-24 19:18:58 +0000479saveDone
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000480 Sent by Vim Controller to tell Vim a save is done. This
481 triggers a save message being printed. Prior to version 2.3,
482 no save messages were displayed after a save.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000483 New in version 2.3.
484
Bram Moolenaar071d4272004-06-13 20:20:40 +0000485setAsUser Not implemented.
486
487setBufferNumber pathname
488 Associate a buffer number with Vim buffer by the name
489 "pathname". To be used when the editor reported editing
490 another file to the IDE and the IDE needs to tell the editor
491 what buffer number it will use for this file.
492 Has the side effect of making the buffer the current buffer.
493 See "putBufferNumber" for a more useful command.
494
495setContentType
496 Not implemented.
497
498setDot off Make the buffer the current buffer and set the cursor at the
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000499 specified position. If the buffer is open in another window
500 than make that window the current window.
501 If there are folds they are opened to make the cursor line
502 visible.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000503 In version 2.1 "lnum/col" can be used instead of "off".
504
505setExitDelay seconds
506 Set the delay for exiting to "seconds", a number.
507 This delay is used to give the IDE a chance to handle things
508 before really exiting. The default delay is two seconds.
509 New in version 2.1.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000510 Obsolete in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000511
512setFullName pathname
513 Set the file name to be used for a buffer to "pathname", a
514 string argument.
515 Used when the IDE wants to edit a file under control of the
516 IDE. This makes the buffer the current buffer, but does not
517 read the file. "insert" commands will be used next to set the
518 contents.
519
520setLocAndSize Not implemented.
521
522setMark Not implemented.
523
524setModified modified
525 When the boolean argument "modified" is "T" mark the buffer as
526 modified, when it is "F" mark it as unmodified.
527
Bram Moolenaar009b2592004-10-24 19:18:58 +0000528setModtime time
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000529 Update a buffers modification time after the file has been
530 saved directly by the Vim Controller.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000531 New in version 2.3.
532
533setReadOnly
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000534 Set a file as readonly
535 Implemented in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000536
537setStyle Not implemented.
538
539setTitle name
540 Set the title for the buffer to "name", a string argument.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000541 The title is only used for the Vim Controller functions, not
542 by Vim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000543
544setVisible visible
545 When the boolean argument "visible" is "T", goto the buffer.
546 The "F" argument does nothing.
547
548showBalloon text
549 Show a balloon (popup window) at the mouse pointer position,
550 containing "text", a string argument. The balloon should
551 disappear when the mouse is moved more than a few pixels.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200552 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000553 New in version 2.1.
554
Bram Moolenaar009b2592004-10-24 19:18:58 +0000555specialKeys
556 Map a set of keys (mostly function keys) to be passed back
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000557 to the Vim Controller for processing. This lets regular IDE
558 hotkeys be used from Vim.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000559 Implemented in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560
561startAtomic Begin an atomic operation. The screen will not be updated
562 until "endAtomic" is given.
563
564startCaretListen
565 Not implemented.
566
567startDocumentListen
568 Mark the buffer to report changes to the IDE with the
569 "insert" and "remove" events. The default is to report
570 changes.
571
572stopCaretListen
573 Not implemented.
574
575stopDocumentListen
576 Mark the buffer to stop reporting changes to the IDE.
577 Opposite of startDocumentListen.
Bram Moolenaar748bf032005-02-02 23:04:36 +0000578 NOTE: if "netbeansBuffer" was used to mark this buffer as a
579 NetBeans buffer, then the buffer is deleted in Vim. This is
580 for compatibility with Sun Studio 10.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000581
582unguard off len
583 Opposite of "guard", remove guarding for a text area.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000584 Also sets the current buffer, if necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000585
586version Not implemented.
587
588
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00005896.4 Functions and Replies *nb-functions*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000590
591getDot Not implemented.
592
593getCursor Return the current buffer and cursor position.
594 The reply is:
595 seqno bufID lnum col off
596 seqno = sequence number of the function
597 bufID = buffer ID of the current buffer (if this is unknown -1
598 is used)
599 lnum = line number of the cursor (first line is one)
600 col = column number of the cursor (in bytes, zero based)
601 off = offset of the cursor in the buffer (in bytes)
602 New in version 2.1.
603
604getLength Return the length of the buffer in bytes.
605 Reply example for a buffer with 5000 bytes:
606 123 5000
607 TODO: explain use of partial line.
608
609getMark Not implemented.
610
Bram Moolenaarc65c4912006-11-14 17:29:46 +0000611getAnno serNum
612 Return the line number of the annotation in the buffer.
613 Argument:
614 serNum serial number of this placed annotation
615 The reply is:
616 123 lnum line number of the annotation
617 123 0 invalid annotation serial number
618 New in version 2.4.
619
Bram Moolenaar071d4272004-06-13 20:20:40 +0000620getModified When a buffer is specified: Return zero if the buffer does not
621 have changes, one if it does have changes.
622 When no buffer is specified (buffer number zero): Return the
623 number of buffers with changes. When the result is zero it's
624 safe to tell Vim to exit.
625 New in version 2.1.
626
627getText Return the contents of the buffer as a string.
628 Reply example for a buffer with two lines
629 123 "first line\nsecond line\n"
630 NOTE: docs indicate an offset and length argument, but this is
631 not implemented.
632
633insert off text
634 Insert "text" before position "off". "text" is a string
635 argument, "off" a number.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000636 "text" should have a "\n" (newline) at the end of each line.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000637 Or "\r\n" when 'fileformat' is "dos". When using "insert" in
638 an empty buffer Vim will set 'fileformat' accordingly.
639 When "off" points to the start of a line the text is inserted
640 above this line. Thus when "off" is zero lines are inserted
641 before the first line.
642 When "off" points after the start of a line, possibly on the
643 NUL at the end of a line, the first line of text is appended
644 to this line. Further lines come below it.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000645 Possible replies:
646 123 no problem
647 123 !message failed
648 Note that the message in the reply is not quoted.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000649 Also sets the current buffer, if necessary.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000650 Does not move the cursor to the changed text.
651 Resets undo information.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000652
653remove off length
654 Delete "length" bytes of text at position "off". Both
655 arguments are numbers.
656 Possible replies:
657 123 no problem
658 123 !message failed
659 Note that the message in the reply is not quoted.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000660 Also sets the current buffer, if necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000661
662saveAndExit Perform the equivalent of closing Vim: ":confirm qall".
663 If there are no changed files or the user does not cancel the
664 operation Vim exits and no result is sent back. The IDE can
665 consider closing the connection as a successful result.
666 If the user cancels the operation the number of modified
667 buffers that remains is returned and Vim does not exit.
668 New in version 2.1.
669
670
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00006716.5 Events *nb-events*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000672
673balloonEval off len type
674 The mouse pointer rests on text for a short while. When "len"
675 is zero, there is no selection and the pointer is at position
676 "off". When "len" is non-zero the text from position "off" to
677 "off" + "len" is selected.
678 Only sent after "enableBalloonEval" was used for this buffer.
679 "type" is not yet defined.
680 Not implemented yet.
681
682balloonText text
683 Used when 'ballooneval' is set and the mouse pointer rests on
684 some text for a moment. "text" is a string, the text under
685 the mouse pointer.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200686 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000687 New in version 2.1.
688
689buttonRelease button lnum col
690 Report which button was pressed and the location of the cursor
691 at the time of the release. Only for buffers that are owned
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000692 by the Vim Controller. This event is not sent if the button
693 was released while the mouse was in the status line or in a
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000694 separator line. If col is less than 1 the button release was
Bram Moolenaar071d4272004-06-13 20:20:40 +0000695 in the sign area.
696 New in version 2.2.
697
Bram Moolenaar009b2592004-10-24 19:18:58 +0000698disconnect
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000699 Tell the Vim Controller that Vim is exiting and not to try and
700 read or write more commands.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000701 New in version 2.3.
702
Bram Moolenaar071d4272004-06-13 20:20:40 +0000703fileClosed Not implemented.
704
705fileModified Not implemented.
706
707fileOpened pathname open modified
708 A file was opened by the user.
709 Arguments:
710 pathname string name of the file
711 open boolean always "T"
712 modified boolean always "F"
713
714geometry cols rows x y
715 Report the size and position of the editor window.
716 Arguments:
717 cols number number of text columns
718 rows number number of text rows
719 x number pixel position on screen
720 y number pixel position on screen
721 Only works for Motif.
722
723insert off text
724 Text "text" has been inserted in Vim at position "off".
725 Only fired when enabled, see "startDocumentListen".
726
727invokeAction Not implemented.
728
729keyCommand keyName
730 Reports a special key being pressed with name "keyName", which
731 is a string.
732 Supported key names:
733 F1 function key 1
734 F2 function key 2
735 ...
736 F12 function key 12
737
738 ' ' space (without the quotes)
739 ! exclamation mark
740 ... any other ASCII printable character
741 ~ tilde
742
743 X any unrecognized key
744
745 The key may be prepended by "C", "S" and/or "M" for Control,
746 Shift and Meta (Alt) modifiers. If there is a modifier a dash
747 is used to separate it from the key name. For example:
748 "C-F2".
749 ASCII characters are new in version 2.1.
750
751keyAtPos keyName lnum/col
752 Like "keyCommand" and also report the line number and column
753 of the cursor.
754 New in version 2.1.
755
Bram Moolenaard7f8f5c2009-01-06 15:14:30 +0000756killed A file was deleted or wiped out by the user and the buffer
757 annotations have been removed. The bufID number for this
758 buffer has become invalid. Only for files that have been
759 assigned a bufID number by the IDE.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000760
761newDotAndMark off off
762 Reports the position of the cursor being at "off" bytes into
763 the buffer. Only sent just before a "keyCommand" event.
764
765quit Not implemented.
766
767remove off len
768 Text was deleted in Vim at position "off" with byte length
769 "len".
770 Only fired when enabled, see "startDocumentListen".
771
772revert Not implemented.
773
774save The buffer has been saved and is now unmodified.
775 Only fired when enabled, see "startDocumentListen".
776
777startupDone The editor has finished its startup work and is ready for
778 editing files.
779 New in version 2.1.
780
781unmodified The buffer is now unmodified.
782 Only fired when enabled, see "startDocumentListen".
783
784version vers Report the version of the interface implementation. Vim
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000785 reports "2.4" (including the quotes).
Bram Moolenaar071d4272004-06-13 20:20:40 +0000786
787
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00007886.6 Special messages *nb-special*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000789
790These messages do not follow the style of the messages above. They are
791terminated by a newline character.
792
793ACCEPT Not used.
794
795AUTH password editor -> IDE: First message that the editor sends to the IDE.
796 Must contain the password for the socket server, as specified
797 with the |-nb| argument. No quotes are used!
798
799DISCONNECT IDE -> editor: break the connection. The editor will exit.
800 The IDE must only send this message when there are no unsaved
801 changes!
802
803DETACH IDE -> editor: break the connection without exiting the
804 editor. Used when the IDE exits without bringing down the
805 editor as well.
806 New in version 2.1.
807
808REJECT Not used.
809
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000810
8116.7 Protocol errors *nb-protocol_errors*
812
813These errors occur when a message violates the protocol:
814*E627* *E628* *E629* *E630* *E631* *E632* *E633* *E634* *E635* *E636*
815*E637* *E638* *E639* *E640* *E641* *E642* *E643* *E644* *E645* *E646*
816*E647* *E648* *E649* *E650* *E651* *E652* *E653* *E654*
817
818
Bram Moolenaar071d4272004-06-13 20:20:40 +0000819==============================================================================
Bram Moolenaarb26e6322010-05-22 21:34:09 +02008207. NetBeans commands *netbeans-commands*
821
822 *:nbstart* *E511*
823:nbs[tart] {connection} Start a new Netbeans session with {connection} as the
824 socket connection parameters. The format of
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200825 {connection} is described in |netbeans-parameters|.
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200826 At any time, one may check if the netbeans socket is
827 connected by running the command:
828 ':echo has("netbeans_enabled")'
829
830 *:nbclose*
831:nbc[lose] Close the current NetBeans session. Remove all placed
832 signs.
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000833
834 *:nbkey*
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200835:nb[key] {key} Pass the {key} to the Vim Controller for processing
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000836
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000837When a hot-key has been installed with the specialKeys command, this command
838can be used to generate a hotkey messages to the Vim Controller. The events
839newDotAndMark, keyCommand and keyAtPos are generated (in this order).
840
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000841
842==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00008438. Known problems *netbeans-problems*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000844
845NUL bytes are not possible. For editor -> IDE they will appear as NL
846characters. For IDE -> editor they cannot be inserted.
847
Bram Moolenaar67c53842010-05-22 18:28:27 +0200848A NetBeans session may be initiated with Vim running in a terminal, and
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200849continued later in a GUI environment after running the |:gui| command. In this
Bram Moolenaar67c53842010-05-22 18:28:27 +0200850case, the highlighting defined for the NetBeans annotations may be cleared
851when the ":gui" command sources .gvimrc and this file loads a colorscheme
852that runs the command ":highlight clear".
853New in version 2.5.
854
Bram Moolenaar071d4272004-06-13 20:20:40 +0000855
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000856==============================================================================
8579. Debugging NetBeans protocol *netbeans-debugging*
858
859To debug the Vim protocol, you must first compile Vim with debugging support
860and NetBeans debugging support. See |netbeans-configure| for instructions
861about Vim compiling and how to enable debug support.
862
863When running Vim, set the following environment variables:
864
865 export SPRO_GVIM_DEBUG=netbeans.log
866 export SPRO_GVIM_DLEVEL=0xffffffff
867
868Vim will then log all the incoming and outgoing messages of the NetBeans
869protocol to the file netbeans.log .
870
871The content of netbeans.log after a session looks like this:
872Tue May 20 17:19:27 2008
873EVT: 0:startupDone=0
874CMD 1: (1) create
875CMD 2: (1) setTitle "testfile1.txt"
876CMD 3: (1) setFullName "testfile1.txt"
877EVT(suppressed): 1:remove=3 0 -1
878EVT: 1:fileOpened=0 "d:\\work\\vimWrapper\\vimWrapper2\\pyvimwrapper\\tests\\testfile1.txt" T F
879CMD 4: (1) initDone
880FUN 5: (0) getCursor
881REP 5: 1 1 0 0
882CMD 6: (2) create
883CMD 7: (2) setTitle "testfile2.txt"
884CMD 8: (2) setFullName "testfile2.txt"
885EVT(suppressed): 2:remove=8 0 -1
886EVT: 2:fileOpened=0 "d:\\work\\vimWrapper\\vimWrapper2\\pyvimwrapper\\tests\\testfile2.txt" T F
887CMD 9: (2) initDone
888
889
890==============================================================================
89110. NetBeans External Editor
892
893NOTE: This information is obsolete! Only relevant if you are using an old
894version of NetBeans.
895
896
89710.1. Downloading NetBeans *netbeans-download*
898
899The NetBeans IDE is available for download from netbeans.org. You can download
900a released version, download sources, or use CVS to download the current
901source tree. If you choose to download sources, follow directions from
902netbeans.org on building NetBeans.
903
904Depending on the version of NetBeans you download, you may need to do further
905work to get the required External Editor module. This is the module which lets
906NetBeans work with gvim (or xemacs :-). See http://externaleditor.netbeans.org
907for details on downloading this module if your NetBeans release does not have
908it.
909
910For C, C++, and Fortran support you will also need the cpp module. See
911http://cpp.netbeans.org for information regarding this module.
912
913You can also download Sun ONE Studio from Sun Microsystems, Inc for a 30 day
914free trial. See http://www.sun.com for further details.
915
916
91710.2. NetBeans Key Bindings *netbeans-keybindings*
918
919Vim understands a number of key bindings that execute NetBeans commands.
920These are typically all the Function key combinations. To execute a NetBeans
921command, the user must press the Pause key followed by a NetBeans key binding.
922For example, in order to compile a Java file, the NetBeans key binding is
923"F9". So, while in vim, press "Pause F9" to compile a java file. To toggle a
924breakpoint at the current line, press "Pause Shift F8".
925
926The Pause key is Function key 21. If you don't have a working Pause key and
927want to use F8 instead, use: >
928
929 :map <F8> <F21>
930
931The External Editor module dynamically reads the NetBeans key bindings so vim
932should always have the latest key bindings, even when NetBeans changes them.
933
934
93510.3. Preparing NetBeans for Vim *netbeans-preparation*
936
937In order for NetBeans to work with vim, the NetBeans External Editor module
938must be loaded and enabled. If you have a Sun ONE Studio Enterprise Edition
939then this module should be loaded and enabled. If you have a NetBeans release
940you may need to find another way of obtaining this open source module.
941
942You can check if you have this module by opening the Tools->Options dialog
943and drilling down to the "Modules" list (IDE Configuration->System->Modules).
944If your Modules list has an entry for "External Editor" you must make sure
945it is enabled (the "Enabled" property should have the value "True"). If your
946Modules list has no External Editor see the next section on |obtaining-exted|.
947
948
94910.4. Obtaining the External Editor Module *obtaining-exted*
950
951There are 2 ways of obtaining the External Editor module. The easiest way
952is to use the NetBeans Update Center to download and install the module.
953Unfortunately, some versions do not have this module in their update
954center. If you cannot download via the update center you will need to
955download sources and build the module. I will try and get the module
956available from the NetBeans Update Center so building will be unnecessary.
957Also check http://externaleditor.netbeans.org for other availability options.
958
959To download the External Editor sources via CVS and build your own module,
960see http://externaleditor.netbeans.org and http://www.netbeans.org.
961Unfortunately, this is not a trivial procedure.
962
963
96410.5. Setting up NetBeans to run with Vim *netbeans-setup*
965
966Assuming you have loaded and enabled the NetBeans External Editor module
967as described in |netbeans-preparation| all you need to do is verify that
968the gvim command line is properly configured for your environment.
969
970Open the Tools->Options dialog and open the Editing category. Select the
971External Editor. The right hand pane should contain a Properties tab and
972an Expert tab. In the Properties tab make sure the "Editor Type" is set
973to "Vim". In the Expert tab make sure the "Vim Command" is correct.
974
975You should be careful if you change the "Vim Command". There are command
976line options there which must be there for the connection to be properly
977set up. You can change the command name but that's about it. If your gvim
978can be found by your $PATH then the VIM Command can start with "gvim". If
979you don't want gvim searched from your $PATH then hard code in the full
980Unix path name. At this point you should get a gvim for any source file
981you open in NetBeans.
982
983If some files come up in gvim and others (with different file suffixes) come
984up in the default NetBeans editor you should verify the MIME type in the
985Expert tab MIME Type property. NetBeans is MIME oriented and the External
986Editor will only open MIME types specified in this property.
987
988
Bram Moolenaar071d4272004-06-13 20:20:40 +0000989 vim:tw=78:ts=8:ft=help:norl: