blob: b7614e7f0d9833ebc182cb8fa37da81c550a37a2 [file] [log] [blame]
Bram Moolenaar15146672011-10-20 22:22:38 +02001*netbeans.txt* For Vim version 7.3. Last change: 2011 Oct 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
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
197 *netbeans-parameters*
198Three forms can be used to setup the NetBeans connection parameters.
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200199When started from the command line, the |-nb| command line argument may be:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000200
201 -nb={fname} from a file
202 -nb:{hostname}:{addr}:{password} directly
203 -nb from a file or environment
204
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200205When started from within Vim, the |:nbstart| optional argument may be:
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200206
207 ={fname} from a file
208 :{hostname}:{addr}:{password} directly
209 <MISSING ARGUMENT> from a file or environment
210
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211 *E660* *E668*
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200212When NetBeans is started from the command line, for security reasons, the best
213method is to write the information in a file readable only by the user. The
214name of the file can be passed with the "-nb={fname}" argument or, when "-nb"
215is used without a parameter, the environment variable "__NETBEANS_CONINFO".
216The file must contain these three lines, in any order:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000217
218 host={hostname}
219 port={addr}
220 auth={password}
221
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200222Other lines are ignored. The Vim Controller is responsible for deleting the
Bram Moolenaar071d4272004-06-13 20:20:40 +0000223file afterwards.
224
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000225{hostname} is the name of the machine where Vim Controller is running. When
226omitted the environment variable "__NETBEANS_HOST" is used or the default
227"localhost".
Bram Moolenaar071d4272004-06-13 20:20:40 +0000228
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000229{addr} is the port number for the NetBeans interface. When omitted the
230environment variable "__NETBEANS_SOCKET" is used or the default 3219.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000231
232{password} is the password for connecting to NetBeans. When omitted the
233environment variable "__NETBEANS_VIM_PASSWORD" is used or "changeme".
234
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000235Vim will initiate a socket connection (client side) to the specified host and
236port upon startup. The password will be sent with the AUTH event when the
237connection has been established.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000238
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000239
240==============================================================================
2416. NetBeans protocol *netbeans-protocol*
242
243The communication between the Vim Controller and Vim uses plain text
244messages. This protocol was first designed to work with the external editor
245module of NetBeans. Later it was extended to work with Agide (A-A-P GUI IDE,
246see http://www.a-a-p.org) and then with other IDE. The extensions are marked
247with "version 2.1".
Bram Moolenaar071d4272004-06-13 20:20:40 +0000248
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000249Version 2.2 of the protocol has several minor changes which should only affect
250NetBeans users (ie, not Agide users). However, a bug was fixed which could
251cause confusion. The netbeans_saved() function sent a "save" protocol
252command. In protocol version 2.1 and earlier this was incorrectly interpreted
253as a notification that a write had taken place. In reality, it told NetBeans
254to save the file so multiple writes were being done. This caused various
255problems and has been fixed in 2.2. To decrease the likelihood of this
Bram Moolenaar071d4272004-06-13 20:20:40 +0000256confusion happening again, netbeans_saved() has been renamed to
257netbeans_save_buffer().
258
Bram Moolenaar67c53842010-05-22 18:28:27 +0200259We are now at version 2.5. For the differences between 2.4 and 2.5 search for
260"2.5" below.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000261
Bram Moolenaar071d4272004-06-13 20:20:40 +0000262The messages are currently sent over a socket. Since the messages are in
263plain UTF-8 text this protocol could also be used with any other communication
264mechanism.
265
Bram Moolenaare3cc6d42011-10-20 21:58:34 +0200266Netbeans messages are processed when Vim is idle, waiting for user input.
267When Vim is run in non-interactive mode, for example when running an automated
268test case that sources a Vim script, the idle loop may not be called often
269enough. In that case, insert |sleep| commands in the Vim script. The |sleep|
270command does invoke Netbeans messages processing.
271
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00002726.1 Kinds of messages |nb-messages|
2736.2 Terms |nb-terms|
2746.3 Commands |nb-commands|
2756.4 Functions and Replies |nb-functions|
2766.5 Events |nb-events|
2776.6 Special messages |nb-special|
2786.7 Protocol errors |nb-protocol_errors|
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000279
280
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00002816.1 Kinds of messages *nb-messages*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000282
283There are four kinds of messages:
284
285kind direction comment ~
286Command IDE -> editor no reply necessary
287Function IDE -> editor editor must send back a reply
288Reply editor -> IDE only in response to a Function
289Event editor -> IDE no reply necessary
290
291The messages are sent as a single line with a terminating newline character.
292Arguments are separated by a single space. The first item of the message
293depends on the kind of message:
294
295kind first item example ~
296Command bufID:name!seqno 11:showBalloon!123 "text"
297Function bufID:name/seqno 11:getLength/123
298Reply seqno 123 5000
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000299Event bufID:name=seqno 11:keyCommand=123 "S-F2"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000300
301
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000302
3036.2 Terms *nb-terms*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000304
305bufID Buffer number. A message may be either for a specific buffer
306 or generic. Generic messages use a bufID of zero. NOTE: this
307 buffer ID is assigned by the IDE, it is not Vim's buffer
308 number. The bufID must be a sequentially rising number,
309 starting at one.
310
311seqno The IDE uses a sequence number for Commands and Functions. A
312 Reply must use the sequence number of the Function that it is
313 associated with. A zero sequence number can be used for
314 Events (the seqno of the last received Command or Function can
315 also be used).
316
317string Argument in double quotes. Text is in UTF-8 encoding. This
318 means ASCII is passed as-is. Special characters are
319 represented with a backslash:
320 \" double quote
321 \n newline
322 \r carriage-return
323 \t tab (optional, also works literally)
324 \\ backslash
325 NUL bytes are not allowed!
326
327boolean Argument with two possible values:
328 T true
329 F false
330
331number Argument with a decimal number.
332
Bram Moolenaar67c53842010-05-22 18:28:27 +0200333color Argument with either a decimal number, "none" (without the
334 quotes) or the name of a color (without the quotes) defined
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200335 both in the color list in |highlight-ctermfg| and in the color
336 list in |gui-colors|.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200337 New in version 2.5.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000338
339offset A number argument that indicates a byte position in a buffer.
340 The first byte has offset zero. Line breaks are counted for
341 how they appear in the file (CR/LF counts for two bytes).
342 Note that a multi-byte character is counted for the number of
343 bytes it takes.
344
345lnum/col Argument with a line number and column number position. The
346 line number starts with one, the column is the byte position,
347 starting with zero. Note that a multi-byte character counts
348 for several columns.
349
350pathname String argument: file name with full path.
351
352
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00003536.3 Commands *nb-commands*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000354
355actionMenuItem Not implemented.
356
357actionSensitivity
358 Not implemented.
359
360addAnno serNum typeNum off len
361 Place an annotation in this buffer.
362 Arguments:
363 serNum number serial number of this placed
364 annotation, used to be able to remove
365 it
366 typeNum number sequence number of the annotation
367 defined with defineAnnoType for this
368 buffer
369 off number offset where annotation is to be placed
370 len number not used
371 In version 2.1 "lnum/col" can be used instead of "off".
372
373balloonResult text
374 Not implemented.
375
376close Close the buffer. This leaves us without current buffer, very
377 dangerous to use!
378
379create Creates a buffer without a name. Replaces the current buffer
380 (it's hidden when it was changed).
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000381 The Vim Controller should use this as the first command for a
382 file that is being opened. The sequence of commands could be:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000383 create
384 setCaretListener (ignored)
385 setModified (no effect)
386 setContentType (ignored)
387 startDocumentListen
388 setTitle
389 setFullName
390
391defineAnnoType typeNum typeName tooltip glyphFile fg bg
392 Define a type of annotation for this buffer.
393 Arguments:
394 typeNum number sequence number (not really used)
395 typeName string name that identifies this annotation
396 tooltip string not used
397 glyphFile string name of icon file
Bram Moolenaar67c53842010-05-22 18:28:27 +0200398 fg color foreground color for line highlighting
399 bg color background color for line highlighting
Bram Moolenaar071d4272004-06-13 20:20:40 +0000400 Vim will define a sign for the annotation.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200401 When color is a number, this is the "#rrggbb" Red, Green and
402 Blue values of the color (see |gui-colors|) and the
403 highlighting is only defined for GVim.
404 When color is a name, this color is defined both for Vim
405 running in a color terminal and for GVim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000406 When both "fg" and "bg" are "none" no line highlighting is
407 used (new in version 2.1).
408 When "glyphFile" is empty, no text sign is used (new in
409 version 2.1).
410 When "glyphFile" is one or two characters long, a text sign is
411 defined (new in version 2.1).
412 Note: the annotations will be defined in sequence, and the
413 sequence number is later used with addAnno.
414
415editFile pathname
416 Set the name for the buffer and edit the file "pathname", a
417 string argument.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000418 Normal way for the IDE to tell the editor to edit a file.
419
420 You must set a bufId different of 0 with this command to
421 assign a bufId to the buffer. It will trigger an event
422 fileOpened with a bufId of 0 but the buffer has been assigned.
423
424 If the IDE is going to pass the file text to the editor use
425 these commands instead:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000426 setFullName
427 insert
428 initDone
429 New in version 2.1.
430
431enableBalloonEval
432 Not implemented.
433
434endAtomic End an atomic operation. The changes between "startAtomic"
435 and "endAtomic" can be undone as one operation. But it's not
436 implemented yet. Redraw when necessary.
437
438guard off len
439 Mark an area in the buffer as guarded. This means it cannot
440 be edited. "off" and "len" are numbers and specify the text
441 to be guarded.
442
443initDone Mark the buffer as ready for use. Implicitly makes the buffer
444 the current buffer. Fires the BufReadPost autocommand event.
445
Bram Moolenaar009b2592004-10-24 19:18:58 +0000446insertDone
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000447 Sent by Vim Controller to tell Vim an initial file insert is
448 done. This triggers a read message being printed. Prior to
449 version 2.3, no read messages were displayed after opening a
450 file. New in version 2.3.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000451
Bram Moolenaar071d4272004-06-13 20:20:40 +0000452moveAnnoToFront serNum
453 Not implemented.
454
455netbeansBuffer isNetbeansBuffer
Bram Moolenaarc236c162008-07-13 17:41:49 +0000456 If "isNetbeansBuffer" is "T" then this buffer is "owned" by
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457 NetBeans.
458 New in version 2.2.
459
460putBufferNumber pathname
461 Associate a buffer number with the Vim buffer by the name
462 "pathname", a string argument. To be used when the editor
463 reported editing another file to the IDE and the IDE needs to
464 tell the editor what buffer number it will use for this file.
465 Also marks the buffer as initialized.
466 New in version 2.1.
467
468raise Bring the editor to the foreground.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200469 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000470 New in version 2.1.
471
472removeAnno serNum
473 Remove a previously place annotation for this buffer.
474 "serNum" is the same number used in addAnno.
475
476save Save the buffer when it was modified. The other side of the
477 interface is expected to write the buffer and invoke
478 "setModified" to reset the "changed" flag of the buffer.
479 The writing is skipped when one of these conditions is true:
480 - 'write' is not set
481 - the buffer is read-only
482 - the buffer does not have a file name
483 - 'buftype' disallows writing
484 New in version 2.2.
485
Bram Moolenaar009b2592004-10-24 19:18:58 +0000486saveDone
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000487 Sent by Vim Controller to tell Vim a save is done. This
488 triggers a save message being printed. Prior to version 2.3,
489 no save messages were displayed after a save.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000490 New in version 2.3.
491
Bram Moolenaar071d4272004-06-13 20:20:40 +0000492setAsUser Not implemented.
493
494setBufferNumber pathname
495 Associate a buffer number with Vim buffer by the name
496 "pathname". To be used when the editor reported editing
497 another file to the IDE and the IDE needs to tell the editor
498 what buffer number it will use for this file.
499 Has the side effect of making the buffer the current buffer.
500 See "putBufferNumber" for a more useful command.
501
502setContentType
503 Not implemented.
504
505setDot off Make the buffer the current buffer and set the cursor at the
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000506 specified position. If the buffer is open in another window
507 than make that window the current window.
508 If there are folds they are opened to make the cursor line
509 visible.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000510 In version 2.1 "lnum/col" can be used instead of "off".
511
512setExitDelay seconds
513 Set the delay for exiting to "seconds", a number.
514 This delay is used to give the IDE a chance to handle things
515 before really exiting. The default delay is two seconds.
516 New in version 2.1.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000517 Obsolete in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000518
519setFullName pathname
520 Set the file name to be used for a buffer to "pathname", a
521 string argument.
522 Used when the IDE wants to edit a file under control of the
523 IDE. This makes the buffer the current buffer, but does not
524 read the file. "insert" commands will be used next to set the
525 contents.
526
527setLocAndSize Not implemented.
528
529setMark Not implemented.
530
531setModified modified
532 When the boolean argument "modified" is "T" mark the buffer as
533 modified, when it is "F" mark it as unmodified.
534
Bram Moolenaar009b2592004-10-24 19:18:58 +0000535setModtime time
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000536 Update a buffers modification time after the file has been
537 saved directly by the Vim Controller.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000538 New in version 2.3.
539
540setReadOnly
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000541 Set a file as readonly
542 Implemented in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000543
544setStyle Not implemented.
545
546setTitle name
547 Set the title for the buffer to "name", a string argument.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000548 The title is only used for the Vim Controller functions, not
549 by Vim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000550
551setVisible visible
552 When the boolean argument "visible" is "T", goto the buffer.
553 The "F" argument does nothing.
554
555showBalloon text
556 Show a balloon (popup window) at the mouse pointer position,
557 containing "text", a string argument. The balloon should
558 disappear when the mouse is moved more than a few pixels.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200559 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560 New in version 2.1.
561
Bram Moolenaar009b2592004-10-24 19:18:58 +0000562specialKeys
563 Map a set of keys (mostly function keys) to be passed back
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000564 to the Vim Controller for processing. This lets regular IDE
565 hotkeys be used from Vim.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000566 Implemented in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000567
568startAtomic Begin an atomic operation. The screen will not be updated
569 until "endAtomic" is given.
570
571startCaretListen
572 Not implemented.
573
574startDocumentListen
575 Mark the buffer to report changes to the IDE with the
576 "insert" and "remove" events. The default is to report
577 changes.
578
579stopCaretListen
580 Not implemented.
581
582stopDocumentListen
583 Mark the buffer to stop reporting changes to the IDE.
584 Opposite of startDocumentListen.
Bram Moolenaar748bf032005-02-02 23:04:36 +0000585 NOTE: if "netbeansBuffer" was used to mark this buffer as a
586 NetBeans buffer, then the buffer is deleted in Vim. This is
587 for compatibility with Sun Studio 10.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000588
589unguard off len
590 Opposite of "guard", remove guarding for a text area.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000591 Also sets the current buffer, if necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000592
593version Not implemented.
594
595
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00005966.4 Functions and Replies *nb-functions*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000597
598getDot Not implemented.
599
600getCursor Return the current buffer and cursor position.
601 The reply is:
602 seqno bufID lnum col off
603 seqno = sequence number of the function
604 bufID = buffer ID of the current buffer (if this is unknown -1
605 is used)
606 lnum = line number of the cursor (first line is one)
607 col = column number of the cursor (in bytes, zero based)
608 off = offset of the cursor in the buffer (in bytes)
609 New in version 2.1.
610
611getLength Return the length of the buffer in bytes.
612 Reply example for a buffer with 5000 bytes:
613 123 5000
614 TODO: explain use of partial line.
615
616getMark Not implemented.
617
Bram Moolenaarc65c4912006-11-14 17:29:46 +0000618getAnno serNum
619 Return the line number of the annotation in the buffer.
620 Argument:
621 serNum serial number of this placed annotation
622 The reply is:
623 123 lnum line number of the annotation
624 123 0 invalid annotation serial number
625 New in version 2.4.
626
Bram Moolenaar071d4272004-06-13 20:20:40 +0000627getModified When a buffer is specified: Return zero if the buffer does not
628 have changes, one if it does have changes.
629 When no buffer is specified (buffer number zero): Return the
630 number of buffers with changes. When the result is zero it's
631 safe to tell Vim to exit.
632 New in version 2.1.
633
634getText Return the contents of the buffer as a string.
635 Reply example for a buffer with two lines
636 123 "first line\nsecond line\n"
637 NOTE: docs indicate an offset and length argument, but this is
638 not implemented.
639
640insert off text
641 Insert "text" before position "off". "text" is a string
642 argument, "off" a number.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000643 "text" should have a "\n" (newline) at the end of each line.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000644 Or "\r\n" when 'fileformat' is "dos". When using "insert" in
645 an empty buffer Vim will set 'fileformat' accordingly.
646 When "off" points to the start of a line the text is inserted
647 above this line. Thus when "off" is zero lines are inserted
648 before the first line.
649 When "off" points after the start of a line, possibly on the
650 NUL at the end of a line, the first line of text is appended
651 to this line. Further lines come below it.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000652 Possible replies:
653 123 no problem
654 123 !message failed
655 Note that the message in the reply is not quoted.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000656 Also sets the current buffer, if necessary.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000657 Does not move the cursor to the changed text.
658 Resets undo information.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000659
660remove off length
661 Delete "length" bytes of text at position "off". Both
662 arguments are numbers.
663 Possible replies:
664 123 no problem
665 123 !message failed
666 Note that the message in the reply is not quoted.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000667 Also sets the current buffer, if necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000668
669saveAndExit Perform the equivalent of closing Vim: ":confirm qall".
670 If there are no changed files or the user does not cancel the
671 operation Vim exits and no result is sent back. The IDE can
672 consider closing the connection as a successful result.
673 If the user cancels the operation the number of modified
674 buffers that remains is returned and Vim does not exit.
675 New in version 2.1.
676
677
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00006786.5 Events *nb-events*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000679
680balloonEval off len type
681 The mouse pointer rests on text for a short while. When "len"
682 is zero, there is no selection and the pointer is at position
683 "off". When "len" is non-zero the text from position "off" to
684 "off" + "len" is selected.
685 Only sent after "enableBalloonEval" was used for this buffer.
686 "type" is not yet defined.
687 Not implemented yet.
688
689balloonText text
690 Used when 'ballooneval' is set and the mouse pointer rests on
691 some text for a moment. "text" is a string, the text under
692 the mouse pointer.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200693 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000694 New in version 2.1.
695
696buttonRelease button lnum col
697 Report which button was pressed and the location of the cursor
698 at the time of the release. Only for buffers that are owned
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000699 by the Vim Controller. This event is not sent if the button
700 was released while the mouse was in the status line or in a
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000701 separator line. If col is less than 1 the button release was
Bram Moolenaar071d4272004-06-13 20:20:40 +0000702 in the sign area.
703 New in version 2.2.
704
Bram Moolenaar009b2592004-10-24 19:18:58 +0000705disconnect
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000706 Tell the Vim Controller that Vim is exiting and not to try and
707 read or write more commands.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000708 New in version 2.3.
709
Bram Moolenaar071d4272004-06-13 20:20:40 +0000710fileClosed Not implemented.
711
712fileModified Not implemented.
713
714fileOpened pathname open modified
715 A file was opened by the user.
716 Arguments:
717 pathname string name of the file
718 open boolean always "T"
719 modified boolean always "F"
720
721geometry cols rows x y
722 Report the size and position of the editor window.
723 Arguments:
724 cols number number of text columns
725 rows number number of text rows
726 x number pixel position on screen
727 y number pixel position on screen
728 Only works for Motif.
729
730insert off text
731 Text "text" has been inserted in Vim at position "off".
732 Only fired when enabled, see "startDocumentListen".
733
734invokeAction Not implemented.
735
736keyCommand keyName
737 Reports a special key being pressed with name "keyName", which
738 is a string.
739 Supported key names:
740 F1 function key 1
741 F2 function key 2
742 ...
743 F12 function key 12
744
745 ' ' space (without the quotes)
746 ! exclamation mark
747 ... any other ASCII printable character
748 ~ tilde
749
750 X any unrecognized key
751
752 The key may be prepended by "C", "S" and/or "M" for Control,
753 Shift and Meta (Alt) modifiers. If there is a modifier a dash
754 is used to separate it from the key name. For example:
755 "C-F2".
756 ASCII characters are new in version 2.1.
757
758keyAtPos keyName lnum/col
759 Like "keyCommand" and also report the line number and column
760 of the cursor.
761 New in version 2.1.
762
Bram Moolenaard7f8f5c2009-01-06 15:14:30 +0000763killed A file was deleted or wiped out by the user and the buffer
764 annotations have been removed. The bufID number for this
765 buffer has become invalid. Only for files that have been
766 assigned a bufID number by the IDE.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000767
768newDotAndMark off off
769 Reports the position of the cursor being at "off" bytes into
770 the buffer. Only sent just before a "keyCommand" event.
771
772quit Not implemented.
773
774remove off len
775 Text was deleted in Vim at position "off" with byte length
776 "len".
777 Only fired when enabled, see "startDocumentListen".
778
779revert Not implemented.
780
781save The buffer has been saved and is now unmodified.
782 Only fired when enabled, see "startDocumentListen".
783
784startupDone The editor has finished its startup work and is ready for
785 editing files.
786 New in version 2.1.
787
788unmodified The buffer is now unmodified.
789 Only fired when enabled, see "startDocumentListen".
790
791version vers Report the version of the interface implementation. Vim
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000792 reports "2.4" (including the quotes).
Bram Moolenaar071d4272004-06-13 20:20:40 +0000793
794
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00007956.6 Special messages *nb-special*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000796
797These messages do not follow the style of the messages above. They are
798terminated by a newline character.
799
800ACCEPT Not used.
801
802AUTH password editor -> IDE: First message that the editor sends to the IDE.
803 Must contain the password for the socket server, as specified
804 with the |-nb| argument. No quotes are used!
805
806DISCONNECT IDE -> editor: break the connection. The editor will exit.
807 The IDE must only send this message when there are no unsaved
808 changes!
809
810DETACH IDE -> editor: break the connection without exiting the
811 editor. Used when the IDE exits without bringing down the
812 editor as well.
813 New in version 2.1.
814
815REJECT Not used.
816
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000817
8186.7 Protocol errors *nb-protocol_errors*
819
820These errors occur when a message violates the protocol:
821*E627* *E628* *E629* *E630* *E631* *E632* *E633* *E634* *E635* *E636*
822*E637* *E638* *E639* *E640* *E641* *E642* *E643* *E644* *E645* *E646*
823*E647* *E648* *E649* *E650* *E651* *E652* *E653* *E654*
824
825
Bram Moolenaar071d4272004-06-13 20:20:40 +0000826==============================================================================
Bram Moolenaarb26e6322010-05-22 21:34:09 +02008277. NetBeans commands *netbeans-commands*
828
Bram Moolenaar4a748032010-09-30 21:47:56 +0200829 *:nbstart* *E511* *E838*
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200830:nbs[tart] {connection} Start a new Netbeans session with {connection} as the
831 socket connection parameters. The format of
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200832 {connection} is described in |netbeans-parameters|.
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200833 At any time, one may check if the netbeans socket is
834 connected by running the command:
835 ':echo has("netbeans_enabled")'
836
837 *:nbclose*
838:nbc[lose] Close the current NetBeans session. Remove all placed
839 signs.
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000840
841 *:nbkey*
Bram Moolenaare3cc6d42011-10-20 21:58:34 +0200842:nb[key] {key} Pass the {key} to the Vim Controller for processing.
843 When a hot-key has been installed with the specialKeys
844 command, this command can be used to generate a hotkey
845 message to the Vim Controller.
846 This command can also be used to pass any text to the
847 Vim Controller. It is used by Pyclewn, for example,
848 to build the complete set of gdb commands as Vim user
849 commands.
850 The events newDotAndMark, keyCommand and keyAtPos are
851 generated (in this order).
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000852
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000853
854==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00008558. Known problems *netbeans-problems*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000856
857NUL bytes are not possible. For editor -> IDE they will appear as NL
858characters. For IDE -> editor they cannot be inserted.
859
Bram Moolenaar67c53842010-05-22 18:28:27 +0200860A NetBeans session may be initiated with Vim running in a terminal, and
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200861continued later in a GUI environment after running the |:gui| command. In this
Bram Moolenaar67c53842010-05-22 18:28:27 +0200862case, the highlighting defined for the NetBeans annotations may be cleared
863when the ":gui" command sources .gvimrc and this file loads a colorscheme
864that runs the command ":highlight clear".
865New in version 2.5.
866
Bram Moolenaar071d4272004-06-13 20:20:40 +0000867
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000868==============================================================================
8699. Debugging NetBeans protocol *netbeans-debugging*
870
871To debug the Vim protocol, you must first compile Vim with debugging support
872and NetBeans debugging support. See |netbeans-configure| for instructions
873about Vim compiling and how to enable debug support.
874
875When running Vim, set the following environment variables:
876
877 export SPRO_GVIM_DEBUG=netbeans.log
878 export SPRO_GVIM_DLEVEL=0xffffffff
879
880Vim will then log all the incoming and outgoing messages of the NetBeans
881protocol to the file netbeans.log .
882
883The content of netbeans.log after a session looks like this:
884Tue May 20 17:19:27 2008
885EVT: 0:startupDone=0
886CMD 1: (1) create
887CMD 2: (1) setTitle "testfile1.txt"
888CMD 3: (1) setFullName "testfile1.txt"
889EVT(suppressed): 1:remove=3 0 -1
890EVT: 1:fileOpened=0 "d:\\work\\vimWrapper\\vimWrapper2\\pyvimwrapper\\tests\\testfile1.txt" T F
891CMD 4: (1) initDone
892FUN 5: (0) getCursor
893REP 5: 1 1 0 0
894CMD 6: (2) create
895CMD 7: (2) setTitle "testfile2.txt"
896CMD 8: (2) setFullName "testfile2.txt"
897EVT(suppressed): 2:remove=8 0 -1
898EVT: 2:fileOpened=0 "d:\\work\\vimWrapper\\vimWrapper2\\pyvimwrapper\\tests\\testfile2.txt" T F
899CMD 9: (2) initDone
900
901
902==============================================================================
90310. NetBeans External Editor
904
905NOTE: This information is obsolete! Only relevant if you are using an old
906version of NetBeans.
907
908
90910.1. Downloading NetBeans *netbeans-download*
910
911The NetBeans IDE is available for download from netbeans.org. You can download
912a released version, download sources, or use CVS to download the current
913source tree. If you choose to download sources, follow directions from
914netbeans.org on building NetBeans.
915
916Depending on the version of NetBeans you download, you may need to do further
917work to get the required External Editor module. This is the module which lets
918NetBeans work with gvim (or xemacs :-). See http://externaleditor.netbeans.org
919for details on downloading this module if your NetBeans release does not have
920it.
921
922For C, C++, and Fortran support you will also need the cpp module. See
923http://cpp.netbeans.org for information regarding this module.
924
925You can also download Sun ONE Studio from Sun Microsystems, Inc for a 30 day
926free trial. See http://www.sun.com for further details.
927
928
92910.2. NetBeans Key Bindings *netbeans-keybindings*
930
931Vim understands a number of key bindings that execute NetBeans commands.
932These are typically all the Function key combinations. To execute a NetBeans
933command, the user must press the Pause key followed by a NetBeans key binding.
934For example, in order to compile a Java file, the NetBeans key binding is
935"F9". So, while in vim, press "Pause F9" to compile a java file. To toggle a
936breakpoint at the current line, press "Pause Shift F8".
937
938The Pause key is Function key 21. If you don't have a working Pause key and
939want to use F8 instead, use: >
940
941 :map <F8> <F21>
942
943The External Editor module dynamically reads the NetBeans key bindings so vim
944should always have the latest key bindings, even when NetBeans changes them.
945
946
94710.3. Preparing NetBeans for Vim *netbeans-preparation*
948
949In order for NetBeans to work with vim, the NetBeans External Editor module
950must be loaded and enabled. If you have a Sun ONE Studio Enterprise Edition
951then this module should be loaded and enabled. If you have a NetBeans release
952you may need to find another way of obtaining this open source module.
953
954You can check if you have this module by opening the Tools->Options dialog
955and drilling down to the "Modules" list (IDE Configuration->System->Modules).
956If your Modules list has an entry for "External Editor" you must make sure
957it is enabled (the "Enabled" property should have the value "True"). If your
958Modules list has no External Editor see the next section on |obtaining-exted|.
959
960
96110.4. Obtaining the External Editor Module *obtaining-exted*
962
963There are 2 ways of obtaining the External Editor module. The easiest way
964is to use the NetBeans Update Center to download and install the module.
965Unfortunately, some versions do not have this module in their update
966center. If you cannot download via the update center you will need to
967download sources and build the module. I will try and get the module
968available from the NetBeans Update Center so building will be unnecessary.
969Also check http://externaleditor.netbeans.org for other availability options.
970
971To download the External Editor sources via CVS and build your own module,
972see http://externaleditor.netbeans.org and http://www.netbeans.org.
973Unfortunately, this is not a trivial procedure.
974
975
97610.5. Setting up NetBeans to run with Vim *netbeans-setup*
977
978Assuming you have loaded and enabled the NetBeans External Editor module
979as described in |netbeans-preparation| all you need to do is verify that
980the gvim command line is properly configured for your environment.
981
982Open the Tools->Options dialog and open the Editing category. Select the
983External Editor. The right hand pane should contain a Properties tab and
984an Expert tab. In the Properties tab make sure the "Editor Type" is set
985to "Vim". In the Expert tab make sure the "Vim Command" is correct.
986
987You should be careful if you change the "Vim Command". There are command
988line options there which must be there for the connection to be properly
989set up. You can change the command name but that's about it. If your gvim
990can be found by your $PATH then the VIM Command can start with "gvim". If
991you don't want gvim searched from your $PATH then hard code in the full
992Unix path name. At this point you should get a gvim for any source file
993you open in NetBeans.
994
995If some files come up in gvim and others (with different file suffixes) come
996up in the default NetBeans editor you should verify the MIME type in the
997Expert tab MIME Type property. NetBeans is MIME oriented and the External
998Editor will only open MIME types specified in this property.
999
1000
Bram Moolenaar071d4272004-06-13 20:20:40 +00001001 vim:tw=78:ts=8:ft=help:norl: