blob: 6b186b3443df0a54fbc4b251709eb6dfd4014bb0 [file] [log] [blame]
Bram Moolenaar4a748032010-09-30 21:47:56 +02001*netbeans.txt* For Vim version 7.3. Last change: 2010 Sep 29
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 Moolenaar3577c6f2008-06-24 21:16:56 +00002666.1 Kinds of messages |nb-messages|
2676.2 Terms |nb-terms|
2686.3 Commands |nb-commands|
2696.4 Functions and Replies |nb-functions|
2706.5 Events |nb-events|
2716.6 Special messages |nb-special|
2726.7 Protocol errors |nb-protocol_errors|
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000273
274
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00002756.1 Kinds of messages *nb-messages*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000276
277There are four kinds of messages:
278
279kind direction comment ~
280Command IDE -> editor no reply necessary
281Function IDE -> editor editor must send back a reply
282Reply editor -> IDE only in response to a Function
283Event editor -> IDE no reply necessary
284
285The messages are sent as a single line with a terminating newline character.
286Arguments are separated by a single space. The first item of the message
287depends on the kind of message:
288
289kind first item example ~
290Command bufID:name!seqno 11:showBalloon!123 "text"
291Function bufID:name/seqno 11:getLength/123
292Reply seqno 123 5000
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000293Event bufID:name=seqno 11:keyCommand=123 "S-F2"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000294
295
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000296
2976.2 Terms *nb-terms*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000298
299bufID Buffer number. A message may be either for a specific buffer
300 or generic. Generic messages use a bufID of zero. NOTE: this
301 buffer ID is assigned by the IDE, it is not Vim's buffer
302 number. The bufID must be a sequentially rising number,
303 starting at one.
304
305seqno The IDE uses a sequence number for Commands and Functions. A
306 Reply must use the sequence number of the Function that it is
307 associated with. A zero sequence number can be used for
308 Events (the seqno of the last received Command or Function can
309 also be used).
310
311string Argument in double quotes. Text is in UTF-8 encoding. This
312 means ASCII is passed as-is. Special characters are
313 represented with a backslash:
314 \" double quote
315 \n newline
316 \r carriage-return
317 \t tab (optional, also works literally)
318 \\ backslash
319 NUL bytes are not allowed!
320
321boolean Argument with two possible values:
322 T true
323 F false
324
325number Argument with a decimal number.
326
Bram Moolenaar67c53842010-05-22 18:28:27 +0200327color Argument with either a decimal number, "none" (without the
328 quotes) or the name of a color (without the quotes) defined
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200329 both in the color list in |highlight-ctermfg| and in the color
330 list in |gui-colors|.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200331 New in version 2.5.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000332
333offset A number argument that indicates a byte position in a buffer.
334 The first byte has offset zero. Line breaks are counted for
335 how they appear in the file (CR/LF counts for two bytes).
336 Note that a multi-byte character is counted for the number of
337 bytes it takes.
338
339lnum/col Argument with a line number and column number position. The
340 line number starts with one, the column is the byte position,
341 starting with zero. Note that a multi-byte character counts
342 for several columns.
343
344pathname String argument: file name with full path.
345
346
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00003476.3 Commands *nb-commands*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000348
349actionMenuItem Not implemented.
350
351actionSensitivity
352 Not implemented.
353
354addAnno serNum typeNum off len
355 Place an annotation in this buffer.
356 Arguments:
357 serNum number serial number of this placed
358 annotation, used to be able to remove
359 it
360 typeNum number sequence number of the annotation
361 defined with defineAnnoType for this
362 buffer
363 off number offset where annotation is to be placed
364 len number not used
365 In version 2.1 "lnum/col" can be used instead of "off".
366
367balloonResult text
368 Not implemented.
369
370close Close the buffer. This leaves us without current buffer, very
371 dangerous to use!
372
373create Creates a buffer without a name. Replaces the current buffer
374 (it's hidden when it was changed).
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000375 The Vim Controller should use this as the first command for a
376 file that is being opened. The sequence of commands could be:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000377 create
378 setCaretListener (ignored)
379 setModified (no effect)
380 setContentType (ignored)
381 startDocumentListen
382 setTitle
383 setFullName
384
385defineAnnoType typeNum typeName tooltip glyphFile fg bg
386 Define a type of annotation for this buffer.
387 Arguments:
388 typeNum number sequence number (not really used)
389 typeName string name that identifies this annotation
390 tooltip string not used
391 glyphFile string name of icon file
Bram Moolenaar67c53842010-05-22 18:28:27 +0200392 fg color foreground color for line highlighting
393 bg color background color for line highlighting
Bram Moolenaar071d4272004-06-13 20:20:40 +0000394 Vim will define a sign for the annotation.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200395 When color is a number, this is the "#rrggbb" Red, Green and
396 Blue values of the color (see |gui-colors|) and the
397 highlighting is only defined for GVim.
398 When color is a name, this color is defined both for Vim
399 running in a color terminal and for GVim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000400 When both "fg" and "bg" are "none" no line highlighting is
401 used (new in version 2.1).
402 When "glyphFile" is empty, no text sign is used (new in
403 version 2.1).
404 When "glyphFile" is one or two characters long, a text sign is
405 defined (new in version 2.1).
406 Note: the annotations will be defined in sequence, and the
407 sequence number is later used with addAnno.
408
409editFile pathname
410 Set the name for the buffer and edit the file "pathname", a
411 string argument.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000412 Normal way for the IDE to tell the editor to edit a file.
413
414 You must set a bufId different of 0 with this command to
415 assign a bufId to the buffer. It will trigger an event
416 fileOpened with a bufId of 0 but the buffer has been assigned.
417
418 If the IDE is going to pass the file text to the editor use
419 these commands instead:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000420 setFullName
421 insert
422 initDone
423 New in version 2.1.
424
425enableBalloonEval
426 Not implemented.
427
428endAtomic End an atomic operation. The changes between "startAtomic"
429 and "endAtomic" can be undone as one operation. But it's not
430 implemented yet. Redraw when necessary.
431
432guard off len
433 Mark an area in the buffer as guarded. This means it cannot
434 be edited. "off" and "len" are numbers and specify the text
435 to be guarded.
436
437initDone Mark the buffer as ready for use. Implicitly makes the buffer
438 the current buffer. Fires the BufReadPost autocommand event.
439
Bram Moolenaar009b2592004-10-24 19:18:58 +0000440insertDone
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000441 Sent by Vim Controller to tell Vim an initial file insert is
442 done. This triggers a read message being printed. Prior to
443 version 2.3, no read messages were displayed after opening a
444 file. New in version 2.3.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000445
Bram Moolenaar071d4272004-06-13 20:20:40 +0000446moveAnnoToFront serNum
447 Not implemented.
448
449netbeansBuffer isNetbeansBuffer
Bram Moolenaarc236c162008-07-13 17:41:49 +0000450 If "isNetbeansBuffer" is "T" then this buffer is "owned" by
Bram Moolenaar071d4272004-06-13 20:20:40 +0000451 NetBeans.
452 New in version 2.2.
453
454putBufferNumber pathname
455 Associate a buffer number with the Vim buffer by the name
456 "pathname", a string argument. To be used when the editor
457 reported editing another file to the IDE and the IDE needs to
458 tell the editor what buffer number it will use for this file.
459 Also marks the buffer as initialized.
460 New in version 2.1.
461
462raise Bring the editor to the foreground.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200463 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000464 New in version 2.1.
465
466removeAnno serNum
467 Remove a previously place annotation for this buffer.
468 "serNum" is the same number used in addAnno.
469
470save Save the buffer when it was modified. The other side of the
471 interface is expected to write the buffer and invoke
472 "setModified" to reset the "changed" flag of the buffer.
473 The writing is skipped when one of these conditions is true:
474 - 'write' is not set
475 - the buffer is read-only
476 - the buffer does not have a file name
477 - 'buftype' disallows writing
478 New in version 2.2.
479
Bram Moolenaar009b2592004-10-24 19:18:58 +0000480saveDone
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000481 Sent by Vim Controller to tell Vim a save is done. This
482 triggers a save message being printed. Prior to version 2.3,
483 no save messages were displayed after a save.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000484 New in version 2.3.
485
Bram Moolenaar071d4272004-06-13 20:20:40 +0000486setAsUser Not implemented.
487
488setBufferNumber pathname
489 Associate a buffer number with Vim buffer by the name
490 "pathname". To be used when the editor reported editing
491 another file to the IDE and the IDE needs to tell the editor
492 what buffer number it will use for this file.
493 Has the side effect of making the buffer the current buffer.
494 See "putBufferNumber" for a more useful command.
495
496setContentType
497 Not implemented.
498
499setDot off Make the buffer the current buffer and set the cursor at the
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000500 specified position. If the buffer is open in another window
501 than make that window the current window.
502 If there are folds they are opened to make the cursor line
503 visible.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000504 In version 2.1 "lnum/col" can be used instead of "off".
505
506setExitDelay seconds
507 Set the delay for exiting to "seconds", a number.
508 This delay is used to give the IDE a chance to handle things
509 before really exiting. The default delay is two seconds.
510 New in version 2.1.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000511 Obsolete in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000512
513setFullName pathname
514 Set the file name to be used for a buffer to "pathname", a
515 string argument.
516 Used when the IDE wants to edit a file under control of the
517 IDE. This makes the buffer the current buffer, but does not
518 read the file. "insert" commands will be used next to set the
519 contents.
520
521setLocAndSize Not implemented.
522
523setMark Not implemented.
524
525setModified modified
526 When the boolean argument "modified" is "T" mark the buffer as
527 modified, when it is "F" mark it as unmodified.
528
Bram Moolenaar009b2592004-10-24 19:18:58 +0000529setModtime time
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000530 Update a buffers modification time after the file has been
531 saved directly by the Vim Controller.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000532 New in version 2.3.
533
534setReadOnly
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000535 Set a file as readonly
536 Implemented in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000537
538setStyle Not implemented.
539
540setTitle name
541 Set the title for the buffer to "name", a string argument.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000542 The title is only used for the Vim Controller functions, not
543 by Vim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000544
545setVisible visible
546 When the boolean argument "visible" is "T", goto the buffer.
547 The "F" argument does nothing.
548
549showBalloon text
550 Show a balloon (popup window) at the mouse pointer position,
551 containing "text", a string argument. The balloon should
552 disappear when the mouse is moved more than a few pixels.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200553 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000554 New in version 2.1.
555
Bram Moolenaar009b2592004-10-24 19:18:58 +0000556specialKeys
557 Map a set of keys (mostly function keys) to be passed back
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000558 to the Vim Controller for processing. This lets regular IDE
559 hotkeys be used from Vim.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000560 Implemented in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000561
562startAtomic Begin an atomic operation. The screen will not be updated
563 until "endAtomic" is given.
564
565startCaretListen
566 Not implemented.
567
568startDocumentListen
569 Mark the buffer to report changes to the IDE with the
570 "insert" and "remove" events. The default is to report
571 changes.
572
573stopCaretListen
574 Not implemented.
575
576stopDocumentListen
577 Mark the buffer to stop reporting changes to the IDE.
578 Opposite of startDocumentListen.
Bram Moolenaar748bf032005-02-02 23:04:36 +0000579 NOTE: if "netbeansBuffer" was used to mark this buffer as a
580 NetBeans buffer, then the buffer is deleted in Vim. This is
581 for compatibility with Sun Studio 10.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000582
583unguard off len
584 Opposite of "guard", remove guarding for a text area.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000585 Also sets the current buffer, if necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000586
587version Not implemented.
588
589
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00005906.4 Functions and Replies *nb-functions*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000591
592getDot Not implemented.
593
594getCursor Return the current buffer and cursor position.
595 The reply is:
596 seqno bufID lnum col off
597 seqno = sequence number of the function
598 bufID = buffer ID of the current buffer (if this is unknown -1
599 is used)
600 lnum = line number of the cursor (first line is one)
601 col = column number of the cursor (in bytes, zero based)
602 off = offset of the cursor in the buffer (in bytes)
603 New in version 2.1.
604
605getLength Return the length of the buffer in bytes.
606 Reply example for a buffer with 5000 bytes:
607 123 5000
608 TODO: explain use of partial line.
609
610getMark Not implemented.
611
Bram Moolenaarc65c4912006-11-14 17:29:46 +0000612getAnno serNum
613 Return the line number of the annotation in the buffer.
614 Argument:
615 serNum serial number of this placed annotation
616 The reply is:
617 123 lnum line number of the annotation
618 123 0 invalid annotation serial number
619 New in version 2.4.
620
Bram Moolenaar071d4272004-06-13 20:20:40 +0000621getModified When a buffer is specified: Return zero if the buffer does not
622 have changes, one if it does have changes.
623 When no buffer is specified (buffer number zero): Return the
624 number of buffers with changes. When the result is zero it's
625 safe to tell Vim to exit.
626 New in version 2.1.
627
628getText Return the contents of the buffer as a string.
629 Reply example for a buffer with two lines
630 123 "first line\nsecond line\n"
631 NOTE: docs indicate an offset and length argument, but this is
632 not implemented.
633
634insert off text
635 Insert "text" before position "off". "text" is a string
636 argument, "off" a number.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000637 "text" should have a "\n" (newline) at the end of each line.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000638 Or "\r\n" when 'fileformat' is "dos". When using "insert" in
639 an empty buffer Vim will set 'fileformat' accordingly.
640 When "off" points to the start of a line the text is inserted
641 above this line. Thus when "off" is zero lines are inserted
642 before the first line.
643 When "off" points after the start of a line, possibly on the
644 NUL at the end of a line, the first line of text is appended
645 to this line. Further lines come below it.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000646 Possible replies:
647 123 no problem
648 123 !message failed
649 Note that the message in the reply is not quoted.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000650 Also sets the current buffer, if necessary.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000651 Does not move the cursor to the changed text.
652 Resets undo information.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000653
654remove off length
655 Delete "length" bytes of text at position "off". Both
656 arguments are numbers.
657 Possible replies:
658 123 no problem
659 123 !message failed
660 Note that the message in the reply is not quoted.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000661 Also sets the current buffer, if necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000662
663saveAndExit Perform the equivalent of closing Vim: ":confirm qall".
664 If there are no changed files or the user does not cancel the
665 operation Vim exits and no result is sent back. The IDE can
666 consider closing the connection as a successful result.
667 If the user cancels the operation the number of modified
668 buffers that remains is returned and Vim does not exit.
669 New in version 2.1.
670
671
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00006726.5 Events *nb-events*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000673
674balloonEval off len type
675 The mouse pointer rests on text for a short while. When "len"
676 is zero, there is no selection and the pointer is at position
677 "off". When "len" is non-zero the text from position "off" to
678 "off" + "len" is selected.
679 Only sent after "enableBalloonEval" was used for this buffer.
680 "type" is not yet defined.
681 Not implemented yet.
682
683balloonText text
684 Used when 'ballooneval' is set and the mouse pointer rests on
685 some text for a moment. "text" is a string, the text under
686 the mouse pointer.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200687 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000688 New in version 2.1.
689
690buttonRelease button lnum col
691 Report which button was pressed and the location of the cursor
692 at the time of the release. Only for buffers that are owned
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000693 by the Vim Controller. This event is not sent if the button
694 was released while the mouse was in the status line or in a
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000695 separator line. If col is less than 1 the button release was
Bram Moolenaar071d4272004-06-13 20:20:40 +0000696 in the sign area.
697 New in version 2.2.
698
Bram Moolenaar009b2592004-10-24 19:18:58 +0000699disconnect
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000700 Tell the Vim Controller that Vim is exiting and not to try and
701 read or write more commands.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000702 New in version 2.3.
703
Bram Moolenaar071d4272004-06-13 20:20:40 +0000704fileClosed Not implemented.
705
706fileModified Not implemented.
707
708fileOpened pathname open modified
709 A file was opened by the user.
710 Arguments:
711 pathname string name of the file
712 open boolean always "T"
713 modified boolean always "F"
714
715geometry cols rows x y
716 Report the size and position of the editor window.
717 Arguments:
718 cols number number of text columns
719 rows number number of text rows
720 x number pixel position on screen
721 y number pixel position on screen
722 Only works for Motif.
723
724insert off text
725 Text "text" has been inserted in Vim at position "off".
726 Only fired when enabled, see "startDocumentListen".
727
728invokeAction Not implemented.
729
730keyCommand keyName
731 Reports a special key being pressed with name "keyName", which
732 is a string.
733 Supported key names:
734 F1 function key 1
735 F2 function key 2
736 ...
737 F12 function key 12
738
739 ' ' space (without the quotes)
740 ! exclamation mark
741 ... any other ASCII printable character
742 ~ tilde
743
744 X any unrecognized key
745
746 The key may be prepended by "C", "S" and/or "M" for Control,
747 Shift and Meta (Alt) modifiers. If there is a modifier a dash
748 is used to separate it from the key name. For example:
749 "C-F2".
750 ASCII characters are new in version 2.1.
751
752keyAtPos keyName lnum/col
753 Like "keyCommand" and also report the line number and column
754 of the cursor.
755 New in version 2.1.
756
Bram Moolenaard7f8f5c2009-01-06 15:14:30 +0000757killed A file was deleted or wiped out by the user and the buffer
758 annotations have been removed. The bufID number for this
759 buffer has become invalid. Only for files that have been
760 assigned a bufID number by the IDE.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000761
762newDotAndMark off off
763 Reports the position of the cursor being at "off" bytes into
764 the buffer. Only sent just before a "keyCommand" event.
765
766quit Not implemented.
767
768remove off len
769 Text was deleted in Vim at position "off" with byte length
770 "len".
771 Only fired when enabled, see "startDocumentListen".
772
773revert Not implemented.
774
775save The buffer has been saved and is now unmodified.
776 Only fired when enabled, see "startDocumentListen".
777
778startupDone The editor has finished its startup work and is ready for
779 editing files.
780 New in version 2.1.
781
782unmodified The buffer is now unmodified.
783 Only fired when enabled, see "startDocumentListen".
784
785version vers Report the version of the interface implementation. Vim
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000786 reports "2.4" (including the quotes).
Bram Moolenaar071d4272004-06-13 20:20:40 +0000787
788
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00007896.6 Special messages *nb-special*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000790
791These messages do not follow the style of the messages above. They are
792terminated by a newline character.
793
794ACCEPT Not used.
795
796AUTH password editor -> IDE: First message that the editor sends to the IDE.
797 Must contain the password for the socket server, as specified
798 with the |-nb| argument. No quotes are used!
799
800DISCONNECT IDE -> editor: break the connection. The editor will exit.
801 The IDE must only send this message when there are no unsaved
802 changes!
803
804DETACH IDE -> editor: break the connection without exiting the
805 editor. Used when the IDE exits without bringing down the
806 editor as well.
807 New in version 2.1.
808
809REJECT Not used.
810
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000811
8126.7 Protocol errors *nb-protocol_errors*
813
814These errors occur when a message violates the protocol:
815*E627* *E628* *E629* *E630* *E631* *E632* *E633* *E634* *E635* *E636*
816*E637* *E638* *E639* *E640* *E641* *E642* *E643* *E644* *E645* *E646*
817*E647* *E648* *E649* *E650* *E651* *E652* *E653* *E654*
818
819
Bram Moolenaar071d4272004-06-13 20:20:40 +0000820==============================================================================
Bram Moolenaarb26e6322010-05-22 21:34:09 +02008217. NetBeans commands *netbeans-commands*
822
Bram Moolenaar4a748032010-09-30 21:47:56 +0200823 *:nbstart* *E511* *E838*
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200824:nbs[tart] {connection} Start a new Netbeans session with {connection} as the
825 socket connection parameters. The format of
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200826 {connection} is described in |netbeans-parameters|.
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200827 At any time, one may check if the netbeans socket is
828 connected by running the command:
829 ':echo has("netbeans_enabled")'
830
831 *:nbclose*
832:nbc[lose] Close the current NetBeans session. Remove all placed
833 signs.
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000834
835 *:nbkey*
Bram Moolenaarb26e6322010-05-22 21:34:09 +0200836:nb[key] {key} Pass the {key} to the Vim Controller for processing
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000837
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000838When a hot-key has been installed with the specialKeys command, this command
839can be used to generate a hotkey messages to the Vim Controller. The events
840newDotAndMark, keyCommand and keyAtPos are generated (in this order).
841
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000842
843==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00008448. Known problems *netbeans-problems*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000845
846NUL bytes are not possible. For editor -> IDE they will appear as NL
847characters. For IDE -> editor they cannot be inserted.
848
Bram Moolenaar67c53842010-05-22 18:28:27 +0200849A NetBeans session may be initiated with Vim running in a terminal, and
Bram Moolenaar9855d6b2010-07-18 14:34:51 +0200850continued later in a GUI environment after running the |:gui| command. In this
Bram Moolenaar67c53842010-05-22 18:28:27 +0200851case, the highlighting defined for the NetBeans annotations may be cleared
852when the ":gui" command sources .gvimrc and this file loads a colorscheme
853that runs the command ":highlight clear".
854New in version 2.5.
855
Bram Moolenaar071d4272004-06-13 20:20:40 +0000856
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000857==============================================================================
8589. Debugging NetBeans protocol *netbeans-debugging*
859
860To debug the Vim protocol, you must first compile Vim with debugging support
861and NetBeans debugging support. See |netbeans-configure| for instructions
862about Vim compiling and how to enable debug support.
863
864When running Vim, set the following environment variables:
865
866 export SPRO_GVIM_DEBUG=netbeans.log
867 export SPRO_GVIM_DLEVEL=0xffffffff
868
869Vim will then log all the incoming and outgoing messages of the NetBeans
870protocol to the file netbeans.log .
871
872The content of netbeans.log after a session looks like this:
873Tue May 20 17:19:27 2008
874EVT: 0:startupDone=0
875CMD 1: (1) create
876CMD 2: (1) setTitle "testfile1.txt"
877CMD 3: (1) setFullName "testfile1.txt"
878EVT(suppressed): 1:remove=3 0 -1
879EVT: 1:fileOpened=0 "d:\\work\\vimWrapper\\vimWrapper2\\pyvimwrapper\\tests\\testfile1.txt" T F
880CMD 4: (1) initDone
881FUN 5: (0) getCursor
882REP 5: 1 1 0 0
883CMD 6: (2) create
884CMD 7: (2) setTitle "testfile2.txt"
885CMD 8: (2) setFullName "testfile2.txt"
886EVT(suppressed): 2:remove=8 0 -1
887EVT: 2:fileOpened=0 "d:\\work\\vimWrapper\\vimWrapper2\\pyvimwrapper\\tests\\testfile2.txt" T F
888CMD 9: (2) initDone
889
890
891==============================================================================
89210. NetBeans External Editor
893
894NOTE: This information is obsolete! Only relevant if you are using an old
895version of NetBeans.
896
897
89810.1. Downloading NetBeans *netbeans-download*
899
900The NetBeans IDE is available for download from netbeans.org. You can download
901a released version, download sources, or use CVS to download the current
902source tree. If you choose to download sources, follow directions from
903netbeans.org on building NetBeans.
904
905Depending on the version of NetBeans you download, you may need to do further
906work to get the required External Editor module. This is the module which lets
907NetBeans work with gvim (or xemacs :-). See http://externaleditor.netbeans.org
908for details on downloading this module if your NetBeans release does not have
909it.
910
911For C, C++, and Fortran support you will also need the cpp module. See
912http://cpp.netbeans.org for information regarding this module.
913
914You can also download Sun ONE Studio from Sun Microsystems, Inc for a 30 day
915free trial. See http://www.sun.com for further details.
916
917
91810.2. NetBeans Key Bindings *netbeans-keybindings*
919
920Vim understands a number of key bindings that execute NetBeans commands.
921These are typically all the Function key combinations. To execute a NetBeans
922command, the user must press the Pause key followed by a NetBeans key binding.
923For example, in order to compile a Java file, the NetBeans key binding is
924"F9". So, while in vim, press "Pause F9" to compile a java file. To toggle a
925breakpoint at the current line, press "Pause Shift F8".
926
927The Pause key is Function key 21. If you don't have a working Pause key and
928want to use F8 instead, use: >
929
930 :map <F8> <F21>
931
932The External Editor module dynamically reads the NetBeans key bindings so vim
933should always have the latest key bindings, even when NetBeans changes them.
934
935
93610.3. Preparing NetBeans for Vim *netbeans-preparation*
937
938In order for NetBeans to work with vim, the NetBeans External Editor module
939must be loaded and enabled. If you have a Sun ONE Studio Enterprise Edition
940then this module should be loaded and enabled. If you have a NetBeans release
941you may need to find another way of obtaining this open source module.
942
943You can check if you have this module by opening the Tools->Options dialog
944and drilling down to the "Modules" list (IDE Configuration->System->Modules).
945If your Modules list has an entry for "External Editor" you must make sure
946it is enabled (the "Enabled" property should have the value "True"). If your
947Modules list has no External Editor see the next section on |obtaining-exted|.
948
949
95010.4. Obtaining the External Editor Module *obtaining-exted*
951
952There are 2 ways of obtaining the External Editor module. The easiest way
953is to use the NetBeans Update Center to download and install the module.
954Unfortunately, some versions do not have this module in their update
955center. If you cannot download via the update center you will need to
956download sources and build the module. I will try and get the module
957available from the NetBeans Update Center so building will be unnecessary.
958Also check http://externaleditor.netbeans.org for other availability options.
959
960To download the External Editor sources via CVS and build your own module,
961see http://externaleditor.netbeans.org and http://www.netbeans.org.
962Unfortunately, this is not a trivial procedure.
963
964
96510.5. Setting up NetBeans to run with Vim *netbeans-setup*
966
967Assuming you have loaded and enabled the NetBeans External Editor module
968as described in |netbeans-preparation| all you need to do is verify that
969the gvim command line is properly configured for your environment.
970
971Open the Tools->Options dialog and open the Editing category. Select the
972External Editor. The right hand pane should contain a Properties tab and
973an Expert tab. In the Properties tab make sure the "Editor Type" is set
974to "Vim". In the Expert tab make sure the "Vim Command" is correct.
975
976You should be careful if you change the "Vim Command". There are command
977line options there which must be there for the connection to be properly
978set up. You can change the command name but that's about it. If your gvim
979can be found by your $PATH then the VIM Command can start with "gvim". If
980you don't want gvim searched from your $PATH then hard code in the full
981Unix path name. At this point you should get a gvim for any source file
982you open in NetBeans.
983
984If some files come up in gvim and others (with different file suffixes) come
985up in the default NetBeans editor you should verify the MIME type in the
986Expert tab MIME Type property. NetBeans is MIME oriented and the External
987Editor will only open MIME types specified in this property.
988
989
Bram Moolenaar071d4272004-06-13 20:20:40 +0000990 vim:tw=78:ts=8:ft=help:norl: