1*netbeans.txt* For Vim version 7.0aa. Last change: 2004 Jun 16 2 3 4 VIM REFERENCE MANUAL by Gordon Prieur 5 6 7NetBeans ExternalEditor Integration Features *netbeans* 8 *netbeans-support* 91. Introduction |netbeans-intro| 102. NetBeans Key Bindings |netbeans-keybindings| 113. Configuring Vim for NetBeans |netbeans-configure| 124. Downloading NetBeans |netbeans-download| 135. Preparing NetBeans for Vim |netbeans-preparation| 146. Obtaining the External Editor Module |obtaining-exted| 157. Setting up NetBeans to run with Vim |netbeans-setup| 168. Messages |netbeans-messages| 179. Running Vim from NetBeans |netbeans-run| 1810. NetBeans protocol |netbeans-protocol| 1911. Known problems |netbeans-problems| 20 21{Vi does not have any of these features} 22{only available when compiled with the |+netbeans_intg| feature} 23 24============================================================================== 251. Introduction *netbeans-intro* 26 27NetBeans is an open source Integrated Development Environment developed 28jointly by Sun Microsystems, Inc. and the netbeans.org developer community. 29Initially just a Java IDE, NetBeans has had C, C++, and Fortran support added 30in recent releases. 31 32For more information visit the main NetBeans web site http://www.netbeans.org 33or the NetBeans External Editor site at http://externaleditor.netbeans.org. 34 35Sun Microsystems, Inc. also ships NetBeans under the name Sun ONE Studio. 36Visit http://www.sun.com for more information regarding the Sun ONE Studio 37product line. 38 39Current releases of NetBeans provide full support for Java and limited support 40for C, C++, and Fortran. Current releases of Sun ONE Studio provide full 41support for Java, C, C++, and Fortran. 42 43The interface to NetBeans is also supported by Agide, the A-A-P GUI IDE. 44Agide is very different from NetBeans: 45- Based on Python instead of Java, much smaller footprint and fast startup. 46- Agide is a framework in which many different tools can work together. 47See the A-A-P website for information: http://www.A-A-P.org. 48 49============================================================================== 502. NetBeans Key Bindings *netbeans-keybindings* 51 52Vim understands a number of key bindings that execute NetBeans commands. These 53are typically all the Function key combinations. To execute a NetBeans command, 54the user must press the Pause key followed by a NetBeans key binding. For 55example, in order to compile a Java file, the NetBeans key binding is "F9". So, 56while in vim, press "Pause F9" to compile a java file. To toggle a breakpoint 57at the current line, press "Pause Shift F8". 58 59The Pause key is Function key 21. If you don't have a working Pause key and 60want to use F8 instead, use: > 61 62 :map <F8> <F21> 63 64The External Editor module dynamically reads the NetBeans key bindings so vim 65should always have the latest key bindings, even when NetBeans changes them. 66 67============================================================================== 683. Configuring Vim for NetBeans *netbeans-configure* 69 70For more help installing vim, please read |usr_90.txt| in the Vim User Manual. 71 72 73On Unix 74 75When running configure without arguments the NetBeans interface should be 76included. That is, if the configure check to find out if your system supports 77the required features succeeds. 78 79In case you do not want the NetBeans interface you can disable it by 80uncommenting a line with "--disable-netbeans" in the Makefile. 81 82Currently, only gvim is supported in this integration as NetBeans does not 83have means to supply a terminal emulator for the vim command. Furthermore, 84there is only GUI support for GTK, GNOME, and Motif. 85 86If Motif support is required the user must supply XPM libraries. See 87|workshop-xpm| for details on obtaining the latest version of XPM. 88 89 90On MS-Windows 91 92The Win32 support is now in beta stage. 93 94To use XPM signs on Win32 (e.g. when using with NetBeans) you can compile 95XPM by yourself or use precompiled libraries from http://iamphet.nm.ru/misc/ 96(for MS Visual C++) or http://gnuwin32.sourceforge.net (for MinGW). 97 98============================================================================== 994. Downloading NetBeans *netbeans-download* 100 101The NetBeans IDE is available for download from netbeans.org. You can download 102a released version, download sources, or use CVS to download the current 103source tree. If you choose to download sources, follow directions from 104netbeans.org on building NetBeans. 105 106Depending on the version of NetBeans you download, you may need to do further 107work to get the required External Editor module. This is the module which lets 108NetBeans work with gvim (or xemacs :-). See http://externaleditor.netbeans.org 109for details on downloading this module if your NetBeans release does not have 110it. 111 112For C, C++, and Fortran support you will also need the cpp module. See 113http://cpp.netbeans.org for information regarding this module. 114 115You can also download Sun ONE Studio from Sun Microsystems, Inc for a 30 day 116free trial. See http://www.sun.com for further details. 117 118============================================================================== 1195. Preparing NetBeans for Vim *netbeans-preparation* 120 121In order for NetBeans to work with vim, the NetBeans External Editor module 122must be loaded and enabled. If you have a Sun ONE Studio Enterprise Edition 123then this module should be loaded and enabled. If you have a NetBeans release 124you may need to find another way of obtaining this open source module. 125 126You can check if you have this module by opening the Tools->Options dialog 127and drilling down to the "Modules" list (IDE Configuration->System->Modules). 128If your Modules list has an entry for "External Editor" you must make sure 129it is enabled (the "Enabled" property should have the value "True"). If your 130Modules list has no External Editor see the next section on |obtaining-exted|. 131 132============================================================================== 1336. Obtaining the External Editor Module *obtaining-exted* 134 135There are 2 ways of obtaining the External Editor module. The easiest way 136is to use the NetBeans Update Center to download and install the module. 137Unfortunately, some versions do not have this module in their update 138center. If you cannot download via the update center you will need to 139download sources and build the module. I will try and get the module 140available from the NetBeans Update Center so building will be unnecessary. 141Also check http://externaleditor.netbeans.org for other availability options. 142 143To download the External Editor sources via CVS and build your own module, 144see http://externaleditor.netbeans.org and http://www.netbeans.org. 145Unfortunately, this is not a trivial procedure. 146 147============================================================================== 1487. Setting up NetBeans to run with Vim *netbeans-setup* 149 150Assuming you have loaded and enabled the NetBeans External Editor module 151as described in |netbeans-preparation| all you need to do is verify that 152the gvim command line is properly configured for your environment. 153 154Open the Tools->Options dialog and open the Editing category. Select the 155External Editor. The right hand pane should contain a Properties tab and 156an Expert tab. In the Properties tab make sure the "Editor Type" is set 157to "Vim". In the Expert tab make sure the "Vim Command" is correct. 158 159You should be careful if you change the "Vim Command". There are command 160line options there which must be there for the connection to be properly 161set up. You can change the command name but thats about it. If your gvim 162can be found by your $PATH then the VIM Command can start with "gvim". If 163you don't want gvim searched from your $PATH then hard code in the full 164Unix path name. At this point you should get a gvim for any source file 165you open in NetBeans. 166 167If some files come up in gvim and others (with different file suffixes) come 168up in the default NetBeans editor you should verify the MIME type in the 169Expert tab MIME Type property. NetBeans is MIME oriented and the External 170Editor will only open MIME types specified in this property. 171 172============================================================================== 1738. Messages *netbeans-messages* 174 175These messages are specific for NetBeans: 176 177 *E463* 178Region is guarded, cannot modify 179 NetBeans defines guarded areas in the text, which you cannot 180 change. 181 182 *E656* 183NetBeans disallows writes of unmodified buffers 184 NetBeans does not support writes of unmodified buffers that 185 were opened from NetBeans. 186 187 *E657* 188Partial writes disallowed for NetBeans buffers 189 NetBeans does not support partial writes for buffers that were 190 opened from NetBeans. 191 192 *E658* 193NetBeans connection lost for this buffer 194 NetBeans has become confused about the state of this file. 195 Rather than risc data corruption, NetBeans has severed the 196 connection for this file. Vim will take over responsibility 197 for saving changes to this file and NetBeans will no longer 198 know of these changes. 199 200============================================================================== 2019. Running Vim from NetBeans *netbeans-run* 202 203NetBeans starts Vim with the |-nb| argument. Three forms can be used, that 204differ in the way the information for the connection is specified: 205 206 -nb={fname} from a file 207 -nb:{hostname}:{addr}:{password} directly 208 -nb from a file or environment 209 210 *E660* *E668* 211For security reasons, the best method is to write the information in a file 212readable only by the user. The name of the file can be passed with the 213"-nb={fname}" argument or, when "-nb" is used without a parameter, the 214environment variable "__NETBEANS_CONINFO". The file must contain these three 215lines, in any order: 216 217 host={hostname} 218 port={addr} 219 auth={password} 220 221Other lines are ignored. The caller of Vim is responsible for deleting the 222file afterwards. 223 224{hostname} is the name of the machine where NetBeans is running. When omitted 225the environment variable "__NETBEANS_HOST" is used or the default "localhost". 226 227{addr} is the port number for NetBeans. When omitted the environment variable 228"__NETBEANS_SOCKET" is used or the default 3219. 229 230{password} is the password for connecting to NetBeans. When omitted the 231environment variable "__NETBEANS_VIM_PASSWORD" is used or "changeme". 232 233============================================================================== 23410. NetBeans protocol *netbeans-protocol* 235 236The communication between NetBeans and Vim uses plain text messages. This 237protocol was first designed to work with the external editor module of 238NetBeans (see http://externaleditor.netbeans.org). Later it was extended to 239work with Agide (A-A-P GUI IDE, see http://www.a-a-p.org). The extensions are 240marked with "version 2.1". 241 242Version 2.2 of the protocol has several minor changes which should only 243affect NetBeans users (ie, not Agide users). However, a bug was fixed which 244could cause confusion. The netbeans_saved() function sent a "save" protocol 245command. In protocol version 2.1 and earlier this was incorrectly interpreted 246as a notification that a write had taken place. In reality, it told NetBeans 247to save the file so multiple writes were being done. This caused various 248problems and has been fixed in 2.2. To decrease the likelihood of this 249confusion happening again, netbeans_saved() has been renamed to 250netbeans_save_buffer(). 251 252The messages are currently sent over a socket. Since the messages are in 253plain UTF-8 text this protocol could also be used with any other communication 254mechanism. 255 25610.1 Kinds of messages |nb-messages| 25710.2 Terms |nb-terms| 25810.3 Commands |nb-commands| 25910.4 Functions and Replies |nb-functions| 26010.5 Events |nb-events| 26110.6 Special messages |nb-special| 262 263*E627* *E628* *E629* *E630* *E631* *E632* *E633* *E634* *E635* *E636* 264*E637* *E638* *E639* *E640* *E641* *E642* *E643* *E644* *E645* *E646* 265*E647* *E648* *E649* *E650* *E651* *E652* *E653* *E654* 266These errors occur when a message violates the protocol. 267 268 26910.1 Kinds of messages *nb-messages* 270 271There are four kinds of messages: 272 273kind direction comment ~ 274Command IDE -> editor no reply necessary 275Function IDE -> editor editor must send back a reply 276Reply editor -> IDE only in response to a Function 277Event editor -> IDE no reply necessary 278 279The messages are sent as a single line with a terminating newline character. 280Arguments are separated by a single space. The first item of the message 281depends on the kind of message: 282 283kind first item example ~ 284Command bufID:name!seqno 11:showBalloon!123 "text" 285Function bufID:name/seqno 11:getLength/123 286Reply seqno 123 5000 287Event bufID:name=123 11:keyCommand=123 "S-F2" 288 289 29010.2 Terms *nb-terms* 291 292bufID Buffer number. A message may be either for a specific buffer 293 or generic. Generic messages use a bufID of zero. NOTE: this 294 buffer ID is assigned by the IDE, it is not Vim's buffer 295 number. The bufID must be a sequentially rising number, 296 starting at one. 297 298seqno The IDE uses a sequence number for Commands and Functions. A 299 Reply must use the sequence number of the Function that it is 300 associated with. A zero sequence number can be used for 301 Events (the seqno of the last received Command or Function can 302 also be used). 303 304string Argument in double quotes. Text is in UTF-8 encoding. This 305 means ASCII is passed as-is. Special characters are 306 represented with a backslash: 307 \" double quote 308 \n newline 309 \r carriage-return 310 \t tab (optional, also works literally) 311 \\ backslash 312 NUL bytes are not allowed! 313 314boolean Argument with two possible values: 315 T true 316 F false 317 318number Argument with a decimal number. 319 320optnum Argument with either a decimal number or "none" (without the 321 quotes). 322 323offset A number argument that indicates a byte position in a buffer. 324 The first byte has offset zero. Line breaks are counted for 325 how they appear in the file (CR/LF counts for two bytes). 326 Note that a multi-byte character is counted for the number of 327 bytes it takes. 328 329lnum/col Argument with a line number and column number position. The 330 line number starts with one, the column is the byte position, 331 starting with zero. Note that a multi-byte character counts 332 for several columns. 333 334pathname String argument: file name with full path. 335 336 33710.3 Commands *nb-commands* 338 339actionMenuItem Not implemented. 340 341actionSensitivity 342 Not implemented. 343 344addAnno serNum typeNum off len 345 Place an annotation in this buffer. 346 Arguments: 347 serNum number serial number of this placed 348 annotation, used to be able to remove 349 it 350 typeNum number sequence number of the annotation 351 defined with defineAnnoType for this 352 buffer 353 off number offset where annotation is to be placed 354 len number not used 355 In version 2.1 "lnum/col" can be used instead of "off". 356 357balloonResult text 358 Not implemented. 359 360close Close the buffer. This leaves us without current buffer, very 361 dangerous to use! 362 363create Creates a buffer without a name. Replaces the current buffer 364 (it's hidden when it was changed). 365 NetBeans uses this as the first command for a file that is 366 being opened. The sequence of commands could be: 367 create 368 setCaretListener (ignored) 369 setModified (no effect) 370 setContentType (ignored) 371 startDocumentListen 372 setTitle 373 setFullName 374 375defineAnnoType typeNum typeName tooltip glyphFile fg bg 376 Define a type of annotation for this buffer. 377 Arguments: 378 typeNum number sequence number (not really used) 379 typeName string name that identifies this annotation 380 tooltip string not used 381 glyphFile string name of icon file 382 fg optnum foreground color for line highlighting 383 bg optnum background color for line highlighting 384 Vim will define a sign for the annotation. 385 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. 397 Normal way for the IDE to tell the editor to edit a file. If 398 the IDE is going to pass the file text to the editor use these 399 commands instead: 400 setFullName 401 insert 402 initDone 403 New in version 2.1. 404 405enableBalloonEval 406 Not implemented. 407 408endAtomic End an atomic operation. The changes between "startAtomic" 409 and "endAtomic" can be undone as one operation. But it's not 410 implemented yet. Redraw when necessary. 411 412guard off len 413 Mark an area in the buffer as guarded. This means it cannot 414 be edited. "off" and "len" are numbers and specify the text 415 to be guarded. 416 417initDone Mark the buffer as ready for use. Implicitly makes the buffer 418 the current buffer. Fires the BufReadPost autocommand event. 419 420moveAnnoToFront serNum 421 Not implemented. 422 423netbeansBuffer isNetbeansBuffer 424 If "isNetbeansBuffer" is "T" then this buffer is ``owned'' by 425 NetBeans. 426 New in version 2.2. 427 428putBufferNumber pathname 429 Associate a buffer number with the Vim buffer by the name 430 "pathname", a string argument. To be used when the editor 431 reported editing another file to the IDE and the IDE needs to 432 tell the editor what buffer number it will use for this file. 433 Also marks the buffer as initialized. 434 New in version 2.1. 435 436raise Bring the editor to the foreground. 437 New in version 2.1. 438 439removeAnno serNum 440 Remove a previously place annotation for this buffer. 441 "serNum" is the same number used in addAnno. 442 443save Save the buffer when it was modified. The other side of the 444 interface is expected to write the buffer and invoke 445 "setModified" to reset the "changed" flag of the buffer. 446 The writing is skipped when one of these conditions is true: 447 - 'write' is not set 448 - the buffer is read-only 449 - the buffer does not have a file name 450 - 'buftype' disallows writing 451 New in version 2.2. 452 453setAsUser Not implemented. 454 455setBufferNumber pathname 456 Associate a buffer number with Vim buffer by the name 457 "pathname". To be used when the editor reported editing 458 another file to the IDE and the IDE needs to tell the editor 459 what buffer number it will use for this file. 460 Has the side effect of making the buffer the current buffer. 461 See "putBufferNumber" for a more useful command. 462 463setContentType 464 Not implemented. 465 466setDot off Make the buffer the current buffer and set the cursor at the 467 specified position. If there are folds they are opened to 468 make the cursor line visible. 469 In version 2.1 "lnum/col" can be used instead of "off". 470 471setExitDelay seconds 472 Set the delay for exiting to "seconds", a number. 473 This delay is used to give the IDE a chance to handle things 474 before really exiting. The default delay is two seconds. 475 New in version 2.1. 476 477setFullName pathname 478 Set the file name to be used for a buffer to "pathname", a 479 string argument. 480 Used when the IDE wants to edit a file under control of the 481 IDE. This makes the buffer the current buffer, but does not 482 read the file. "insert" commands will be used next to set the 483 contents. 484 485setLocAndSize Not implemented. 486 487setMark Not implemented. 488 489setModified modified 490 When the boolean argument "modified" is "T" mark the buffer as 491 modified, when it is "F" mark it as unmodified. 492 493setReadOnly Not implemented. 494 495setStyle Not implemented. 496 497setTitle name 498 Set the title for the buffer to "name", a string argument. 499 The title is only used for NetBeans functions, not by Vim. 500 501setVisible visible 502 When the boolean argument "visible" is "T", goto the buffer. 503 The "F" argument does nothing. 504 505showBalloon text 506 Show a balloon (popup window) at the mouse pointer position, 507 containing "text", a string argument. The balloon should 508 disappear when the mouse is moved more than a few pixels. 509 New in version 2.1. 510 511specialKeys Not implemented. 512 513startAtomic Begin an atomic operation. The screen will not be updated 514 until "endAtomic" is given. 515 516startCaretListen 517 Not implemented. 518 519startDocumentListen 520 Mark the buffer to report changes to the IDE with the 521 "insert" and "remove" events. The default is to report 522 changes. 523 524stopCaretListen 525 Not implemented. 526 527stopDocumentListen 528 Mark the buffer to stop reporting changes to the IDE. 529 Opposite of startDocumentListen. 530 531unguard off len 532 Opposite of "guard", remove guarding for a text area. 533 534version Not implemented. 535 536 53710.4 Functions and Replies *nb-functions* 538 539getDot Not implemented. 540 541getCursor Return the current buffer and cursor position. 542 The reply is: 543 seqno bufID lnum col off 544 seqno = sequence number of the function 545 bufID = buffer ID of the current buffer (if this is unknown -1 546 is used) 547 lnum = line number of the cursor (first line is one) 548 col = column number of the cursor (in bytes, zero based) 549 off = offset of the cursor in the buffer (in bytes) 550 New in version 2.1. 551 552getLength Return the length of the buffer in bytes. 553 Reply example for a buffer with 5000 bytes: 554 123 5000 555 TODO: explain use of partial line. 556 557getMark Not implemented. 558 559getModified When a buffer is specified: Return zero if the buffer does not 560 have changes, one if it does have changes. 561 When no buffer is specified (buffer number zero): Return the 562 number of buffers with changes. When the result is zero it's 563 safe to tell Vim to exit. 564 New in version 2.1. 565 566getText Return the contents of the buffer as a string. 567 Reply example for a buffer with two lines 568 123 "first line\nsecond line\n" 569 NOTE: docs indicate an offset and length argument, but this is 570 not implemented. 571 572insert off text 573 Insert "text" before position "off". "text" is a string 574 argument, "off" a number. 575 Possible replies: 576 123 no problem 577 123 !message failed 578 Note that the message in the reply is not quoted. 579 580remove off length 581 Delete "length" bytes of text at position "off". Both 582 arguments are numbers. 583 Possible replies: 584 123 no problem 585 123 !message failed 586 Note that the message in the reply is not quoted. 587 588saveAndExit Perform the equivalent of closing Vim: ":confirm qall". 589 If there are no changed files or the user does not cancel the 590 operation Vim exits and no result is sent back. The IDE can 591 consider closing the connection as a successful result. 592 If the user cancels the operation the number of modified 593 buffers that remains is returned and Vim does not exit. 594 New in version 2.1. 595 596 59710.5 Events *nb-events* 598 599balloonEval off len type 600 The mouse pointer rests on text for a short while. When "len" 601 is zero, there is no selection and the pointer is at position 602 "off". When "len" is non-zero the text from position "off" to 603 "off" + "len" is selected. 604 Only sent after "enableBalloonEval" was used for this buffer. 605 "type" is not yet defined. 606 Not implemented yet. 607 608balloonText text 609 Used when 'ballooneval' is set and the mouse pointer rests on 610 some text for a moment. "text" is a string, the text under 611 the mouse pointer. 612 New in version 2.1. 613 614buttonRelease button lnum col 615 Report which button was pressed and the location of the cursor 616 at the time of the release. Only for buffers that are owned 617 by NetBeans. This event is not sent if the button was 618 released while the mouse was in the status line or in a 619 separator line. If col is less than 1 the button release was 620 in the sign area. 621 New in version 2.2. 622 623fileClosed Not implemented. 624 625fileModified Not implemented. 626 627fileOpened pathname open modified 628 A file was opened by the user. 629 Arguments: 630 pathname string name of the file 631 open boolean always "T" 632 modified boolean always "F" 633 634geometry cols rows x y 635 Report the size and position of the editor window. 636 Arguments: 637 cols number number of text columns 638 rows number number of text rows 639 x number pixel position on screen 640 y number pixel position on screen 641 Only works for Motif. 642 643insert off text 644 Text "text" has been inserted in Vim at position "off". 645 Only fired when enabled, see "startDocumentListen". 646 647invokeAction Not implemented. 648 649keyCommand keyName 650 Reports a special key being pressed with name "keyName", which 651 is a string. 652 Supported key names: 653 F1 function key 1 654 F2 function key 2 655 ... 656 F12 function key 12 657 658 ' ' space (without the quotes) 659 ! exclamation mark 660 ... any other ASCII printable character 661 ~ tilde 662 663 X any unrecognized key 664 665 The key may be prepended by "C", "S" and/or "M" for Control, 666 Shift and Meta (Alt) modifiers. If there is a modifier a dash 667 is used to separate it from the key name. For example: 668 "C-F2". 669 ASCII characters are new in version 2.1. 670 671keyAtPos keyName lnum/col 672 Like "keyCommand" and also report the line number and column 673 of the cursor. 674 New in version 2.1. 675 676killed A file was closed by the user. Only for files that have been 677 assigned a number by the IDE. 678 679newDotAndMark off off 680 Reports the position of the cursor being at "off" bytes into 681 the buffer. Only sent just before a "keyCommand" event. 682 683quit Not implemented. 684 685remove off len 686 Text was deleted in Vim at position "off" with byte length 687 "len". 688 Only fired when enabled, see "startDocumentListen". 689 690revert Not implemented. 691 692save The buffer has been saved and is now unmodified. 693 Only fired when enabled, see "startDocumentListen". 694 695startupDone The editor has finished its startup work and is ready for 696 editing files. 697 New in version 2.1. 698 699unmodified The buffer is now unmodified. 700 Only fired when enabled, see "startDocumentListen". 701 702version vers Report the version of the interface implementation. Vim 703 reports "2.2" (including the quotes). 704 705 70610.6 Special messages *nb-special* 707 708These messages do not follow the style of the messages above. They are 709terminated by a newline character. 710 711ACCEPT Not used. 712 713AUTH password editor -> IDE: First message that the editor sends to the IDE. 714 Must contain the password for the socket server, as specified 715 with the |-nb| argument. No quotes are used! 716 717DISCONNECT IDE -> editor: break the connection. The editor will exit. 718 The IDE must only send this message when there are no unsaved 719 changes! 720 721DETACH IDE -> editor: break the connection without exiting the 722 editor. Used when the IDE exits without bringing down the 723 editor as well. 724 New in version 2.1. 725 726REJECT Not used. 727 728============================================================================== 72911. Known problems *netbeans-problems* 730 731NUL bytes are not possible. For editor -> IDE they will appear as NL 732characters. For IDE -> editor they cannot be inserted. 733 734 735 vim:tw=78:ts=8:ft=help:norl: 736