diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index b236214024e3837e40844ec5f60fe1812ba8294d..ad5209aeee6d4edd1d32005fbc2de8bd329b14bc 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt*      For Vim version 7.0aa.  Last change: 2004 Oct 12
+*todo.txt*      For Vim version 7.0aa.  Last change: 2004 Oct 24
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -30,6 +30,14 @@ be worked on, but only if you sponsor Vim development.  See |sponsor|.
 							*known-bugs*
 -------------------- Known bugs and current work -----------------------
 
+Include NetBeans patches (Gordon Prieur, Oct 20)
+    See two messages for list of changed files.  Additionally:
+	doc/eval.txt
+    Docs for message E680.
+
+Line number not updated when inserting a line in anothe window. (Hitier
+Sylvain, Oct 24)
+
 Aborting at the ATTENTION prompt causes trouble:
     buffer remains active, nwindows isn't closed (fixed in buffer.c)
     alternate buffer gets "read error" flag.
@@ -48,6 +56,8 @@ Solved in os_mswin.c.  Add to 6.3?
 
 Patch for Win32 textdomain: NAKADAIRA Yukihiro, Sept 17.
 
+Handling decimal point on keypad: use MapVirtualKey. (Vince Negri, Oct 20)
+
 Valencia: executable("xxd.exe") returns true while "!xxd" doesn't work.
 Works fine for me.  Only in specific environment?
 
@@ -77,6 +87,8 @@ When using "set laststatus=2 cmdheight=2" in the .gvimrc you only get one line
 for the cmdline. (Christian Robinson)  When the Vim window is resized (e.g.,
 xterm with many lines) it's OK.
 
+":e <cfile>" does not expand ~/file, very confusing compared to ":e ~/file".
+
 
 For version 7.0:
 
@@ -193,11 +205,8 @@ For version 7.0:
 	Also: when the environment variable exists, use it.  If it doesn't
 	exist, set it.  Requires good names: $VIM_USER_VIMRC  $VIM_USER_DIR
 
-xterm title: After setting a title, obtaining the title still may result in
-the old one.  Sometimes happens with the test scripts.  Setting the title is
-done with an ESC sequence, obtaining the old title with an X library call.
-Invoking XFlush() before getting the title doesn't help.
 
+-   Edit same file on Unix and from MS-Windows: no warning for swap file.
 -   In the kvim/KDE source files fix the formatting.
 -   KDE version is called "kvim".  Make it "gvim", like the others?
 -   Better configure check for KDE include files from Dan Sharp.
@@ -233,6 +242,7 @@ Invoking XFlush() before getting the title doesn't help.
 -   "INTELLISENSE".  First cleanup the Insert-mode completion.
 	http://www.vim.org/scripts/script.php?script_id=747
 	http://sourceforge.net/projects/insenvim
+	    of http://insenvim.sourceforge.net
 	http://cedet.sourceforge.net/intellisense.shtml (for Emacs)
 	Ivan Villanueva has something for Java.
     Can't call it Intellisense, it is a trademark by Microsoft.
@@ -250,6 +260,7 @@ Invoking XFlush() before getting the title doesn't help.
     info, make a new branch.
     To navigate through the undo tree number the states of the text
     sequentially and make it possible to go through the tree in that order.
+    Use "g+++" to go forward, "g---" to go backward.  Can mix - and +.
     Could also use timestamps (to show the time and/or jump to a state five
     minutes ago). (David Schweikert)
     To go from one state to another: backtrack to a common state, then forward
@@ -269,7 +280,8 @@ Invoking XFlush() before getting the title doesn't help.
     incompatible change.
 7   Support WINDOW TABS.  Works like several pages, each with their own
     split windows.  Patch for GTK 1.2 from Christian Michon, 2004 Jan 6.
-    Also for the console!
+    Also for the console!  In Emacs these are called frames.
+    Use "1gt" - "99gt" to switch to a tab?
 -   EMBEDDING: Make it possible to run Vim inside a window of another program.
     For Xwindows this can be done with XReparentWindow().
     For GTK Neil Bird has a patch to use Vim like a widget.
@@ -299,6 +311,8 @@ Invoking XFlush() before getting the title doesn't help.
     "foldcolumn". (Benji Fisher, 2004 Jun 21)
 -   FileChangedShellPost autocommand event: after (not) reloading a changed
     file.  Can be used to update statusline oslt.
+-   Running a shell command from the GUI still has limitations.  Look into how
+    the Vim shell project can help: http://vimshell.wana.at
 8   When a file is change outside of Vim and unmodified in Vim there is no
     simple way to automatically reload the file.  Either add an option for
     this or make it simple to have the FileChangedShell invoke the normal
@@ -361,7 +375,7 @@ name. (Charles Campbell)
 
 Add gui_mch_browsedir() for Motif, KDE and Mac OS/X.
 
-Translated manual pages: Install German one in /usr/local/man/de/man1/vim.1
+Install vim-it.1 manual page in .../man/it/man1/vim.1
 
 
 Vi incompatibility:
@@ -1014,6 +1028,9 @@ Macintosh:
 8   For xterm need to open a connection to the X server to get the window
     title, which can be slow.  Can also get the title with "<Esc>[21t", no
     need to use X11 calls.  This returns "<Esc>]l{title}<Esc>\".
+6   When the xterm reports the number of colors, a redraw occurs.  This is
+    annoying on a slow connection.  Wait for the xterm to report the number of
+    colors before drawing the screen.  With a timeout.
 8   When the builtin xterm termcap contains codes that are not wanted, need a
     way to avoid using the builtin termcap.
 8   Xterm sends ^[[H for <Home> and ^[[F for <End> in some mode.  Also
@@ -1108,6 +1125,12 @@ I can't reproduce these (if you can, let me know how!):
 
 
 Problems that will (probably) not be solved:
+-   xterm title: The following scenario may occur (esp. when running the Vim
+    test script): Vim 1 sets the title to "file1", then restores the title to
+    "xterm" when exiting with an ESC sequence.  Vim 2 obtains the old title
+    with an X library call, this may result in "file1", because the window
+    manager hasn't processed the "xterm" title yet.  Can apparently only be
+    worked around with a delay.
 -   In a terminal with 'mouse' set such that the mouse is active when entering
     a command line, after executing a shell command that scrolls up the
     display and then pressing ":": Selecting text with the mouse works like
diff --git a/runtime/keymap/bulgarian.vim b/runtime/keymap/bulgarian.vim
new file mode 100644
index 0000000000000000000000000000000000000000..3c80c9ffed8a04558ef145e323643dab844481bd
--- /dev/null
+++ b/runtime/keymap/bulgarian.vim
@@ -0,0 +1,90 @@
+" Vim Keymap file for russian characters, phonetic layout 'yawerty'
+" Useful mainly with utf-8 but may work with other encodings
+
+" Maintainer:   Alberto Mardegan <mardy@despammed.com>
+" Last Changed: 2004 Oct 17
+
+" All characters are given literally, conversion to another encoding (e.g.,
+" UTF-8) should work.
+scriptencoding utf-8
+
+let b:keymap_name = "bg"
+
+loadkeymap
+A	А	CYRILLIC CAPITAL LETTER A
+B	Б	CYRILLIC CAPITAL LETTER BE
+W	Ð’	CYRILLIC CAPITAL LETTER VE
+V	Ð’	CYRILLIC CAPITAL LETTER VE
+G	Г	CYRILLIC CAPITAL LETTER GHE
+D	Д	CYRILLIC CAPITAL LETTER DE
+E	Е	CYRILLIC CAPITAL LETTER IE
+Zh	Ж	CYRILLIC CAPITAL LETTER ZHE
+ZH	Ж	CYRILLIC CAPITAL LETTER ZHE
+Z	З	CYRILLIC CAPITAL LETTER ZE
+I	И	CYRILLIC CAPITAL LETTER I
+J	Й	CYRILLIC CAPITAL LETTER SHORT I
+K	К	CYRILLIC CAPITAL LETTER KA
+L	Л	CYRILLIC CAPITAL LETTER EL
+M	М	CYRILLIC CAPITAL LETTER EM
+N	Н	CYRILLIC CAPITAL LETTER EN
+O	О	CYRILLIC CAPITAL LETTER O
+P	П	CYRILLIC CAPITAL LETTER PE
+R	Р	CYRILLIC CAPITAL LETTER ER
+S	С	CYRILLIC CAPITAL LETTER ES
+T	Т	CYRILLIC CAPITAL LETTER TE
+U	У	CYRILLIC CAPITAL LETTER U
+F	Ф	CYRILLIC CAPITAL LETTER EF
+H	Х	CYRILLIC CAPITAL LETTER HA
+C	Ц	CYRILLIC CAPITAL LETTER TSE
+Ch	Ч	CYRILLIC CAPITAL LETTER CHE
+CH	Ч	CYRILLIC CAPITAL LETTER CHE
+Sh	Ш	CYRILLIC CAPITAL LETTER SHA
+SH	Ш	CYRILLIC CAPITAL LETTER SHA
+Sht	Щ	CYRILLIC CAPITAL LETTER SHCHA
+SHt	Щ	CYRILLIC CAPITAL LETTER SHCHA
+SHT	Щ	CYRILLIC CAPITAL LETTER SHCHA
+Sj	Щ	CYRILLIC CAPITAL LETTER SHCHA
+SJ	Щ	CYRILLIC CAPITAL LETTER SHCHA
+Y	Ъ	CYRILLIC CAPITAL LETTER HARD SIGN
+X	Ь	CYRILLIC CAPITAL LETTER SOFT SIGN
+~	Ю	CYRILLIC CAPITAL LETTER YU
+Ju	Ю	CYRILLIC CAPITAL LETTER YU
+JU	Ю	CYRILLIC CAPITAL LETTER YU
+Q	Я	CYRILLIC CAPITAL LETTER YA
+Ja	Я	CYRILLIC CAPITAL LETTER YA
+JA	Я	CYRILLIC CAPITAL LETTER YA
+a	а	CYRILLIC SMALL LETTER A
+b	б	CYRILLIC SMALL LETTER BE
+w	в	CYRILLIC SMALL LETTER VE
+v	в	CYRILLIC SMALL LETTER VE
+g	г	CYRILLIC SMALL LETTER GHE
+d	д	CYRILLIC SMALL LETTER DE
+e	е	CYRILLIC SMALL LETTER IE
+zh	ж	CYRILLIC SMALL LETTER ZHE
+w	ж	CYRILLIC SMALL LETTER ZHE
+z	з	CYRILLIC SMALL LETTER ZE
+i	и	CYRILLIC SMALL LETTER I
+j	й	CYRILLIC SMALL LETTER SHORT I
+k	к	CYRILLIC SMALL LETTER KA
+l	л	CYRILLIC SMALL LETTER EL
+m	м	CYRILLIC SMALL LETTER EM
+n	н	CYRILLIC SMALL LETTER EN
+o	о	CYRILLIC SMALL LETTER O
+p	п	CYRILLIC SMALL LETTER PE
+r	р	CYRILLIC SMALL LETTER ER
+s	с	CYRILLIC SMALL LETTER ES
+t	Ñ‚	CYRILLIC SMALL LETTER TE
+u	у	CYRILLIC SMALL LETTER U
+f	Ñ„	CYRILLIC SMALL LETTER EF
+h	Ñ…	CYRILLIC SMALL LETTER HA
+c	ц	CYRILLIC SMALL LETTER TSE
+ch	ч	CYRILLIC SMALL LETTER CHE
+sh	ш	CYRILLIC SMALL LETTER SHA
+sht	щ	CYRILLIC SMALL LETTER SHCHA
+sj	щ	CYRILLIC SMALL LETTER SHCHA
+y	ÑŠ	CYRILLIC SMALL LETTER HARD SIGN
+x	ь	CYRILLIC SMALL LETTER SOFT SIGN
+`	ÑŽ	CYRILLIC SMALL LETTER YU
+ju	ÑŽ	CYRILLIC SMALL LETTER YU
+q	я	CYRILLIC SMALL LETTER YA
+ja	я	CYRILLIC SMALL LETTER YA
diff --git a/runtime/lang/menu_ja.ujis.vim b/runtime/lang/menu_ja.ujis.vim
new file mode 100644
index 0000000000000000000000000000000000000000..49248fc74c31553be09b1bfbb6d902d2bdc0fed0
--- /dev/null
+++ b/runtime/lang/menu_ja.ujis.vim
@@ -0,0 +1,6 @@
+" Menu Translations:	Japanese (for UNIX)
+" Translated By:	Muraoka Taro  <koron@tka.att.ne.jp>
+" Last Change:		08:50:47 25-Mar-2001.
+
+" ujis is the same as euc-jp.  Source the other one from here.
+source <sfile>:p:h/menu_ja_jp.euc-jp.vim
diff --git a/runtime/syntax/2html.vim b/runtime/syntax/2html.vim
index ea1e6e7bbc58d3a82acb17c6d1513b1b3691ab84..008221400d00b0986ac6b6408d3688f0642f7eaa 100644
--- a/runtime/syntax/2html.vim
+++ b/runtime/syntax/2html.vim
@@ -1,6 +1,6 @@
 " Vim syntax support file
 " Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2004 Oct 12
+" Last Change: 2004 Oct 15
 "	       (modified by David Ne\v{c}as (Yeti) <yeti@physics.muni.cz>)
 "	       (XHTML support by Panagiotis Issaris <takis@lumumba.luc.ac.be>)
 
@@ -103,6 +103,32 @@ if !exists("html_use_css")
   endfun
 endif
 
+" Return HTML valid characters enclosed in a span of class style_name with
+" unprintable characters expanded and double spaces replaced as necessary.
+function! s:HtmlFormat(text, style_name)
+  " Replace unprintable characters
+  let formatted = strtrans(a:text)
+
+  " Replace the reserved html characters
+  let formatted = substitute(substitute(substitute(substitute(substitute(formatted, '&', '\&amp;', 'g'), '<', '\&lt;', 'g'), '>', '\&gt;', 'g'), '"', '\&quot;', 'g'), "\x0c", '<hr class="PAGE-BREAK">', 'g')
+  
+  " Replace double spaces
+  if ' ' != s:HtmlSpace 
+    let formatted = substitute(formatted, '  ', s:HtmlSpace . s:HtmlSpace, 'g')
+  endif
+
+  " Enclose in a span of class style_name
+  let formatted = '<span class="' . a:style_name . '">' . formatted . '</span>'
+
+  " Add the class to class list if it's not there yet
+  let s:id = hlID(a:style_name)
+  if stridx(s:idlist, "," . s:id . ",") == -1
+    let s:idlist = s:idlist . s:id . ","
+  endif
+
+  return formatted
+endfun
+
 " Return CSS style describing given highlight id (can be empty)
 function! s:CSS1(id)
   let a = ""
@@ -157,7 +183,6 @@ endif
 
 
 " Set some options to make it work faster.
-" Expand tabs in original buffer to get 'tabstop' correctly used.
 " Don't report changes for :substitute, there will be many of them.
 let s:old_title = &title
 let s:old_icon = &icon
@@ -187,18 +212,29 @@ set magic
 
 if exists("use_xhtml")
   exe "normal! a<?xml version=\"1.0\"?>\n\e"
-  let tag_close = '/>'
+  let s:tag_close = '/>'
 else
-  let tag_close = '>'
+  let s:tag_close = '>'
+endif
+
+let s:HtmlSpace = ' '
+let s:HtmlEndline = ''
+if exists("html_no_pre")
+  let s:HtmlEndline = '<br' . s:tag_close
+  if exists("use_xhtml")
+    let s:HtmlSpace = '\&#x20;'
+  else
+    let s:HtmlSpace = '\&nbsp;'
+  endif
 endif
 
 " HTML header, with the title and generator ;-). Left free space for the CSS,
 " to be filled at the end.
 exe "normal! a<html>\n<head>\n<title>\e"
 exe "normal! a" . expand("%:p:~") . "</title>\n\e"
-exe "normal! a<meta name=\"Generator\" content=\"Vim/" . v:version/100 . "." . v:version %100 . '"' . tag_close . "\n\e"
+exe "normal! a<meta name=\"Generator\" content=\"Vim/" . v:version/100 . "." . v:version %100 . '"' . s:tag_close . "\n\e"
 if s:html_encoding != ""
-  exe "normal! a<meta http-equiv=\"content-type\" content=\"text/html; charset=" . s:html_encoding . '"' . tag_close . "\n\e"
+  exe "normal! a<meta http-equiv=\"content-type\" content=\"text/html; charset=" . s:html_encoding . '"' . s:tag_close . "\n\e"
 endif
 if exists("html_use_css")
   exe "normal! a<style type=\"text/css\">\n<!--\n-->\n</style>\n\e"
@@ -214,11 +250,6 @@ exe s:orgwin . "wincmd w"
 " List of all id's
 let s:idlist = ","
 
-let s:expandedtab = ' '
-while strlen(s:expandedtab) < &ts
-  let s:expandedtab = s:expandedtab . ' '
-endwhile
-
 " Loop over all lines in the original text.
 " Use html_start_line and html_end_line if they are set.
 if exists("html_start_line")
@@ -238,35 +269,18 @@ else
   let s:end = line("$")
 endif
 
-" Closed folds are kept in the HTML.  Prepare the closed fold template text.
 if has('folding')
-  let s:c = &fillchars[matchend(&fillchars, 'fold:')]
-  if s:c == ''
-    let s:c = '-'
+  let s:foldfillchar = &fillchars[matchend(&fillchars, 'fold:')]
+  if s:foldfillchar == ''
+    let s:foldfillchar = '-'
   endif
-  let s:htmlfoldtext = '+' . s:c
-  while strlen(s:htmlfoldtext) < &columns
-      let s:htmlfoldtext = s:htmlfoldtext . s:c
-  endwhile
-  unlet s:c
 endif
-
-" For diff filler lines
-if has('diff')
-  if s:numblines
-    let s:fillerline = strpart('        ', 0, strlen(line("$"))) . ' '
-  else
-    let s:fillerline = ''
-  endif
-  let s:fillchar = &fillchars[matchend(&fillchars, 'diff:')]
-  if s:fillchar == ''
-    let s:fillchar = '-'
-  endif
-  while strlen(s:fillerline) < &columns
-      let s:fillerline = s:fillerline . s:fillchar
-  endwhile
+let s:difffillchar = &fillchars[matchend(&fillchars, 'diff:')]
+if s:difffillchar == ''
+  let s:difffillchar = '-'
 endif
 
+
 while s:lnum <= s:end
 
   " If there are filler lines for diff mode, show these above the line.
@@ -274,24 +288,28 @@ while s:lnum <= s:end
   if s:filler > 0
     let s:n = s:filler
     while s:n > 0
+      if s:numblines
+        " Indent if line numbering is on
+        let s:new = repeat(' ', strlen(s:end) + 1) . repeat(s:difffillchar, 3)
+      else
+        let s:new = repeat(s:difffillchar, 3)
+      endif
+
       if s:n > 2 && s:n < s:filler && !exists("html_whole_filler")
-	let s:new = strpart(s:fillerline, 0, 3) . " " . s:filler . " inserted lines "
-	let s:new = s:new . strpart(s:fillerline, strlen(s:new))
+	let s:new = s:new . " " . s:filler . " inserted lines "
 	let s:n = 2
-      else
-	let s:new = s:fillerline
       endif
-      let s:id_name = "DiffDelete"
-      let s:id = hlID(s:id_name)
-      let s:new = '<span class="' . s:id_name . '">' . s:new . '</span>'
-      " Add the class to class list if it's not there yet
-      if stridx(s:idlist, "," . s:id . ",") == -1
-	let s:idlist = s:idlist . s:id . ","
+
+      if !exists("html_no_pre")
+        " HTML line wrapping is off--go ahead and fill to the margin
+        let s:new = s:new . repeat(s:difffillchar, &columns - strlen(s:new))
       endif
 
+      let s:new = s:HtmlFormat(s:new, "DiffDelete")
       exe s:newwin . "wincmd w"
-      exe "normal! a" . strtrans(s:new) . "\n\e"
+      exe "normal! a" . s:new . s:HtmlEndline . "\n\e"
       exe s:orgwin . "wincmd w"
+
       let s:n = s:n - 1
     endwhile
     unlet s:n
@@ -300,35 +318,22 @@ while s:lnum <= s:end
 
   " Start the line with the line number.
   if s:numblines
-    let s:new = strpart('        ', 0, strlen(line("$")) - strlen(s:lnum)) . s:lnum . ' '
+    let s:new = repeat(' ', strlen(s:end) - strlen(s:lnum)) . s:lnum . ' '
   else
     let s:new = ""
   endif
 
-  " Get the current line
-  let s:line = getline(s:lnum)
-
   if has('folding') && foldclosed(s:lnum) > -1
     "
     " This is the beginning of a folded block
     "
-    let s:line = foldtextresult(s:lnum)
-
-    let s:new = s:new . s:line
+    let s:new = s:new . foldtextresult(s:lnum)
     if !exists("html_no_pre")
-      let s:new = s:new . strpart(s:htmlfoldtext, strlen(s:new))
+      " HTML line wrapping is off--go ahead and fill to the margin
+      let s:new = s:new . repeat(s:foldfillchar, &columns - strlen(s:new))
     endif
     
-    " Replace the reserved html characters
-    let s:new = substitute(substitute(substitute(substitute(substitute(s:new, '&', '\&amp;', 'g'), '<', '\&lt;', 'g'), '>', '\&gt;', 'g'), '"', '\&quot;', 'g'), "\x0c", '<hr class="PAGE-BREAK">', 'g')
-   
-    let s:id_name = "Folded"
-    let s:id = hlID(s:id_name)
-    let s:new = '<span class="' . s:id_name . '">' . s:new . '</span>'
-    " Add the class to class list if it's not there yet
-    if stridx(s:idlist, "," . s:id . ",") == -1
-      let s:idlist = s:idlist . s:id . ","
-    endif
+    let s:new = s:HtmlFormat(s:new, "Folded")
 
     " Skip to the end of the fold  
     let s:lnum = foldclosedend(s:lnum)
@@ -337,10 +342,12 @@ while s:lnum <= s:end
     "
     " A line that is not folded.
     "
+    let s:line = getline(s:lnum)
+
     let s:len = strlen(s:line)
 
     if s:numblines
-      let s:new = '<span class="lnr">' . s:new . '</span>  '
+      let s:new = '<span class="lnr">' . s:new . '</span>'
     endif
 
     " Get the diff attribute, if any.
@@ -348,7 +355,7 @@ while s:lnum <= s:end
 
     " Loop over each character in the line
     let s:col = 1
-    while s:col <= s:len
+    while s:col <= s:len || (s:col == 1 && s:diffattr)
       let s:startcol = s:col " The start column for processing text
       if s:diffattr
 	let s:id = diff_hlID(s:lnum, s:col)
@@ -356,11 +363,11 @@ while s:lnum <= s:end
 	" Speed loop (it's small - that's the trick)
 	" Go along till we find a change in hlID
 	while s:col <= s:len && s:id == diff_hlID(s:lnum, s:col) | let s:col = s:col + 1 | endwhile
-	while s:len < &columns
+        if s:len < &columns && !exists("html_no_pre")
 	  " Add spaces at the end to mark the changed line.
-	  let s:line = s:line . ' '
-	  let s:len = s:len + 1
-	endwhile
+          let s:line = s:line . repeat(' ', &columns - s:len)
+          let s:len = &columns
+        endif
       else
 	let s:id = synID(s:lnum, s:col, 1)
 	let s:col = s:col + 1
@@ -369,42 +376,24 @@ while s:lnum <= s:end
 	while s:col <= s:len && s:id == synID(s:lnum, s:col, 1) | let s:col = s:col + 1 | endwhile
       endif
 
+      " Expand tabs
+      let s:expandedtab = strpart(s:line, s:startcol - 1, s:col - s:startcol)
+      let idx = stridx(s:expandedtab, "\t")
+      while idx >= 0
+        let i = &ts - ((idx + s:startcol - 1) % &ts)
+        let s:expandedtab = substitute(s:expandedtab, '\t', repeat(' ', i), '')
+        let idx = stridx(s:expandedtab, "\t")
+      endwhile
+
       " Output the text with the same synID, with class set to {s:id_name}
       let s:id = synIDtrans(s:id)
       let s:id_name = synIDattr(s:id, "name", s:whatterm)
-      let s:new = s:new . '<span class="' . s:id_name . '">' . substitute(substitute(substitute(substitute(substitute(strpart(s:line, s:startcol - 1, s:col - s:startcol), '&', '\&amp;', 'g'), '<', '\&lt;', 'g'), '>', '\&gt;', 'g'), '"', '\&quot;', 'g'), "\x0c", '<hr class="PAGE-BREAK">', 'g') . '</span>'
-      " Add the class to class list if it's not there yet
-      if stridx(s:idlist, "," . s:id . ",") == -1
-	let s:idlist = s:idlist . s:id . ","
-      endif
-
-      if s:col > s:len
-	break
-      endif
+      let s:new = s:new . s:HtmlFormat(s:expandedtab,  s:id_name)
     endwhile
   endif
 
-  " Expand tabs
-  let s:pad=0
-  let s:start = 0
-  let s:idx = stridx(s:line, "\t")
-  while s:idx >= 0
-    let s:i = &ts - ((s:start + s:pad + s:idx) % &ts)
-    let s:new = substitute(s:new, '\t', strpart(s:expandedtab, 0, s:i), '')
-    let s:pad = s:pad + s:i - 1
-    let s:start = s:start + s:idx + 1
-    let s:idx = stridx(strpart(s:line, s:start), "\t")
-  endwhile
-
-  if exists("html_no_pre")
-    if exists("use_xhtml")
-      let s:new = substitute(s:new, '  ', '\&#x20;\&#x20;', 'g') . '<br/>'
-    else
-      let s:new = substitute(s:new, '  ', '\&nbsp;\&nbsp;', 'g') . '<br>'
-    endif
-  endif
   exe s:newwin . "wincmd w"
-  exe "normal! a" . strtrans(s:new) . "\n\e"
+  exe "normal! a" . s:new . s:HtmlEndline . "\n\e"
   exe s:orgwin . "wincmd w"
   let s:lnum = s:lnum + 1
   +
@@ -488,7 +477,7 @@ while s:idlist != ""
 endwhile
 
 " Add hyperlinks
-%s+\(http://\S\{-}\)\(\([.,;:}]\=\(\s\|$\)\)\|[\\"'<>]\|&gt;\|&lt;\)+<A HREF="\1">\1</A>\2+ge
+%s+\(http://\S\{-}\)\(\([.,;:}]\=\(\s\|$\)\)\|[\\"'<>]\|&gt;\|&lt;\|&quot;\)+<A HREF="\1">\1</A>\2+ge
 
 " The DTD
 if exists("html_use_css")
@@ -512,12 +501,13 @@ exe s:newwin . "wincmd w"
 " Save a little bit of memory (worth doing?)
 unlet s:old_et s:old_paste s:old_icon s:old_report s:old_title s:old_search
 unlet s:whatterm s:idlist s:lnum s:end s:fgc s:bgc s:old_magic
-unlet! s:col s:id s:attr s:len s:line s:new s:did_retab s:numblines
+unlet! s:col s:id s:attr s:len s:line s:new s:expandedtab s:numblines
 unlet s:orgwin s:newwin s:orgbufnr
 delfunc s:HtmlColor
+delfunc s:HtmlFormat
 delfunc s:CSS1
 if !exists("html_use_css")
   delfunc s:HtmlOpening
   delfunc s:HtmlClosing
 endif
-silent! unlet s:htmlfoldtext s:fillerline s:diffattr
+silent! unlet s:diffattr s:difffillchar s:foldfillchar s:HtmlSpace s:HtmlEndline
diff --git a/src/eval.c b/src/eval.c
index 8416b578f727b188d0782579e4f1317f5f96bc67..88b954971d5f50704f04564b0da0e47665b3bcc2 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -5570,6 +5570,10 @@ f_has(argvars, retvar)
 #if defined(WIN3264)
 	else if (STRICMP(name, "win95") == 0)
 	    n = mch_windows95();
+#endif
+#ifdef FEAT_NETBEANS_INTG
+	else if (STRICMP(name, "netbeans_enabled") == 0)
+	    n = usingNetbeans;
 #endif
     }
 
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index b462e1f6e17559a31b9b6922ddbf2a0428764379..7ed48b96783f62ab2df95510c90ae1a24ccde9e3 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3208,8 +3208,8 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
 	    workshop_file_opened((char *)curbuf->b_ffname, curbuf->b_p_ro);
 # endif
 # ifdef FEAT_NETBEANS_INTG
-	if (usingNetbeans)
-	    netbeans_file_opened((char *)curbuf->b_ffname);
+	if (usingNetbeans & ((flags & ECMD_SET_HELP) != ECMD_SET_HELP))
+	    netbeans_file_opened(curbuf);
 # endif
     }
 #endif
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index af76d734bf78cd54db8e63cfef15c7b87a443c33..5d0f0819b0bf3e29cef93f7223e6be80b9a0e11c 100644
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -524,6 +524,8 @@ EX(CMD_mzfile,		"mzfile",	ex_mzfile,
 			RANGE|FILE1|NEEDARG|CMDWIN),
 EX(CMD_next,		"next",		ex_next,
 			RANGE|NOTADR|BANG|FILES|EDITCMD|ARGOPT|TRLBAR),
+EX(CMD_nbkey,		"nbkey",	ex_nbkey,
+			EXTRA|NOTADR|NEEDARG),
 EX(CMD_new,		"new",		ex_splitview,
 			BANG|FILE1|RANGE|NOTADR|EDITCMD|ARGOPT|TRLBAR),
 EX(CMD_nmap,		"nmap",		ex_map,
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index bc727733f3fa9cd132187e4873a6724d41736485..6d6d55d0950b0f05af15e3cfa502d424cc617210 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -3309,11 +3309,6 @@ gui_mch_init(void)
     /* Pretend we don't have input focus, we will get an event if we do. */
     gui.in_focus = FALSE;
 
-#ifdef FEAT_NETBEANS_INTG
-    if (usingNetbeans)
-	netbeans_gtk_connect();
-# endif
-
     return OK;
 }
 
diff --git a/src/gui_x11.c b/src/gui_x11.c
index 7087e0208f9ce69bee5f35c00da96f66003d8b7e..e57bb9279ffa7e9fdbaf1329d60682398a965296 100644
--- a/src/gui_x11.c
+++ b/src/gui_x11.c
@@ -1540,10 +1540,6 @@ gui_mch_init()
     if (usingSunWorkShop)
 	workshop_connect(app_context);
 #endif
-#ifdef FEAT_NETBEANS_INTG
-    if (usingNetbeans)
-	netbeans_Xt_connect(app_context);
-#endif
 
 #ifdef FEAT_BEVAL
     gui_init_tooltip_font();
diff --git a/src/main.c b/src/main.c
index 0f63d7848fa68f91e9f6f0024f9d79d0d8ab8a4a..3976a44338ffa71f6e8890e88e59394ceae5195a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1255,6 +1255,20 @@ scripterror:
 #endif
 	    )
     {
+#ifdef NBDEBUG
+	/*
+	 * This shouldn't be necessary. But if I run netbeans with the log
+	 * output coming to the console and XOpenDisplay fails, I get vim
+	 * trying to start with input/output to my console tty.  This fills my
+	 * input buffer so fast I can't even kill the process in under 2
+	 * minutes (and it beeps continuosly the whole time :-)
+	 */
+	if (usingNetbeans && (!stdout_isatty || !input_isatty))
+	{
+	    mch_errmsg(_("Vim: Error: Failure to start gvim from NetBeans\n"));
+	    exit(1);
+	}
+#endif
 	if (!stdout_isatty)
 	    mch_errmsg(_("Vim: Warning: Output is not to a terminal\n"));
 	if (!input_isatty)
diff --git a/src/memline.c b/src/memline.c
index 67d233b9ebdd989cc0aaaff7c3fd71fe9147d98d..a3bd9d7beba591f150ca5ff691367f6de01edb25 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -2462,8 +2462,8 @@ ml_append_int(buf, lnum, line, len, newfile, mark)
     if (usingNetbeans)
     {
 	if (STRLEN(line) > 0)
-	    netbeans_inserted(buf, lnum+1, (colnr_T)0, 0, line, STRLEN(line));
-	netbeans_inserted(buf, lnum+1, (colnr_T)STRLEN(line), 0,
+	    netbeans_inserted(buf, lnum+1, (colnr_T)0, line, STRLEN(line));
+	netbeans_inserted(buf, lnum+1, (colnr_T)STRLEN(line),
 							   (char_u *)"\n", 1);
     }
 #endif
@@ -2500,7 +2500,7 @@ ml_replace(lnum, line, copy)
     if (usingNetbeans)
     {
 	netbeans_removed(curbuf, lnum, 0, (long)STRLEN(ml_get(lnum)));
-	netbeans_inserted(curbuf, lnum, 0, 0, line, STRLEN(line));
+	netbeans_inserted(curbuf, lnum, 0, line, STRLEN(line));
     }
 #endif
     if (curbuf->b_ml.ml_line_lnum != lnum)	    /* other line buffered */
@@ -2605,7 +2605,7 @@ ml_delete_int(buf, lnum, message)
 
 #ifdef FEAT_NETBEANS_INTG
     if (usingNetbeans)
-	netbeans_removed(buf, lnum, 0, line_size);
+	netbeans_removed(buf, lnum, 0, (long)line_size);
 #endif
 
 /*