blob: 4d44965586fc77043976afabf56d52510734365d [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 Moolenaar3577c6f2008-06-24 21:16:56 +0000118Currently, only GVim is supported in this integration as NetBeans does not
119have means to supply a terminal emulator for the Vim command. Furthermore,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000120there is only GUI support for GTK, GNOME, and Motif.
121
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000122If Motif support is required the user must supply XPM libraries. See
Bram Moolenaar071d4272004-06-13 20:20:40 +0000123|workshop-xpm| for details on obtaining the latest version of XPM.
124
125
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000126On MS-Windows:
127--------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000128
129The Win32 support is now in beta stage.
130
131To use XPM signs on Win32 (e.g. when using with NetBeans) you can compile
132XPM by yourself or use precompiled libraries from http://iamphet.nm.ru/misc/
133(for MS Visual C++) or http://gnuwin32.sourceforge.net (for MinGW).
134
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000135Enable debugging:
136-----------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000137
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000138To enable debugging of Vim and of the NetBeans protocol, the "NBDEBUG" macro
139needs to be defined. Search in the Makefile of the platform you are using for
140"NBDEBUG" to see what line needs to be uncommented. This effectively adds
141"-DNBDEBUG" to the compile command. Also see |netbeans-debugging|
Bram Moolenaar071d4272004-06-13 20:20:40 +0000142
143==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00001444. Error Messages *netbeans-messages*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000145
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000146These error messages are specific to NetBeans socket protocol:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000147
148 *E463*
149Region is guarded, cannot modify
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000150 The Vim Controller has defined guarded areas in the text,
151 which you cannot change. Also sets the current buffer, if
152 necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000153
154 *E656*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000155Writes of unmodified buffers forbidden
156 Writes of unmodified buffers that were opened from the
157 Vim Controller are not possible.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000158
159 *E657*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000160Partial writes disallowed
161 Partial writes for buffers that were opened from the
162 Vim Controller are not allowed.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000163
164 *E658*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000165Connection lost for this buffer
166 The Vim Controller has become confused about the state of
167 this file. Rather than risk data corruption, it has severed
168 the connection for this file. Vim will take over
169 responsibility for saving changes to this file and the
170 Vim Controller will no longer know of these changes.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000171
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000172 *E744*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000173Read-only file
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000174 Vim normally allows changes to a read-only file and only
175 enforces the read-only rule if you try to write the file.
176 However, NetBeans does not let you make changes to a file
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000177 which is read-only and becomes confused if Vim does this.
178 So Vim does not allow modifications to files when run
179 in NetBeans mode.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000180
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000181==============================================================================
1825. Running Vim in NetBeans mode *netbeans-run*
183
184Vim must be started with the |-nb| argument. Three forms can be used, that
Bram Moolenaar071d4272004-06-13 20:20:40 +0000185differ in the way the information for the connection is specified:
186
187 -nb={fname} from a file
188 -nb:{hostname}:{addr}:{password} directly
189 -nb from a file or environment
190
191 *E660* *E668*
192For security reasons, the best method is to write the information in a file
193readable only by the user. The name of the file can be passed with the
194"-nb={fname}" argument or, when "-nb" is used without a parameter, the
195environment variable "__NETBEANS_CONINFO". The file must contain these three
196lines, in any order:
197
198 host={hostname}
199 port={addr}
200 auth={password}
201
202Other lines are ignored. The caller of Vim is responsible for deleting the
203file afterwards.
204
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000205{hostname} is the name of the machine where Vim Controller is running. When
206omitted the environment variable "__NETBEANS_HOST" is used or the default
207"localhost".
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000209{addr} is the port number for the NetBeans interface. When omitted the
210environment variable "__NETBEANS_SOCKET" is used or the default 3219.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211
212{password} is the password for connecting to NetBeans. When omitted the
213environment variable "__NETBEANS_VIM_PASSWORD" is used or "changeme".
214
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000215Vim will initiate a socket connection (client side) to the specified host and
216port upon startup. The password will be sent with the AUTH event when the
217connection has been established.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000218
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000219
220==============================================================================
2216. NetBeans protocol *netbeans-protocol*
222
223The communication between the Vim Controller and Vim uses plain text
224messages. This protocol was first designed to work with the external editor
225module of NetBeans. Later it was extended to work with Agide (A-A-P GUI IDE,
226see http://www.a-a-p.org) and then with other IDE. The extensions are marked
227with "version 2.1".
Bram Moolenaar071d4272004-06-13 20:20:40 +0000228
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000229Version 2.2 of the protocol has several minor changes which should only affect
230NetBeans users (ie, not Agide users). However, a bug was fixed which could
231cause confusion. The netbeans_saved() function sent a "save" protocol
232command. In protocol version 2.1 and earlier this was incorrectly interpreted
233as a notification that a write had taken place. In reality, it told NetBeans
234to save the file so multiple writes were being done. This caused various
235problems and has been fixed in 2.2. To decrease the likelihood of this
Bram Moolenaar071d4272004-06-13 20:20:40 +0000236confusion happening again, netbeans_saved() has been renamed to
237netbeans_save_buffer().
238
Bram Moolenaarc65c4912006-11-14 17:29:46 +0000239We are now at version 2.4. For the differences between 2.3 and 2.4 search for
240"2.4" below.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000241
Bram Moolenaar071d4272004-06-13 20:20:40 +0000242The messages are currently sent over a socket. Since the messages are in
243plain UTF-8 text this protocol could also be used with any other communication
244mechanism.
245
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00002466.1 Kinds of messages |nb-messages|
2476.2 Terms |nb-terms|
2486.3 Commands |nb-commands|
2496.4 Functions and Replies |nb-functions|
2506.5 Events |nb-events|
2516.6 Special messages |nb-special|
2526.7 Protocol errors |nb-protocol_errors|
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000253
254
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00002556.1 Kinds of messages *nb-messages*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000256
257There are four kinds of messages:
258
259kind direction comment ~
260Command IDE -> editor no reply necessary
261Function IDE -> editor editor must send back a reply
262Reply editor -> IDE only in response to a Function
263Event editor -> IDE no reply necessary
264
265The messages are sent as a single line with a terminating newline character.
266Arguments are separated by a single space. The first item of the message
267depends on the kind of message:
268
269kind first item example ~
270Command bufID:name!seqno 11:showBalloon!123 "text"
271Function bufID:name/seqno 11:getLength/123
272Reply seqno 123 5000
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000273Event bufID:name=seqno 11:keyCommand=123 "S-F2"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000274
275
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000276
2776.2 Terms *nb-terms*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000278
279bufID Buffer number. A message may be either for a specific buffer
280 or generic. Generic messages use a bufID of zero. NOTE: this
281 buffer ID is assigned by the IDE, it is not Vim's buffer
282 number. The bufID must be a sequentially rising number,
283 starting at one.
284
285seqno The IDE uses a sequence number for Commands and Functions. A
286 Reply must use the sequence number of the Function that it is
287 associated with. A zero sequence number can be used for
288 Events (the seqno of the last received Command or Function can
289 also be used).
290
291string Argument in double quotes. Text is in UTF-8 encoding. This
292 means ASCII is passed as-is. Special characters are
293 represented with a backslash:
294 \" double quote
295 \n newline
296 \r carriage-return
297 \t tab (optional, also works literally)
298 \\ backslash
299 NUL bytes are not allowed!
300
301boolean Argument with two possible values:
302 T true
303 F false
304
305number Argument with a decimal number.
306
307optnum Argument with either a decimal number or "none" (without the
308 quotes).
309
310offset A number argument that indicates a byte position in a buffer.
311 The first byte has offset zero. Line breaks are counted for
312 how they appear in the file (CR/LF counts for two bytes).
313 Note that a multi-byte character is counted for the number of
314 bytes it takes.
315
316lnum/col Argument with a line number and column number position. The
317 line number starts with one, the column is the byte position,
318 starting with zero. Note that a multi-byte character counts
319 for several columns.
320
321pathname String argument: file name with full path.
322
323
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00003246.3 Commands *nb-commands*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000325
326actionMenuItem Not implemented.
327
328actionSensitivity
329 Not implemented.
330
331addAnno serNum typeNum off len
332 Place an annotation in this buffer.
333 Arguments:
334 serNum number serial number of this placed
335 annotation, used to be able to remove
336 it
337 typeNum number sequence number of the annotation
338 defined with defineAnnoType for this
339 buffer
340 off number offset where annotation is to be placed
341 len number not used
342 In version 2.1 "lnum/col" can be used instead of "off".
343
344balloonResult text
345 Not implemented.
346
347close Close the buffer. This leaves us without current buffer, very
348 dangerous to use!
349
350create Creates a buffer without a name. Replaces the current buffer
351 (it's hidden when it was changed).
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000352 The Vim Controller should use this as the first command for a
353 file that is being opened. The sequence of commands could be:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000354 create
355 setCaretListener (ignored)
356 setModified (no effect)
357 setContentType (ignored)
358 startDocumentListen
359 setTitle
360 setFullName
361
362defineAnnoType typeNum typeName tooltip glyphFile fg bg
363 Define a type of annotation for this buffer.
364 Arguments:
365 typeNum number sequence number (not really used)
366 typeName string name that identifies this annotation
367 tooltip string not used
368 glyphFile string name of icon file
369 fg optnum foreground color for line highlighting
370 bg optnum background color for line highlighting
371 Vim will define a sign for the annotation.
372 When both "fg" and "bg" are "none" no line highlighting is
373 used (new in version 2.1).
374 When "glyphFile" is empty, no text sign is used (new in
375 version 2.1).
376 When "glyphFile" is one or two characters long, a text sign is
377 defined (new in version 2.1).
378 Note: the annotations will be defined in sequence, and the
379 sequence number is later used with addAnno.
380
381editFile pathname
382 Set the name for the buffer and edit the file "pathname", a
383 string argument.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000384 Normal way for the IDE to tell the editor to edit a file.
385
386 You must set a bufId different of 0 with this command to
387 assign a bufId to the buffer. It will trigger an event
388 fileOpened with a bufId of 0 but the buffer has been assigned.
389
390 If the IDE is going to pass the file text to the editor use
391 these commands instead:
Bram Moolenaar071d4272004-06-13 20:20:40 +0000392 setFullName
393 insert
394 initDone
395 New in version 2.1.
396
397enableBalloonEval
398 Not implemented.
399
400endAtomic End an atomic operation. The changes between "startAtomic"
401 and "endAtomic" can be undone as one operation. But it's not
402 implemented yet. Redraw when necessary.
403
404guard off len
405 Mark an area in the buffer as guarded. This means it cannot
406 be edited. "off" and "len" are numbers and specify the text
407 to be guarded.
408
409initDone Mark the buffer as ready for use. Implicitly makes the buffer
410 the current buffer. Fires the BufReadPost autocommand event.
411
Bram Moolenaar009b2592004-10-24 19:18:58 +0000412insertDone
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000413 Sent by Vim Controller to tell Vim an initial file insert is
414 done. This triggers a read message being printed. Prior to
415 version 2.3, no read messages were displayed after opening a
416 file. New in version 2.3.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000417
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418moveAnnoToFront serNum
419 Not implemented.
420
421netbeansBuffer isNetbeansBuffer
Bram Moolenaarc236c162008-07-13 17:41:49 +0000422 If "isNetbeansBuffer" is "T" then this buffer is "owned" by
Bram Moolenaar071d4272004-06-13 20:20:40 +0000423 NetBeans.
424 New in version 2.2.
425
426putBufferNumber pathname
427 Associate a buffer number with the Vim buffer by the name
428 "pathname", a string argument. To be used when the editor
429 reported editing another file to the IDE and the IDE needs to
430 tell the editor what buffer number it will use for this file.
431 Also marks the buffer as initialized.
432 New in version 2.1.
433
434raise Bring the editor to the foreground.
435 New in version 2.1.
436
437removeAnno serNum
438 Remove a previously place annotation for this buffer.
439 "serNum" is the same number used in addAnno.
440
441save Save the buffer when it was modified. The other side of the
442 interface is expected to write the buffer and invoke
443 "setModified" to reset the "changed" flag of the buffer.
444 The writing is skipped when one of these conditions is true:
445 - 'write' is not set
446 - the buffer is read-only
447 - the buffer does not have a file name
448 - 'buftype' disallows writing
449 New in version 2.2.
450
Bram Moolenaar009b2592004-10-24 19:18:58 +0000451saveDone
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000452 Sent by Vim Controller to tell Vim a save is done. This
453 triggers a save message being printed. Prior to version 2.3,
454 no save messages were displayed after a save.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000455 New in version 2.3.
456
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457setAsUser Not implemented.
458
459setBufferNumber pathname
460 Associate a buffer number with Vim buffer by the name
461 "pathname". To be used when the editor reported editing
462 another file to the IDE and the IDE needs to tell the editor
463 what buffer number it will use for this file.
464 Has the side effect of making the buffer the current buffer.
465 See "putBufferNumber" for a more useful command.
466
467setContentType
468 Not implemented.
469
470setDot off Make the buffer the current buffer and set the cursor at the
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000471 specified position. If the buffer is open in another window
472 than make that window the current window.
473 If there are folds they are opened to make the cursor line
474 visible.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000475 In version 2.1 "lnum/col" can be used instead of "off".
476
477setExitDelay seconds
478 Set the delay for exiting to "seconds", a number.
479 This delay is used to give the IDE a chance to handle things
480 before really exiting. The default delay is two seconds.
481 New in version 2.1.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000482 Obsolete in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000483
484setFullName pathname
485 Set the file name to be used for a buffer to "pathname", a
486 string argument.
487 Used when the IDE wants to edit a file under control of the
488 IDE. This makes the buffer the current buffer, but does not
489 read the file. "insert" commands will be used next to set the
490 contents.
491
492setLocAndSize Not implemented.
493
494setMark Not implemented.
495
496setModified modified
497 When the boolean argument "modified" is "T" mark the buffer as
498 modified, when it is "F" mark it as unmodified.
499
Bram Moolenaar009b2592004-10-24 19:18:58 +0000500setModtime time
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000501 Update a buffers modification time after the file has been
502 saved directly by the Vim Controller.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000503 New in version 2.3.
504
505setReadOnly
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000506 Set a file as readonly
507 Implemented in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000508
509setStyle Not implemented.
510
511setTitle name
512 Set the title for the buffer to "name", a string argument.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000513 The title is only used for the Vim Controller functions, not
514 by Vim.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000515
516setVisible visible
517 When the boolean argument "visible" is "T", goto the buffer.
518 The "F" argument does nothing.
519
520showBalloon text
521 Show a balloon (popup window) at the mouse pointer position,
522 containing "text", a string argument. The balloon should
523 disappear when the mouse is moved more than a few pixels.
524 New in version 2.1.
525
Bram Moolenaar009b2592004-10-24 19:18:58 +0000526specialKeys
527 Map a set of keys (mostly function keys) to be passed back
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000528 to the Vim Controller for processing. This lets regular IDE
529 hotkeys be used from Vim.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000530 Implemented in version 2.3.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000531
532startAtomic Begin an atomic operation. The screen will not be updated
533 until "endAtomic" is given.
534
535startCaretListen
536 Not implemented.
537
538startDocumentListen
539 Mark the buffer to report changes to the IDE with the
540 "insert" and "remove" events. The default is to report
541 changes.
542
543stopCaretListen
544 Not implemented.
545
546stopDocumentListen
547 Mark the buffer to stop reporting changes to the IDE.
548 Opposite of startDocumentListen.
Bram Moolenaar748bf032005-02-02 23:04:36 +0000549 NOTE: if "netbeansBuffer" was used to mark this buffer as a
550 NetBeans buffer, then the buffer is deleted in Vim. This is
551 for compatibility with Sun Studio 10.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000552
553unguard off len
554 Opposite of "guard", remove guarding for a text area.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000555 Also sets the current buffer, if necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000556
557version Not implemented.
558
559
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00005606.4 Functions and Replies *nb-functions*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000561
562getDot Not implemented.
563
564getCursor Return the current buffer and cursor position.
565 The reply is:
566 seqno bufID lnum col off
567 seqno = sequence number of the function
568 bufID = buffer ID of the current buffer (if this is unknown -1
569 is used)
570 lnum = line number of the cursor (first line is one)
571 col = column number of the cursor (in bytes, zero based)
572 off = offset of the cursor in the buffer (in bytes)
573 New in version 2.1.
574
575getLength Return the length of the buffer in bytes.
576 Reply example for a buffer with 5000 bytes:
577 123 5000
578 TODO: explain use of partial line.
579
580getMark Not implemented.
581
Bram Moolenaarc65c4912006-11-14 17:29:46 +0000582getAnno serNum
583 Return the line number of the annotation in the buffer.
584 Argument:
585 serNum serial number of this placed annotation
586 The reply is:
587 123 lnum line number of the annotation
588 123 0 invalid annotation serial number
589 New in version 2.4.
590
Bram Moolenaar071d4272004-06-13 20:20:40 +0000591getModified When a buffer is specified: Return zero if the buffer does not
592 have changes, one if it does have changes.
593 When no buffer is specified (buffer number zero): Return the
594 number of buffers with changes. When the result is zero it's
595 safe to tell Vim to exit.
596 New in version 2.1.
597
598getText Return the contents of the buffer as a string.
599 Reply example for a buffer with two lines
600 123 "first line\nsecond line\n"
601 NOTE: docs indicate an offset and length argument, but this is
602 not implemented.
603
604insert off text
605 Insert "text" before position "off". "text" is a string
606 argument, "off" a number.
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000607 "text" should have a "\n" (newline) at the end of each line.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000608 Or "\r\n" when 'fileformat' is "dos". When using "insert" in
609 an empty buffer Vim will set 'fileformat' accordingly.
610 When "off" points to the start of a line the text is inserted
611 above this line. Thus when "off" is zero lines are inserted
612 before the first line.
613 When "off" points after the start of a line, possibly on the
614 NUL at the end of a line, the first line of text is appended
615 to this line. Further lines come below it.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000616 Possible replies:
617 123 no problem
618 123 !message failed
619 Note that the message in the reply is not quoted.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000620 Also sets the current buffer, if necessary.
Bram Moolenaar0fd92892006-03-09 22:27:48 +0000621 Does not move the cursor to the changed text.
622 Resets undo information.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000623
624remove off length
625 Delete "length" bytes of text at position "off". Both
626 arguments are numbers.
627 Possible replies:
628 123 no problem
629 123 !message failed
630 Note that the message in the reply is not quoted.
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000631 Also sets the current buffer, if necessary.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000632
633saveAndExit Perform the equivalent of closing Vim: ":confirm qall".
634 If there are no changed files or the user does not cancel the
635 operation Vim exits and no result is sent back. The IDE can
636 consider closing the connection as a successful result.
637 If the user cancels the operation the number of modified
638 buffers that remains is returned and Vim does not exit.
639 New in version 2.1.
640
641
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00006426.5 Events *nb-events*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000643
644balloonEval off len type
645 The mouse pointer rests on text for a short while. When "len"
646 is zero, there is no selection and the pointer is at position
647 "off". When "len" is non-zero the text from position "off" to
648 "off" + "len" is selected.
649 Only sent after "enableBalloonEval" was used for this buffer.
650 "type" is not yet defined.
651 Not implemented yet.
652
653balloonText text
654 Used when 'ballooneval' is set and the mouse pointer rests on
655 some text for a moment. "text" is a string, the text under
656 the mouse pointer.
657 New in version 2.1.
658
659buttonRelease button lnum col
660 Report which button was pressed and the location of the cursor
661 at the time of the release. Only for buffers that are owned
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000662 by the Vim Controller. This event is not sent if the button
663 was released while the mouse was in the status line or in a
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000664 separator line. If col is less than 1 the button release was
Bram Moolenaar071d4272004-06-13 20:20:40 +0000665 in the sign area.
666 New in version 2.2.
667
Bram Moolenaar009b2592004-10-24 19:18:58 +0000668disconnect
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000669 Tell the Vim Controller that Vim is exiting and not to try and
670 read or write more commands.
Bram Moolenaar009b2592004-10-24 19:18:58 +0000671 New in version 2.3.
672
Bram Moolenaar071d4272004-06-13 20:20:40 +0000673fileClosed Not implemented.
674
675fileModified Not implemented.
676
677fileOpened pathname open modified
678 A file was opened by the user.
679 Arguments:
680 pathname string name of the file
681 open boolean always "T"
682 modified boolean always "F"
683
684geometry cols rows x y
685 Report the size and position of the editor window.
686 Arguments:
687 cols number number of text columns
688 rows number number of text rows
689 x number pixel position on screen
690 y number pixel position on screen
691 Only works for Motif.
692
693insert off text
694 Text "text" has been inserted in Vim at position "off".
695 Only fired when enabled, see "startDocumentListen".
696
697invokeAction Not implemented.
698
699keyCommand keyName
700 Reports a special key being pressed with name "keyName", which
701 is a string.
702 Supported key names:
703 F1 function key 1
704 F2 function key 2
705 ...
706 F12 function key 12
707
708 ' ' space (without the quotes)
709 ! exclamation mark
710 ... any other ASCII printable character
711 ~ tilde
712
713 X any unrecognized key
714
715 The key may be prepended by "C", "S" and/or "M" for Control,
716 Shift and Meta (Alt) modifiers. If there is a modifier a dash
717 is used to separate it from the key name. For example:
718 "C-F2".
719 ASCII characters are new in version 2.1.
720
721keyAtPos keyName lnum/col
722 Like "keyCommand" and also report the line number and column
723 of the cursor.
724 New in version 2.1.
725
Bram Moolenaard7f8f5c2009-01-06 15:14:30 +0000726killed A file was deleted or wiped out by the user and the buffer
727 annotations have been removed. The bufID number for this
728 buffer has become invalid. Only for files that have been
729 assigned a bufID number by the IDE.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000730
731newDotAndMark off off
732 Reports the position of the cursor being at "off" bytes into
733 the buffer. Only sent just before a "keyCommand" event.
734
735quit Not implemented.
736
737remove off len
738 Text was deleted in Vim at position "off" with byte length
739 "len".
740 Only fired when enabled, see "startDocumentListen".
741
742revert Not implemented.
743
744save The buffer has been saved and is now unmodified.
745 Only fired when enabled, see "startDocumentListen".
746
747startupDone The editor has finished its startup work and is ready for
748 editing files.
749 New in version 2.1.
750
751unmodified The buffer is now unmodified.
752 Only fired when enabled, see "startDocumentListen".
753
754version vers Report the version of the interface implementation. Vim
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000755 reports "2.4" (including the quotes).
Bram Moolenaar071d4272004-06-13 20:20:40 +0000756
757
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00007586.6 Special messages *nb-special*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000759
760These messages do not follow the style of the messages above. They are
761terminated by a newline character.
762
763ACCEPT Not used.
764
765AUTH password editor -> IDE: First message that the editor sends to the IDE.
766 Must contain the password for the socket server, as specified
767 with the |-nb| argument. No quotes are used!
768
769DISCONNECT IDE -> editor: break the connection. The editor will exit.
770 The IDE must only send this message when there are no unsaved
771 changes!
772
773DETACH IDE -> editor: break the connection without exiting the
774 editor. Used when the IDE exits without bringing down the
775 editor as well.
776 New in version 2.1.
777
778REJECT Not used.
779
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000780
7816.7 Protocol errors *nb-protocol_errors*
782
783These errors occur when a message violates the protocol:
784*E627* *E628* *E629* *E630* *E631* *E632* *E633* *E634* *E635* *E636*
785*E637* *E638* *E639* *E640* *E641* *E642* *E643* *E644* *E645* *E646*
786*E647* *E648* *E649* *E650* *E651* *E652* *E653* *E654*
787
788
Bram Moolenaar071d4272004-06-13 20:20:40 +0000789==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00007907. NetBeans key *netbeans-key*
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000791
792 *:nbkey*
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000793:nbkey key Pass the key to the Vim Controller for processing
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000794
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000795When a hot-key has been installed with the specialKeys command, this command
796can be used to generate a hotkey messages to the Vim Controller. The events
797newDotAndMark, keyCommand and keyAtPos are generated (in this order).
798
Bram Moolenaar65c1b012005-01-31 19:02:28 +0000799
800==============================================================================
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00008018. Known problems *netbeans-problems*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000802
803NUL bytes are not possible. For editor -> IDE they will appear as NL
804characters. For IDE -> editor they cannot be inserted.
805
806
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000807==============================================================================
8089. Debugging NetBeans protocol *netbeans-debugging*
809
810To debug the Vim protocol, you must first compile Vim with debugging support
811and NetBeans debugging support. See |netbeans-configure| for instructions
812about Vim compiling and how to enable debug support.
813
814When running Vim, set the following environment variables:
815
816 export SPRO_GVIM_DEBUG=netbeans.log
817 export SPRO_GVIM_DLEVEL=0xffffffff
818
819Vim will then log all the incoming and outgoing messages of the NetBeans
820protocol to the file netbeans.log .
821
822The content of netbeans.log after a session looks like this:
823Tue May 20 17:19:27 2008
824EVT: 0:startupDone=0
825CMD 1: (1) create
826CMD 2: (1) setTitle "testfile1.txt"
827CMD 3: (1) setFullName "testfile1.txt"
828EVT(suppressed): 1:remove=3 0 -1
829EVT: 1:fileOpened=0 "d:\\work\\vimWrapper\\vimWrapper2\\pyvimwrapper\\tests\\testfile1.txt" T F
830CMD 4: (1) initDone
831FUN 5: (0) getCursor
832REP 5: 1 1 0 0
833CMD 6: (2) create
834CMD 7: (2) setTitle "testfile2.txt"
835CMD 8: (2) setFullName "testfile2.txt"
836EVT(suppressed): 2:remove=8 0 -1
837EVT: 2:fileOpened=0 "d:\\work\\vimWrapper\\vimWrapper2\\pyvimwrapper\\tests\\testfile2.txt" T F
838CMD 9: (2) initDone
839
840
841==============================================================================
84210. NetBeans External Editor
843
844NOTE: This information is obsolete! Only relevant if you are using an old
845version of NetBeans.
846
847
84810.1. Downloading NetBeans *netbeans-download*
849
850The NetBeans IDE is available for download from netbeans.org. You can download
851a released version, download sources, or use CVS to download the current
852source tree. If you choose to download sources, follow directions from
853netbeans.org on building NetBeans.
854
855Depending on the version of NetBeans you download, you may need to do further
856work to get the required External Editor module. This is the module which lets
857NetBeans work with gvim (or xemacs :-). See http://externaleditor.netbeans.org
858for details on downloading this module if your NetBeans release does not have
859it.
860
861For C, C++, and Fortran support you will also need the cpp module. See
862http://cpp.netbeans.org for information regarding this module.
863
864You can also download Sun ONE Studio from Sun Microsystems, Inc for a 30 day
865free trial. See http://www.sun.com for further details.
866
867
86810.2. NetBeans Key Bindings *netbeans-keybindings*
869
870Vim understands a number of key bindings that execute NetBeans commands.
871These are typically all the Function key combinations. To execute a NetBeans
872command, the user must press the Pause key followed by a NetBeans key binding.
873For example, in order to compile a Java file, the NetBeans key binding is
874"F9". So, while in vim, press "Pause F9" to compile a java file. To toggle a
875breakpoint at the current line, press "Pause Shift F8".
876
877The Pause key is Function key 21. If you don't have a working Pause key and
878want to use F8 instead, use: >
879
880 :map <F8> <F21>
881
882The External Editor module dynamically reads the NetBeans key bindings so vim
883should always have the latest key bindings, even when NetBeans changes them.
884
885
88610.3. Preparing NetBeans for Vim *netbeans-preparation*
887
888In order for NetBeans to work with vim, the NetBeans External Editor module
889must be loaded and enabled. If you have a Sun ONE Studio Enterprise Edition
890then this module should be loaded and enabled. If you have a NetBeans release
891you may need to find another way of obtaining this open source module.
892
893You can check if you have this module by opening the Tools->Options dialog
894and drilling down to the "Modules" list (IDE Configuration->System->Modules).
895If your Modules list has an entry for "External Editor" you must make sure
896it is enabled (the "Enabled" property should have the value "True"). If your
897Modules list has no External Editor see the next section on |obtaining-exted|.
898
899
90010.4. Obtaining the External Editor Module *obtaining-exted*
901
902There are 2 ways of obtaining the External Editor module. The easiest way
903is to use the NetBeans Update Center to download and install the module.
904Unfortunately, some versions do not have this module in their update
905center. If you cannot download via the update center you will need to
906download sources and build the module. I will try and get the module
907available from the NetBeans Update Center so building will be unnecessary.
908Also check http://externaleditor.netbeans.org for other availability options.
909
910To download the External Editor sources via CVS and build your own module,
911see http://externaleditor.netbeans.org and http://www.netbeans.org.
912Unfortunately, this is not a trivial procedure.
913
914
91510.5. Setting up NetBeans to run with Vim *netbeans-setup*
916
917Assuming you have loaded and enabled the NetBeans External Editor module
918as described in |netbeans-preparation| all you need to do is verify that
919the gvim command line is properly configured for your environment.
920
921Open the Tools->Options dialog and open the Editing category. Select the
922External Editor. The right hand pane should contain a Properties tab and
923an Expert tab. In the Properties tab make sure the "Editor Type" is set
924to "Vim". In the Expert tab make sure the "Vim Command" is correct.
925
926You should be careful if you change the "Vim Command". There are command
927line options there which must be there for the connection to be properly
928set up. You can change the command name but that's about it. If your gvim
929can be found by your $PATH then the VIM Command can start with "gvim". If
930you don't want gvim searched from your $PATH then hard code in the full
931Unix path name. At this point you should get a gvim for any source file
932you open in NetBeans.
933
934If some files come up in gvim and others (with different file suffixes) come
935up in the default NetBeans editor you should verify the MIME type in the
936Expert tab MIME Type property. NetBeans is MIME oriented and the External
937Editor will only open MIME types specified in this property.
938
939
Bram Moolenaar071d4272004-06-13 20:20:40 +0000940 vim:tw=78:ts=8:ft=help:norl: