blob: ebe71885467c0588f2768ebb350ba3e9e0b7abd6 [file] [log] [blame]
Bram Moolenaarfff2bee2010-05-15 13:56:02 +02001*netbeans.txt* For Vim version 7.3a. Last change: 2009 Jan 06
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|
177. NetBeans key |netbeans-key|
188. 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/
51- VimPlugin, integration of Vim inside Eclipse:
52 http://vimplugin.sourceforge.net/wiki/pmwiki.php
53- PIDA, IDE written in Python integrating Vim:
54 http://pida.co.uk/
55- VimWrapper, library to easy Vim integration into IDE:
56 http://www.freehackers.org/VimWrapper
57
58Check the specific project pages to see how to use Vim with these projects.
59
60In the rest of this help page, we will use the term "Vim Controller" to
61describe the program controlling Vim through the NetBeans socket interface.
62
63
64About the NetBeans IDE ~
65
Bram Moolenaar071d4272004-06-13 20:20:40 +000066NetBeans is an open source Integrated Development Environment developed
67jointly by Sun Microsystems, Inc. and the netbeans.org developer community.
68Initially just a Java IDE, NetBeans has had C, C++, and Fortran support added
69in recent releases.
70
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000071For more information visit the main NetBeans web site http://www.netbeans.org.
Bram Moolenaarc236c162008-07-13 17:41:49 +000072The External Editor is now, unfortunately, declared obsolete. See
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000073 http://externaleditor.netbeans.org.
Bram Moolenaar071d4272004-06-13 20:20:40 +000074
75Sun Microsystems, Inc. also ships NetBeans under the name Sun ONE Studio.
76Visit http://www.sun.com for more information regarding the Sun ONE Studio
77product line.
78
79Current releases of NetBeans provide full support for Java and limited support
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000080for C, C++, and Fortran. Current releases of Sun ONE Studio provide full
Bram Moolenaar071d4272004-06-13 20:20:40 +000081support for Java, C, C++, and Fortran.
82
Bram Moolenaar071d4272004-06-13 20:20:40 +000083==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000842. Integration features *netbeans-integration*
Bram Moolenaar071d4272004-06-13 20:20:40 +000085
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000086The NetBeans socket interface of Vim allows to get information from Vim or to
87ask Vim to perform specific actions:
88- get information about buffer: buffer name, cursor position, buffer content,
89 etc.
90- be notified when buffers are open or closed
91- be notified of how the buffer content is modified
92- load and save files
93- modify the buffer content
94- installing special key bindings
95- raise the window, control the window geometry
Bram Moolenaar071d4272004-06-13 20:20:40 +000096
Bram Moolenaar3577c6f2008-06-24 21:16:56 +000097For sending key strokes to Vim or for evaluating functions in Vim, you must
98use the |clientserver| interface.
Bram Moolenaar071d4272004-06-13 20:20:40 +000099
Bram Moolenaar071d4272004-06-13 20:20:40 +0000100
101==============================================================================
1023. Configuring Vim for NetBeans *netbeans-configure*
103
Bram Moolenaar06b5d512010-05-22 15:37:44 +0200104For more help about installing Vim, please read |usr_90.txt| in the Vim User
105Manual.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106
107
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000108On Unix:
109--------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000110
111When running configure without arguments the NetBeans interface should be
112included. That is, if the configure check to find out if your system supports
113the required features succeeds.
114
115In case you do not want the NetBeans interface you can disable it by
116uncommenting a line with "--disable-netbeans" in the Makefile.
117
Bram Moolenaar67c53842010-05-22 18:28:27 +0200118Currently the NetBeans interface is supported by Vim running in a terminal and
119by GVim when it is run with one of the following GUIs: GTK, GNOME, and Motif.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000120
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000121If Motif support is required the user must supply XPM libraries. See
Bram Moolenaar071d4272004-06-13 20:20:40 +0000122|workshop-xpm| for details on obtaining the latest version of XPM.
123
124
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000125On MS-Windows:
126--------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000127
128The Win32 support is now in beta stage.
129
130To use XPM signs on Win32 (e.g. when using with NetBeans) you can compile
131XPM by yourself or use precompiled libraries from http://iamphet.nm.ru/misc/
132(for MS Visual C++) or http://gnuwin32.sourceforge.net (for MinGW).
133
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000134Enable debugging:
135-----------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000136
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000137To enable debugging of Vim and of the NetBeans protocol, the "NBDEBUG" macro
138needs to be defined. Search in the Makefile of the platform you are using for
139"NBDEBUG" to see what line needs to be uncommented. This effectively adds
140"-DNBDEBUG" to the compile command. Also see |netbeans-debugging|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000141
142==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00001434. Error Messages *netbeans-messages*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000144
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000145These error messages are specific to NetBeans socket protocol:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000146
147 *E463*
148Region is guarded, cannot modify
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000149 The Vim Controller has defined guarded areas in the text,
150 which you cannot change. Also sets the current buffer, if
151 necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000152
Bram Moolenaar67c53842010-05-22 18:28:27 +0200153 *E532*
154The defineAnnoType highlighting color name is too long
155 The maximum length of the "fg" or "bg" color argument in the
156 defineAnnoType command is 32 characters.
157 New in version 2.5.
158
Bram Moolenaar071d4272004-06-13 20:20:40 +0000159 *E656*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000160Writes of unmodified buffers forbidden
161 Writes of unmodified buffers that were opened from the
162 Vim Controller are not possible.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000163
164 *E657*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000165Partial writes disallowed
166 Partial writes for buffers that were opened from the
167 Vim Controller are not allowed.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000168
169 *E658*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000170Connection lost for this buffer
171 The Vim Controller has become confused about the state of
172 this file. Rather than risk data corruption, it has severed
173 the connection for this file. Vim will take over
174 responsibility for saving changes to this file and the
175 Vim Controller will no longer know of these changes.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000176
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000177 *E744*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000178Read-only file
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000179 Vim normally allows changes to a read-only file and only
180 enforces the read-only rule if you try to write the file.
181 However, NetBeans does not let you make changes to a file
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000182 which is read-only and becomes confused if Vim does this.
183 So Vim does not allow modifications to files when run
184 in NetBeans mode.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000185
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000186==============================================================================
1875. Running Vim in NetBeans mode *netbeans-run*
188
189Vim must be started with the |-nb| argument. Three forms can be used, that
Bram Moolenaar071d4272004-06-13 20:20:40 +0000190differ in the way the information for the connection is specified:
191
192 -nb={fname} from a file
193 -nb:{hostname}:{addr}:{password} directly
194 -nb from a file or environment
195
196 *E660* *E668*
197For security reasons, the best method is to write the information in a file
198readable only by the user. The name of the file can be passed with the
199"-nb={fname}" argument or, when "-nb" is used without a parameter, the
200environment variable "__NETBEANS_CONINFO". The file must contain these three
201lines, in any order:
202
203 host={hostname}
204 port={addr}
205 auth={password}
206
207Other lines are ignored. The caller of Vim is responsible for deleting the
208file afterwards.
209
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000210{hostname} is the name of the machine where Vim Controller is running. When
211omitted the environment variable "__NETBEANS_HOST" is used or the default
212"localhost".
Bram Moolenaar071d4272004-06-13 20:20:40 +0000213
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000214{addr} is the port number for the NetBeans interface. When omitted the
215environment variable "__NETBEANS_SOCKET" is used or the default 3219.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000216
217{password} is the password for connecting to NetBeans. When omitted the
218environment variable "__NETBEANS_VIM_PASSWORD" is used or "changeme".
219
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000220Vim will initiate a socket connection (client side) to the specified host and
221port upon startup. The password will be sent with the AUTH event when the
222connection has been established.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000223
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000224
225==============================================================================
2266. NetBeans protocol *netbeans-protocol*
227
228The communication between the Vim Controller and Vim uses plain text
229messages. This protocol was first designed to work with the external editor
230module of NetBeans. Later it was extended to work with Agide (A-A-P GUI IDE,
231see http://www.a-a-p.org) and then with other IDE. The extensions are marked
232with "version 2.1".
Bram Moolenaar071d4272004-06-13 20:20:40 +0000233
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000234Version 2.2 of the protocol has several minor changes which should only affect
235NetBeans users (ie, not Agide users). However, a bug was fixed which could
236cause confusion. The netbeans_saved() function sent a "save" protocol
237command. In protocol version 2.1 and earlier this was incorrectly interpreted
238as a notification that a write had taken place. In reality, it told NetBeans
239to save the file so multiple writes were being done. This caused various
240problems and has been fixed in 2.2. To decrease the likelihood of this
Bram Moolenaar071d4272004-06-13 20:20:40 +0000241confusion happening again, netbeans_saved() has been renamed to
242netbeans_save_buffer().
243
Bram Moolenaar67c53842010-05-22 18:28:27 +0200244We are now at version 2.5. For the differences between 2.4 and 2.5 search for
245"2.5" below.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000246
Bram Moolenaar071d4272004-06-13 20:20:40 +0000247The messages are currently sent over a socket. Since the messages are in
248plain UTF-8 text this protocol could also be used with any other communication
249mechanism.
250
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00002516.1 Kinds of messages |nb-messages|
2526.2 Terms |nb-terms|
2536.3 Commands |nb-commands|
2546.4 Functions and Replies |nb-functions|
2556.5 Events |nb-events|
2566.6 Special messages |nb-special|
2576.7 Protocol errors |nb-protocol_errors|
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000258
259
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00002606.1 Kinds of messages *nb-messages*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261
262There are four kinds of messages:
263
264kind direction comment ~
265Command IDE -> editor no reply necessary
266Function IDE -> editor editor must send back a reply
267Reply editor -> IDE only in response to a Function
268Event editor -> IDE no reply necessary
269
270The messages are sent as a single line with a terminating newline character.
271Arguments are separated by a single space. The first item of the message
272depends on the kind of message:
273
274kind first item example ~
275Command bufID:name!seqno 11:showBalloon!123 "text"
276Function bufID:name/seqno 11:getLength/123
277Reply seqno 123 5000
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000278Event bufID:name=seqno 11:keyCommand=123 "S-F2"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000279
280
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000281
2826.2 Terms *nb-terms*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000283
284bufID Buffer number. A message may be either for a specific buffer
285 or generic. Generic messages use a bufID of zero. NOTE: this
286 buffer ID is assigned by the IDE, it is not Vim's buffer
287 number. The bufID must be a sequentially rising number,
288 starting at one.
289
290seqno The IDE uses a sequence number for Commands and Functions. A
291 Reply must use the sequence number of the Function that it is
292 associated with. A zero sequence number can be used for
293 Events (the seqno of the last received Command or Function can
294 also be used).
295
296string Argument in double quotes. Text is in UTF-8 encoding. This
297 means ASCII is passed as-is. Special characters are
298 represented with a backslash:
299 \" double quote
300 \n newline
301 \r carriage-return
302 \t tab (optional, also works literally)
303 \\ backslash
304 NUL bytes are not allowed!
305
306boolean Argument with two possible values:
307 T true
308 F false
309
310number Argument with a decimal number.
311
Bram Moolenaar67c53842010-05-22 18:28:27 +0200312color Argument with either a decimal number, "none" (without the
313 quotes) or the name of a color (without the quotes) defined
314 both in the color list in|highlight-ctermfg| and in the color
315 list in|gui-colors|.
316 New in version 2.5.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000317
318offset A number argument that indicates a byte position in a buffer.
319 The first byte has offset zero. Line breaks are counted for
320 how they appear in the file (CR/LF counts for two bytes).
321 Note that a multi-byte character is counted for the number of
322 bytes it takes.
323
324lnum/col Argument with a line number and column number position. The
325 line number starts with one, the column is the byte position,
326 starting with zero. Note that a multi-byte character counts
327 for several columns.
328
329pathname String argument: file name with full path.
330
331
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00003326.3 Commands *nb-commands*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000333
334actionMenuItem Not implemented.
335
336actionSensitivity
337 Not implemented.
338
339addAnno serNum typeNum off len
340 Place an annotation in this buffer.
341 Arguments:
342 serNum number serial number of this placed
343 annotation, used to be able to remove
344 it
345 typeNum number sequence number of the annotation
346 defined with defineAnnoType for this
347 buffer
348 off number offset where annotation is to be placed
349 len number not used
350 In version 2.1 "lnum/col" can be used instead of "off".
351
352balloonResult text
353 Not implemented.
354
355close Close the buffer. This leaves us without current buffer, very
356 dangerous to use!
357
358create Creates a buffer without a name. Replaces the current buffer
359 (it's hidden when it was changed).
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000360 The Vim Controller should use this as the first command for a
361 file that is being opened. The sequence of commands could be:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000362 create
363 setCaretListener (ignored)
364 setModified (no effect)
365 setContentType (ignored)
366 startDocumentListen
367 setTitle
368 setFullName
369
370defineAnnoType typeNum typeName tooltip glyphFile fg bg
371 Define a type of annotation for this buffer.
372 Arguments:
373 typeNum number sequence number (not really used)
374 typeName string name that identifies this annotation
375 tooltip string not used
376 glyphFile string name of icon file
Bram Moolenaar67c53842010-05-22 18:28:27 +0200377 fg color foreground color for line highlighting
378 bg color background color for line highlighting
Bram Moolenaar071d4272004-06-13 20:20:40 +0000379 Vim will define a sign for the annotation.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200380 When color is a number, this is the "#rrggbb" Red, Green and
381 Blue values of the color (see |gui-colors|) and the
382 highlighting is only defined for GVim.
383 When color is a name, this color is defined both for Vim
384 running in a color terminal and for GVim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000385 When both "fg" and "bg" are "none" no line highlighting is
386 used (new in version 2.1).
387 When "glyphFile" is empty, no text sign is used (new in
388 version 2.1).
389 When "glyphFile" is one or two characters long, a text sign is
390 defined (new in version 2.1).
391 Note: the annotations will be defined in sequence, and the
392 sequence number is later used with addAnno.
393
394editFile pathname
395 Set the name for the buffer and edit the file "pathname", a
396 string argument.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000397 Normal way for the IDE to tell the editor to edit a file.
398
399 You must set a bufId different of 0 with this command to
400 assign a bufId to the buffer. It will trigger an event
401 fileOpened with a bufId of 0 but the buffer has been assigned.
402
403 If the IDE is going to pass the file text to the editor use
404 these commands instead:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000405 setFullName
406 insert
407 initDone
408 New in version 2.1.
409
410enableBalloonEval
411 Not implemented.
412
413endAtomic End an atomic operation. The changes between "startAtomic"
414 and "endAtomic" can be undone as one operation. But it's not
415 implemented yet. Redraw when necessary.
416
417guard off len
418 Mark an area in the buffer as guarded. This means it cannot
419 be edited. "off" and "len" are numbers and specify the text
420 to be guarded.
421
422initDone Mark the buffer as ready for use. Implicitly makes the buffer
423 the current buffer. Fires the BufReadPost autocommand event.
424
Bram Moolenaar009b2592004-10-24 19:18:58 +0000425insertDone
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000426 Sent by Vim Controller to tell Vim an initial file insert is
427 done. This triggers a read message being printed. Prior to
428 version 2.3, no read messages were displayed after opening a
429 file. New in version 2.3.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000430
Bram Moolenaar071d4272004-06-13 20:20:40 +0000431moveAnnoToFront serNum
432 Not implemented.
433
434netbeansBuffer isNetbeansBuffer
Bram Moolenaarc236c162008-07-13 17:41:49 +0000435 If "isNetbeansBuffer" is "T" then this buffer is "owned" by
Bram Moolenaar071d4272004-06-13 20:20:40 +0000436 NetBeans.
437 New in version 2.2.
438
439putBufferNumber pathname
440 Associate a buffer number with the Vim buffer by the name
441 "pathname", a string argument. To be used when the editor
442 reported editing another file to the IDE and the IDE needs to
443 tell the editor what buffer number it will use for this file.
444 Also marks the buffer as initialized.
445 New in version 2.1.
446
447raise Bring the editor to the foreground.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200448 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000449 New in version 2.1.
450
451removeAnno serNum
452 Remove a previously place annotation for this buffer.
453 "serNum" is the same number used in addAnno.
454
455save Save the buffer when it was modified. The other side of the
456 interface is expected to write the buffer and invoke
457 "setModified" to reset the "changed" flag of the buffer.
458 The writing is skipped when one of these conditions is true:
459 - 'write' is not set
460 - the buffer is read-only
461 - the buffer does not have a file name
462 - 'buftype' disallows writing
463 New in version 2.2.
464
Bram Moolenaar009b2592004-10-24 19:18:58 +0000465saveDone
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000466 Sent by Vim Controller to tell Vim a save is done. This
467 triggers a save message being printed. Prior to version 2.3,
468 no save messages were displayed after a save.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000469 New in version 2.3.
470
Bram Moolenaar071d4272004-06-13 20:20:40 +0000471setAsUser Not implemented.
472
473setBufferNumber pathname
474 Associate a buffer number with Vim buffer by the name
475 "pathname". To be used when the editor reported editing
476 another file to the IDE and the IDE needs to tell the editor
477 what buffer number it will use for this file.
478 Has the side effect of making the buffer the current buffer.
479 See "putBufferNumber" for a more useful command.
480
481setContentType
482 Not implemented.
483
484setDot off Make the buffer the current buffer and set the cursor at the
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000485 specified position. If the buffer is open in another window
486 than make that window the current window.
487 If there are folds they are opened to make the cursor line
488 visible.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000489 In version 2.1 "lnum/col" can be used instead of "off".
490
491setExitDelay seconds
492 Set the delay for exiting to "seconds", a number.
493 This delay is used to give the IDE a chance to handle things
494 before really exiting. The default delay is two seconds.
495 New in version 2.1.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000496 Obsolete in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000497
498setFullName pathname
499 Set the file name to be used for a buffer to "pathname", a
500 string argument.
501 Used when the IDE wants to edit a file under control of the
502 IDE. This makes the buffer the current buffer, but does not
503 read the file. "insert" commands will be used next to set the
504 contents.
505
506setLocAndSize Not implemented.
507
508setMark Not implemented.
509
510setModified modified
511 When the boolean argument "modified" is "T" mark the buffer as
512 modified, when it is "F" mark it as unmodified.
513
Bram Moolenaar009b2592004-10-24 19:18:58 +0000514setModtime time
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000515 Update a buffers modification time after the file has been
516 saved directly by the Vim Controller.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000517 New in version 2.3.
518
519setReadOnly
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000520 Set a file as readonly
521 Implemented in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000522
523setStyle Not implemented.
524
525setTitle name
526 Set the title for the buffer to "name", a string argument.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000527 The title is only used for the Vim Controller functions, not
528 by Vim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000529
530setVisible visible
531 When the boolean argument "visible" is "T", goto the buffer.
532 The "F" argument does nothing.
533
534showBalloon text
535 Show a balloon (popup window) at the mouse pointer position,
536 containing "text", a string argument. The balloon should
537 disappear when the mouse is moved more than a few pixels.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200538 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000539 New in version 2.1.
540
Bram Moolenaar009b2592004-10-24 19:18:58 +0000541specialKeys
542 Map a set of keys (mostly function keys) to be passed back
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000543 to the Vim Controller for processing. This lets regular IDE
544 hotkeys be used from Vim.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000545 Implemented in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000546
547startAtomic Begin an atomic operation. The screen will not be updated
548 until "endAtomic" is given.
549
550startCaretListen
551 Not implemented.
552
553startDocumentListen
554 Mark the buffer to report changes to the IDE with the
555 "insert" and "remove" events. The default is to report
556 changes.
557
558stopCaretListen
559 Not implemented.
560
561stopDocumentListen
562 Mark the buffer to stop reporting changes to the IDE.
563 Opposite of startDocumentListen.
Bram Moolenaar748bf032005-02-02 23:04:36 +0000564 NOTE: if "netbeansBuffer" was used to mark this buffer as a
565 NetBeans buffer, then the buffer is deleted in Vim. This is
566 for compatibility with Sun Studio 10.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000567
568unguard off len
569 Opposite of "guard", remove guarding for a text area.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000570 Also sets the current buffer, if necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000571
572version Not implemented.
573
574
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00005756.4 Functions and Replies *nb-functions*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000576
577getDot Not implemented.
578
579getCursor Return the current buffer and cursor position.
580 The reply is:
581 seqno bufID lnum col off
582 seqno = sequence number of the function
583 bufID = buffer ID of the current buffer (if this is unknown -1
584 is used)
585 lnum = line number of the cursor (first line is one)
586 col = column number of the cursor (in bytes, zero based)
587 off = offset of the cursor in the buffer (in bytes)
588 New in version 2.1.
589
590getLength Return the length of the buffer in bytes.
591 Reply example for a buffer with 5000 bytes:
592 123 5000
593 TODO: explain use of partial line.
594
595getMark Not implemented.
596
Bram Moolenaarc65c4912006-11-14 17:29:46 +0000597getAnno serNum
598 Return the line number of the annotation in the buffer.
599 Argument:
600 serNum serial number of this placed annotation
601 The reply is:
602 123 lnum line number of the annotation
603 123 0 invalid annotation serial number
604 New in version 2.4.
605
Bram Moolenaar071d4272004-06-13 20:20:40 +0000606getModified When a buffer is specified: Return zero if the buffer does not
607 have changes, one if it does have changes.
608 When no buffer is specified (buffer number zero): Return the
609 number of buffers with changes. When the result is zero it's
610 safe to tell Vim to exit.
611 New in version 2.1.
612
613getText Return the contents of the buffer as a string.
614 Reply example for a buffer with two lines
615 123 "first line\nsecond line\n"
616 NOTE: docs indicate an offset and length argument, but this is
617 not implemented.
618
619insert off text
620 Insert "text" before position "off". "text" is a string
621 argument, "off" a number.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000622 "text" should have a "\n" (newline) at the end of each line.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000623 Or "\r\n" when 'fileformat' is "dos". When using "insert" in
624 an empty buffer Vim will set 'fileformat' accordingly.
625 When "off" points to the start of a line the text is inserted
626 above this line. Thus when "off" is zero lines are inserted
627 before the first line.
628 When "off" points after the start of a line, possibly on the
629 NUL at the end of a line, the first line of text is appended
630 to this line. Further lines come below it.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000631 Possible replies:
632 123 no problem
633 123 !message failed
634 Note that the message in the reply is not quoted.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000635 Also sets the current buffer, if necessary.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000636 Does not move the cursor to the changed text.
637 Resets undo information.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000638
639remove off length
640 Delete "length" bytes of text at position "off". Both
641 arguments are numbers.
642 Possible replies:
643 123 no problem
644 123 !message failed
645 Note that the message in the reply is not quoted.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000646 Also sets the current buffer, if necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000647
648saveAndExit Perform the equivalent of closing Vim: ":confirm qall".
649 If there are no changed files or the user does not cancel the
650 operation Vim exits and no result is sent back. The IDE can
651 consider closing the connection as a successful result.
652 If the user cancels the operation the number of modified
653 buffers that remains is returned and Vim does not exit.
654 New in version 2.1.
655
656
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00006576.5 Events *nb-events*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000658
659balloonEval off len type
660 The mouse pointer rests on text for a short while. When "len"
661 is zero, there is no selection and the pointer is at position
662 "off". When "len" is non-zero the text from position "off" to
663 "off" + "len" is selected.
664 Only sent after "enableBalloonEval" was used for this buffer.
665 "type" is not yet defined.
666 Not implemented yet.
667
668balloonText text
669 Used when 'ballooneval' is set and the mouse pointer rests on
670 some text for a moment. "text" is a string, the text under
671 the mouse pointer.
Bram Moolenaar67c53842010-05-22 18:28:27 +0200672 Only when Vim is run with a GUI.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000673 New in version 2.1.
674
675buttonRelease button lnum col
676 Report which button was pressed and the location of the cursor
677 at the time of the release. Only for buffers that are owned
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000678 by the Vim Controller. This event is not sent if the button
679 was released while the mouse was in the status line or in a
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000680 separator line. If col is less than 1 the button release was
Bram Moolenaar071d4272004-06-13 20:20:40 +0000681 in the sign area.
682 New in version 2.2.
683
Bram Moolenaar009b2592004-10-24 19:18:58 +0000684disconnect
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000685 Tell the Vim Controller that Vim is exiting and not to try and
686 read or write more commands.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000687 New in version 2.3.
688
Bram Moolenaar071d4272004-06-13 20:20:40 +0000689fileClosed Not implemented.
690
691fileModified Not implemented.
692
693fileOpened pathname open modified
694 A file was opened by the user.
695 Arguments:
696 pathname string name of the file
697 open boolean always "T"
698 modified boolean always "F"
699
700geometry cols rows x y
701 Report the size and position of the editor window.
702 Arguments:
703 cols number number of text columns
704 rows number number of text rows
705 x number pixel position on screen
706 y number pixel position on screen
707 Only works for Motif.
708
709insert off text
710 Text "text" has been inserted in Vim at position "off".
711 Only fired when enabled, see "startDocumentListen".
712
713invokeAction Not implemented.
714
715keyCommand keyName
716 Reports a special key being pressed with name "keyName", which
717 is a string.
718 Supported key names:
719 F1 function key 1
720 F2 function key 2
721 ...
722 F12 function key 12
723
724 ' ' space (without the quotes)
725 ! exclamation mark
726 ... any other ASCII printable character
727 ~ tilde
728
729 X any unrecognized key
730
731 The key may be prepended by "C", "S" and/or "M" for Control,
732 Shift and Meta (Alt) modifiers. If there is a modifier a dash
733 is used to separate it from the key name. For example:
734 "C-F2".
735 ASCII characters are new in version 2.1.
736
737keyAtPos keyName lnum/col
738 Like "keyCommand" and also report the line number and column
739 of the cursor.
740 New in version 2.1.
741
Bram Moolenaard7f8f5c2009-01-06 15:14:30 +0000742killed A file was deleted or wiped out by the user and the buffer
743 annotations have been removed. The bufID number for this
744 buffer has become invalid. Only for files that have been
745 assigned a bufID number by the IDE.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000746
747newDotAndMark off off
748 Reports the position of the cursor being at "off" bytes into
749 the buffer. Only sent just before a "keyCommand" event.
750
751quit Not implemented.
752
753remove off len
754 Text was deleted in Vim at position "off" with byte length
755 "len".
756 Only fired when enabled, see "startDocumentListen".
757
758revert Not implemented.
759
760save The buffer has been saved and is now unmodified.
761 Only fired when enabled, see "startDocumentListen".
762
763startupDone The editor has finished its startup work and is ready for
764 editing files.
765 New in version 2.1.
766
767unmodified The buffer is now unmodified.
768 Only fired when enabled, see "startDocumentListen".
769
770version vers Report the version of the interface implementation. Vim
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000771 reports "2.4" (including the quotes).
Bram Moolenaar071d4272004-06-13 20:20:40 +0000772
773
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00007746.6 Special messages *nb-special*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000775
776These messages do not follow the style of the messages above. They are
777terminated by a newline character.
778
779ACCEPT Not used.
780
781AUTH password editor -> IDE: First message that the editor sends to the IDE.
782 Must contain the password for the socket server, as specified
783 with the |-nb| argument. No quotes are used!
784
785DISCONNECT IDE -> editor: break the connection. The editor will exit.
786 The IDE must only send this message when there are no unsaved
787 changes!
788
789DETACH IDE -> editor: break the connection without exiting the
790 editor. Used when the IDE exits without bringing down the
791 editor as well.
792 New in version 2.1.
793
794REJECT Not used.
795
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000796
7976.7 Protocol errors *nb-protocol_errors*
798
799These errors occur when a message violates the protocol:
800*E627* *E628* *E629* *E630* *E631* *E632* *E633* *E634* *E635* *E636*
801*E637* *E638* *E639* *E640* *E641* *E642* *E643* *E644* *E645* *E646*
802*E647* *E648* *E649* *E650* *E651* *E652* *E653* *E654*
803
804
Bram Moolenaar071d4272004-06-13 20:20:40 +0000805==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00008067. NetBeans key *netbeans-key*
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000807
808 *:nbkey*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000809:nbkey key Pass the key to the Vim Controller for processing
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000810
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000811When a hot-key has been installed with the specialKeys command, this command
812can be used to generate a hotkey messages to the Vim Controller. The events
813newDotAndMark, keyCommand and keyAtPos are generated (in this order).
814
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000815
816==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00008178. Known problems *netbeans-problems*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000818
819NUL bytes are not possible. For editor -> IDE they will appear as NL
820characters. For IDE -> editor they cannot be inserted.
821
Bram Moolenaar67c53842010-05-22 18:28:27 +0200822A NetBeans session may be initiated with Vim running in a terminal, and
823continued later in a GUI environment after running the |:gui|command. In this
824case, the highlighting defined for the NetBeans annotations may be cleared
825when the ":gui" command sources .gvimrc and this file loads a colorscheme
826that runs the command ":highlight clear".
827New in version 2.5.
828
Bram Moolenaar071d4272004-06-13 20:20:40 +0000829
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000830==============================================================================
8319. Debugging NetBeans protocol *netbeans-debugging*
832
833To debug the Vim protocol, you must first compile Vim with debugging support
834and NetBeans debugging support. See |netbeans-configure| for instructions
835about Vim compiling and how to enable debug support.
836
837When running Vim, set the following environment variables:
838
839 export SPRO_GVIM_DEBUG=netbeans.log
840 export SPRO_GVIM_DLEVEL=0xffffffff
841
842Vim will then log all the incoming and outgoing messages of the NetBeans
843protocol to the file netbeans.log .
844
845The content of netbeans.log after a session looks like this:
846Tue May 20 17:19:27 2008
847EVT: 0:startupDone=0
848CMD 1: (1) create
849CMD 2: (1) setTitle "testfile1.txt"
850CMD 3: (1) setFullName "testfile1.txt"
851EVT(suppressed): 1:remove=3 0 -1
852EVT: 1:fileOpened=0 "d:\\work\\vimWrapper\\vimWrapper2\\pyvimwrapper\\tests\\testfile1.txt" T F
853CMD 4: (1) initDone
854FUN 5: (0) getCursor
855REP 5: 1 1 0 0
856CMD 6: (2) create
857CMD 7: (2) setTitle "testfile2.txt"
858CMD 8: (2) setFullName "testfile2.txt"
859EVT(suppressed): 2:remove=8 0 -1
860EVT: 2:fileOpened=0 "d:\\work\\vimWrapper\\vimWrapper2\\pyvimwrapper\\tests\\testfile2.txt" T F
861CMD 9: (2) initDone
862
863
864==============================================================================
86510. NetBeans External Editor
866
867NOTE: This information is obsolete! Only relevant if you are using an old
868version of NetBeans.
869
870
87110.1. Downloading NetBeans *netbeans-download*
872
873The NetBeans IDE is available for download from netbeans.org. You can download
874a released version, download sources, or use CVS to download the current
875source tree. If you choose to download sources, follow directions from
876netbeans.org on building NetBeans.
877
878Depending on the version of NetBeans you download, you may need to do further
879work to get the required External Editor module. This is the module which lets
880NetBeans work with gvim (or xemacs :-). See http://externaleditor.netbeans.org
881for details on downloading this module if your NetBeans release does not have
882it.
883
884For C, C++, and Fortran support you will also need the cpp module. See
885http://cpp.netbeans.org for information regarding this module.
886
887You can also download Sun ONE Studio from Sun Microsystems, Inc for a 30 day
888free trial. See http://www.sun.com for further details.
889
890
89110.2. NetBeans Key Bindings *netbeans-keybindings*
892
893Vim understands a number of key bindings that execute NetBeans commands.
894These are typically all the Function key combinations. To execute a NetBeans
895command, the user must press the Pause key followed by a NetBeans key binding.
896For example, in order to compile a Java file, the NetBeans key binding is
897"F9". So, while in vim, press "Pause F9" to compile a java file. To toggle a
898breakpoint at the current line, press "Pause Shift F8".
899
900The Pause key is Function key 21. If you don't have a working Pause key and
901want to use F8 instead, use: >
902
903 :map <F8> <F21>
904
905The External Editor module dynamically reads the NetBeans key bindings so vim
906should always have the latest key bindings, even when NetBeans changes them.
907
908
90910.3. Preparing NetBeans for Vim *netbeans-preparation*
910
911In order for NetBeans to work with vim, the NetBeans External Editor module
912must be loaded and enabled. If you have a Sun ONE Studio Enterprise Edition
913then this module should be loaded and enabled. If you have a NetBeans release
914you may need to find another way of obtaining this open source module.
915
916You can check if you have this module by opening the Tools->Options dialog
917and drilling down to the "Modules" list (IDE Configuration->System->Modules).
918If your Modules list has an entry for "External Editor" you must make sure
919it is enabled (the "Enabled" property should have the value "True"). If your
920Modules list has no External Editor see the next section on |obtaining-exted|.
921
922
92310.4. Obtaining the External Editor Module *obtaining-exted*
924
925There are 2 ways of obtaining the External Editor module. The easiest way
926is to use the NetBeans Update Center to download and install the module.
927Unfortunately, some versions do not have this module in their update
928center. If you cannot download via the update center you will need to
929download sources and build the module. I will try and get the module
930available from the NetBeans Update Center so building will be unnecessary.
931Also check http://externaleditor.netbeans.org for other availability options.
932
933To download the External Editor sources via CVS and build your own module,
934see http://externaleditor.netbeans.org and http://www.netbeans.org.
935Unfortunately, this is not a trivial procedure.
936
937
93810.5. Setting up NetBeans to run with Vim *netbeans-setup*
939
940Assuming you have loaded and enabled the NetBeans External Editor module
941as described in |netbeans-preparation| all you need to do is verify that
942the gvim command line is properly configured for your environment.
943
944Open the Tools->Options dialog and open the Editing category. Select the
945External Editor. The right hand pane should contain a Properties tab and
946an Expert tab. In the Properties tab make sure the "Editor Type" is set
947to "Vim". In the Expert tab make sure the "Vim Command" is correct.
948
949You should be careful if you change the "Vim Command". There are command
950line options there which must be there for the connection to be properly
951set up. You can change the command name but that's about it. If your gvim
952can be found by your $PATH then the VIM Command can start with "gvim". If
953you don't want gvim searched from your $PATH then hard code in the full
954Unix path name. At this point you should get a gvim for any source file
955you open in NetBeans.
956
957If some files come up in gvim and others (with different file suffixes) come
958up in the default NetBeans editor you should verify the MIME type in the
959Expert tab MIME Type property. NetBeans is MIME oriented and the External
960Editor will only open MIME types specified in this property.
961
962
Bram Moolenaar071d4272004-06-13 20:20:40 +0000963 vim:tw=78:ts=8:ft=help:norl: