Commits

vimboss  committed c75153d

updated for version 7.0026

  • Participants
  • Parent commits f529edb

Comments (0)

Files changed (38)

File runtime/doc/change.txt

-*change.txt*    For Vim version 7.0aa.  Last change: 2004 Dec 24
+*change.txt*    For Vim version 7.0aa.  Last change: 2004 Dec 29
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
 or copied with the yank "y" command, regardless of whether or not a specific
 register was used (e.g.  "xdd).  This is like the unnamed register is pointing
 to the last used register.  An exception is the '_' register: "_dd does not
-store the deleted text in any register.  Vim uses the contents of this
-register for any put command (p or P) which does not specify a register.
-Additionally you can access it with the name '"'.  This means you have to type
-two double quotes.  Writing to the "" register writes to register "0.
+store the deleted text in any register.
+Vim uses the contents of the unnamed register for any put command (p or P)
+which does not specify a register.  Additionally you can access it with the
+name '"'.  This means you have to type two double quotes.  Writing to the ""
+register writes to register "0.
 {Vi: register contents are lost when changing files, no '"'}
 
 2. Numbered registers "0 to "9		*quote_number* *quote0*	*quote1*
    Numbered register 1 contains the text deleted by the most recent delete or
 change command, unless the command specified another register or the text is
 less than one line (the small delete register is used then).  An exception is
-made for these commands: |%|, |(|, |)|, |`|, |/|, |?|, |n|, |N|, |{| and |}|.
-Register "1 is always used then (this is Vi compatible).  The "- register is
-used as well if the delete is within a line.
+made for the delete operator with these movement commands: |%|, |(|, |)|, |`|,
+|/|, |?|, |n|, |N|, |{| and |}|.  Register "1 is always used then (this is Vi
+compatible).  The "- register is used as well if the delete is within a line.
    With each successive deletion or change, Vim shifts the previous contents
 of register 1 into register 2, 2 into 3, and so forth, losing the previous
 contents of register 9.

File runtime/doc/editing.txt

-*editing.txt*   For Vim version 7.0aa.  Last change: 2004 Dec 16
+*editing.txt*   For Vim version 7.0aa.  Last change: 2004 Dec 29
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
 			name.  {not in Vi}
 
 All file names are remembered in the buffer list.  When you enter a file name,
-for editing (e.g., with ":e filename") or writing (e.g., with (:w file name"),
+for editing (e.g., with ":e filename") or writing (e.g., with ":w file name"),
 the file name is added to the list.  You can use the buffer list to remember
 which files you edited and to quickly switch from one file to another (e.g.,
 to copy text) with the |CTRL-^| command.  First type the number of the file
 :f[ile]			Prints the current file name (as typed), the
 			cursor position (unless the 'ruler' option is set),
 			and the file status (readonly, modified, read errors,
-			new file)).  See the 'shortmess' option about how tho
+			new file).  See the 'shortmess' option about how tho
 			make this message shorter.  {Vi does not include
 			column number}
 
 keep file names short.  When reading or writing files the full name is still
 used, the "~" is only used when displaying file names.  When replacing the
 file name would result in just "~", "~/" is used instead (to avoid confusion
-with 'backupext' set to "~").
+between options set to $HOME with 'backupext' set to "~").
 
 When writing the buffer, the default is to use the current file name.  Thus
 when you give the "ZZ" or ":wq" command, the original file will be
 
 							*:vi* *:visual*
 :vi[sual][!] [++opt] [+cmd] [file]
-			When entered in Ex mode: Leave |Ex-mode|, go back to
+			When used in Ex mode: Leave |Ex-mode|, go back to
 			Normal mode.  Otherwise same as |:edit|.
 
 							*:vie* *:view*
 :vie[w] [++opt] [+cmd] file
-			When entered in Ex mode: Leave Ex mode, go back to
+			When used in Ex mode: Leave |Ex mode|, go back to
 			Normal mode.  Otherwise same as |:edit|, but set
 			'readonly' option for this buffer.  {not in Vi}
 
 			in Vi}
 
 :[count]wN[ext][!] [++opt] [+cmd] [file]		*:wN* *:wNext*
-:[count]wp[revous][!] [++opt] [+cmd] [file]		*:wp* *:wprevious*
+:[count]wp[revious][!] [++opt] [+cmd] [file]		*:wp* *:wprevious*
 			Same as :wnext, but go to previous file instead of
 			next.  {not in Vi}
 
 
    '**' is more sophisticated:
       - It ONLY matches directories.
-      - It matches up to 30  directories deep, so you can use it to search an
+      - It matches up to 30 directories deep, so you can use it to search an
 	entire directory tree
       - The maximum number of levels matched can be given by appending a number
 	to '**'.

File runtime/doc/fold.txt

-*fold.txt*      For Vim version 7.0aa.  Last change: 2004 Oct 15
+*fold.txt*      For Vim version 7.0aa.  Last change: 2004 Dec 29
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
 		Create a fold for the lines in {range}.  Works like "zf".
 
 							*zd* *E351*
-zd		Delete one fold at the cursor.  When the cursor is on folded
+zd		Delete one fold at the cursor.  When the cursor is on a folded
 		line, that fold is deleted.  Nested folds are moved one level
 		up.  In Visual mode all folds (partially) in the selected area
 		are deleted.  Careful: This easily deletes more folds than you
 
 'foldlevel' is a number option: The higher the more folded regions are open.
 When 'foldlevel' is 0, all folds are closed.
-When 'foldlevel' is positive, some folds closed.
+When 'foldlevel' is positive, some folds are closed.
 When 'foldlevel' is very high, all folds are open.
 'foldlevel' is applied when it is changed.  After that manually folds can be
 opened and closed.

File runtime/doc/gui.txt

-*gui.txt*       For Vim version 7.0aa.  Last change: 2004 Jun 15
+*gui.txt*       For Vim version 7.0aa.  Last change: 2004 Dec 29
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
 	:let bmenu_max_pathlen = 50
 - If the "-U {gvimrc}" command-line option has been used when starting Vim,
   the {gvimrc} file will be read for initializations.  The following
-  initializations are skipped.
+  initializations are skipped.  When {gvimrc} is "NONE" no file will be read
+  for initializations.
 - For Unix and MS-Windows, if the system gvimrc exists, it is sourced.  The
   name of this file is normally "$VIM/gvimrc".  You can check this with
   ":version".  Also see |$VIM|.

File runtime/doc/gui_x11.txt

-*gui_x11.txt*   For Vim version 7.0aa.  Last change: 2004 Jul 02
+*gui_x11.txt*   For Vim version 7.0aa.  Last change: 2004 Dec 29
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
 ==============================================================================
 7. KDE version					*gui-kde* *kde* *KDE* *KVim*
 
+NOTE: The KDE version is still under development.  It is not recommended for
+daily work.
+
 The KDE version of Vim works with KDE 2.x and KDE 3.x.
 KVim (name code for gui-kde) does not use traditional X settings for its
 configuration.

File runtime/doc/index.txt

-*index.txt*     For Vim version 7.0aa.  Last change: 2004 Dec 24
+*index.txt*     For Vim version 7.0aa.  Last change: 2004 Dec 29
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
 ------------------------------------------------------------------------------
 |v_CTRL-\_CTRL-N| CTRL-\ CTRL-N	   stop Visual mode
 |v_CTRL-\_CTRL-G| CTRL-\ CTRL-G	   go to mode specified with 'insertmode'
+|v_CTRL-C|	CTRL-C		   stop Visual mode
 |v_CTRL-G|	CTRL-G		   toggle between Visual mode and Select mode
 |v_<BS>|	<BS>		2  Select mode: delete highlighted area
 |v_CTRL-H|	CTRL-H		2  same as <BS>
 				   command
 |v_CTRL-V|	CTRL-V		   make Visual mode blockwise or stop Visual
 				   mode
+|v_<Esc>|	<Esc>		   stop Visual mode
 |v_CTRL-]|	CTRL-]		   jump to highlighted tag
 |v_!|		!{filter}	2  filter the highlighted lines through the
 				   external command {filter}

File runtime/doc/map.txt

-*map.txt*       For Vim version 7.0aa.  Last change: 2004 Dec 09
+*map.txt*       For Vim version 7.0aa.  Last change: 2004 Dec 29
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
 <		"#i{CURSOR}"	  is expanded to "#include"
 		">#i{CURSOR}"	  is not expanded
 >
-   :ab ;; <endofline>"
+   :ab ;; <endofline>
 <		"test;;"	  is not expanded
 		"test ;;"	  is expanded to "test <endofline>"
 
 	how it should appear in your .exrc file, if you choose to go that
 	route.  The first ^V is there to quote the second ^V; the :ab
 	command uses ^V as its own quote character, so you can include quoted
-	whitespace or the | character in the abbreviation.   The :ab command
+	whitespace or the | character in the abbreviation.  The :ab command
 	doesn't do anything special with the ^[ character, so it doesn't need
 	to be quoted.  (Although quoting isn't harmful; that's why typing 7
 	[but not 8!] ^Vs works.)
 	Later, when the abbreviation is expanded because the user typed in
 	the word "esc", the long form is subjected to the same type of
 	^V interpretation as keyboard input.  So the ^V protects the ^[
-	character from being interpreted as the "exit input-mode" character.
+	character from being interpreted as the "exit Insert mode" character.
 	Instead, the ^[ is inserted into the text.
 
 Expands to: ^[
 the script, it doesn't know in which script the function was defined.  To
 avoid this problem, use "<SID>" instead of "s:".  The same translation is done
 as for mappings.  This makes it possible to define a call to the function in
-mapping.
+a mapping.
 
 When a local function is executed, it runs in the context of the script it was
 defined in.  This means that new functions and mappings it defines can also
 	 Replace <line1>-pu_|<line1>,<line2>d|r <args>|<line1>d
 
    " Count the number of lines in the range
-   :com! -range -nargs=0 Lines :echo <line2> - <line1> + 1 "lines"
+   :com! -range -nargs=0 Lines  echo <line2> - <line1> + 1 "lines"
 
    " Call a user function (example of <f-args>)
    :com -nargs=* Mycmd call Myfunc(<f-args>)

File runtime/doc/motion.txt

-*motion.txt*    For Vim version 7.0aa.  Last change: 2004 Nov 23
+*motion.txt*    For Vim version 7.0aa.  Last change: 2004 Dec 29
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
 
 							*'^* *`^*
 '^  `^			To the position where the cursor was the last time
-			when Insert mode was stopped  This is used by the |gi|
-			command.  Not set when the |:keepjumps| command
+			when Insert mode was stopped.  This is used by the
+			|gi| command.  Not set when the |:keepjumps| command
 			modifier was used.  {not in Vi}
 
 							*'.* *`.*

File runtime/doc/pi_expl.txt

-*pi_expl.txt*   For Vim version 7.0aa.  Last change: 2002 Nov 08
+*pi_expl.txt*   For Vim version 7.0aa.  Last change: 2004 Dec 29
 
 
 		  VIM REFERENCE MANUAL    by M A Aziz Ahmed
 The default for this is the setting of splitbelow at the time the plugin is
 loaded.
 
-To control where the windows goes relative to the explorer window when
+To control where the window goes relative to the explorer window when
 splitting vertically, use the variable: >
   let g:explSplitRight=1    " Put new window to the right of the explorer
   let g:explSplitRight=0    " Put new window to the left of the explorer
 			    " current window
   let g:explStartRight=0    " Put new explorer window to the left of the
 			    " current window
-The default for this set to g:explSplitRight at the time the plugin is loaded.
+The default is the value of g:explSplitRight at the time the plugin is loaded.
 
 To use a different split method for the explorer window, use: >
   let g:explStartBelow=1    " Put new explorer window below the
 			    " current window
   let g:explStartBelow=0    " Put new explorer window above the
 			    " current window
-The default for this set to g:explSplitBelow at the time the plugin is loaded.
+The default is the value of g:explSplitBelow at the time the plugin is loaded.
 
 The start splits allow for the explorer window to be placed in a file browser
 type arrangement, where the directories are shown on the left and the contents

File runtime/doc/tags

 :vi	editing.txt	/*:vi*
 :vie	editing.txt	/*:vie*
 :view	editing.txt	/*:view*
+:vim	quickfix.txt	/*:vim*
+:vimgrep	quickfix.txt	/*:vimgrep*
+:vimgrepa	quickfix.txt	/*:vimgrepa*
+:vimgrepadd	quickfix.txt	/*:vimgrepadd*
 :visual	editing.txt	/*:visual*
 :visual_example	visual.txt	/*:visual_example*
 :viu	various.txt	/*:viu*
 hebrew.txt	hebrew.txt	/*hebrew.txt*
 help	various.txt	/*help*
 help-context	help.txt	/*help-context*
-help-tags	tags	1
 help-translated	various.txt	/*help-translated*
 help-xterm-window	various.txt	/*help-xterm-window*
 help.txt	help.txt	/*help.txt*
 new-utf-8	version6.txt	/*new-utf-8*
 new-vertsplit	version6.txt	/*new-vertsplit*
 new-vim-server	version6.txt	/*new-vim-server*
+new-vimgrep	version7.txt	/*new-vimgrep*
 new-virtedit	version6.txt	/*new-virtedit*
 news	intro.txt	/*news*
 nextnonblank()	eval.txt	/*nextnonblank()*

File runtime/doc/usr_40.txt

-*usr_40.txt*	For Vim version 7.0aa.  Last change: 2004 Feb 13
+*usr_40.txt*	For Vim version 7.0aa.  Last change: 2004 Dec 29
 
 		     VIM USER MANUAL - by Bram Moolenaar
 
 different.  The <F2> mapping for Normal mode is still there.  Thus you can map
 the same key differently for each mode.
    Notice that, although this mapping starts in Insert mode, it ends in Normal
-mode.  If you want it to continue in Insert mode, append a "a" to the mapping.
+mode.  If you want it to continue in Insert mode, append an "a" to the
+mapping.
 
 Here is an overview of map commands and in which mode they work:
 

File runtime/doc/visual.txt

-*visual.txt*    For Vim version 7.0aa.  Last change: 2004 Jun 08
+*visual.txt*    For Vim version 7.0aa.  Last change: 2004 Dec 29
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
 after the Visual area, the character under the cursor is not included.
 
 With "v" the text before the start position and after the end position will
-not be highlighted.  However, All uppercase and non-alpha operators, except
+not be highlighted.  However, all uppercase and non-alpha operators, except
 "~" and "U", will work on whole lines anyway.  See the list of operators
 below.
 
 If you want to highlight exactly the same area as the last time, you can use
 "gv" |gv| |v_gv|.
 
+							*v_<Esc>*
+<Esc>			In Visual mode: Stop Visual mode.
+
 							*v_CTRL-C*
 CTRL-C			In Visual mode: Stop Visual mode.  When insert mode is
 			pending (the mode message shows
 that window is adjusted, so that the same Visual area is still selected.  This
 is especially useful to view the start of the Visual area in one window, and
 the end in another.  You can then use <RightMouse> (or <S-LeftMouse> when
-'mousemodel' is "popup") to move either end of the Visual area.
+'mousemodel' is "popup") to drag either end of the Visual area.
 
 ==============================================================================
 4. Operating on the Visual area				*visual-operators*
 Visual-block Examples					*blockwise-examples*
 With the following text, I will indicate the commands to produce the block and
 the results below. In all cases, the cursor begins on the 'a' in the first
-line if the test text.
+line of the test text.
 The following modeline settings are assumed ":ts=8:sw=4:".
 
 It will be helpful to

File runtime/doc/windows.txt

-*windows.txt*   For Vim version 7.0aa.  Last change: 2004 Dec 21
+*windows.txt*   For Vim version 7.0aa.  Last change: 2004 Dec 29
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
 
 			1 #h  "/test/text"		line 1 ~
 			2u    "asdf"			line 0 ~
-			3 %l+ "version.c"		line 1 ~
+			3 %a+ "version.c"		line 1 ~
 
 		When the [!] is included the list will show unlisted buffers
 		(the term "unlisted" is a bit confusing then...).

File runtime/indent/php.vim

 " Author:	Miles Lott <milos@groupwhere.org>
 " URL:		http://milosch.dyndns.org/php.vim
 " Last Change:	2004 May 18
-" Version:	0.5
+" Version:	0.4
 " Notes:  Close all switches with default:\nbreak; and it will look better.
 "         Also, open and close brackets should be alone on a line.
 "         This is my preference, and the only way this will look nice.
 "         switch/case.  It is nearly perfect for anyone regardless of your
 "         stance on brackets.
 "
-" Changes: 0.5 - fix duplicate indent on open tag, and empty bracketed
-"          statements.
-"          0.4 - Fixes for closing php tag, switch statement closure, and php_indent_shortopentags
+" Changes: Fixes for closing php tag, switch statement closure, and php_indent_shortopentags
 "          option from Steffen Bruentjen <vim@kontraphon.de>
 "
 " Options: php_noindent_switch=1 -- do not try to indent switch/case statements (version 0.1 behavior)
 	let pline = getline(lnum - 1) " previous to last line
 	let ind = indent(lnum)
 
-	" Indent after php open tag
+	" Indent after php open tags
 	if line =~ '<?php'
 		let ind = ind + &sw
-	elseif exists('g:php_indent_shortopentags')
-		" indent after short open tag
+		" indent after short open tags
+	endif
+	if exists('g:php_indent_shortopentags')
 		if line =~ '<?'
 			let ind = ind + &sw
 		endif
 	endif
-	" indent after php closing tag
 	if cline =~ '\M?>'
 		let ind = ind - &sw
 	endif
 			let ind = ind - &sw
 		endif
 		return ind
-	else
-		" Search the matching bracket (with searchpair()) and set the indent of
-		" to the indent of the matching line.
-		if cline =~ '^\s*}'
-			call cursor(line('.'), 1)
-			let ind = indent(searchpair('{', '', '}',
-			'bW', 'synIDattr(synID(line("."), col("."),
-			0), "name") =~? "string"'))
-			return ind
-		endif
-		" Try to indent switch/case statements as well
+	else " Try to indent switch/case statements as well
 		" Indent blocks enclosed by {} or () or case statements, with some anal requirements
 		if line =~ 'case.*:\|[{(]\s*\(#[^)}]*\)\=$'
 			let ind = ind + &sw
 		" Search the matching bracket (with searchpair()) and set the indent of cline
 		" to the indent of the matching line.
 		if cline =~ '^\s*}'
-			call cursor(line('. '), 1)
+			call cursor(line('.'), 1)
 			let ind = indent(searchpair('{', '', '}', 'bW', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"'))
 			return ind
 		endif

File runtime/lang/menu_zh.big5.vim

-source <sfile>:p:h/menu_chinese(taiwan)_taiwan.950.vim
+source <sfile>:p:h/menu_chinese_taiwan.950.vim

File runtime/lang/menu_zh_tw.big5.vim

-source <sfile>:p:h/menu_chinese(taiwan)_taiwan.950.vim
+source <sfile>:p:h/menu_chinese_taiwan.950.vim

File runtime/plugin/netrw.vim

 " netrw.vim: Handles file transfer and remote directory listing across a network
-" last change:	Dec 06, 2004
+" last change:	Dec 29, 2004
 " Maintainer:	Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz>
-" Version:	53
+" Version:	54
 " License:	Vim License  (see vim's :help license)
 "
 "  But be doers of the Word, and not only hearers, deluding your own selves
 if exists("g:loaded_netrw") || &cp
   finish
 endif
-let g:loaded_netrw  = "v53"
+let g:loaded_netrw  = "v54"
 let s:save_cpo      = &cpo
 let loaded_explorer = 1
 set cpo&vim
    au BufReadCmd  file://localhost/*	exe "silent doau BufReadPre ".expand("<afile>")|exe 'e /'.substitute(expand("<afile>"),"file:/*","","")|exe "silent doau BufReadPost ".expand("<afile>")
   endif
   au BufReadCmd   ftp://*,rcp://*,scp://*,http://*,dav://*,rsync://*,sftp://*	exe "silent doau BufReadPre ".expand("<afile>")|exe "Nread 0r ".expand("<afile>")|exe "silent doau BufReadPost ".expand("<afile>")
-  au FileReadCmd  ftp://*,rcp://*,scp://*,http://*,dav://*,rsync://*,sftp://*	exe "silent doau BufReadPre ".expand("<afile>")|exe "Nread "   .expand("<afile>")|exe "silent doau BufReadPost ".expand("<afile>")
+  au FileReadCmd  ftp://*,rcp://*,scp://*,http://*,dav://*,rsync://*,sftp://*	exe "silent doau BufReadPre ".expand("<afile>")|exe "Nread "   .expand("<afile>")|exe "silent doau FileReadPost ".expand("<afile>")
   au BufWriteCmd  ftp://*,rcp://*,scp://*,dav://*,rsync://*,sftp://*    	exe "silent doau BufWritePre ".expand("<afile>")|exe "Nwrite " .expand("<afile>")|exe "silent doau BufWritePost ".expand("<afile>")
-  au FileWriteCmd ftp://*,rcp://*,scp://*,dav://*,rsync://*,sftp://*    	exe "silent doau BufWritePre ".expand("<afile>")|exe "'[,']Nwrite " .expand("<afile>")|exe "silent doau BufWritePost ".expand("<afile>")
+  au FileWriteCmd ftp://*,rcp://*,scp://*,dav://*,rsync://*,sftp://*    	exe "silent doau BufWritePre ".expand("<afile>")|exe "'[,']Nwrite " .expand("<afile>")|exe "silent doau FileWritePost ".expand("<afile>")
  augroup END
 endif
 
 fun! <SID>NetRestorePosn()
 "  call Dfunc("NetRestorePosn() winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline)
 
+  " restore window
+"  call Decho("restore window: exe silent! ".s:netrw_winnr."wincmd w")
   exe "silent! ".s:netrw_winnr."wincmd w"
   if v:shell_error == 0
    " as suggested by Bram M: redraw on no error
    " allows protocol error messages to remain visible
    redraw!
   endif
+
   " restore top-of-screen line
+"  call Decho("restore topofscreen: exe norm! ".s:netrw_hline."G0z")
   exe "norm! ".s:netrw_hline."G0z\<CR>"
+
   " restore position
+"  call Decho("restore posn: exe norm! ".s:netrw_line."G0".s:netrw_col."|")
   exe "norm! ".s:netrw_line."G0".s:netrw_col."\<bar>"
 
 "  call Dret("NetRestorePosn")
 "   call Decho("(copied) fname<".fname.">")
   endif
  
-  " get the file, but disable undo when reading a new buffer
   if a:readcmd[0] == '0'
-   let use_e_cmd = 0		" 1 when using ':edit'
-   let delline   = 0		" 1 when have to delete empty last line
-   if line("$") == 1 && getline(1) == ""
-    " Now being asked to 0r a file into an empty file.
-    " Safe to :e it instead, unless there is another window on the same buffer.
-    let curbufnr  = bufnr("%")
-    let use_e_cmd = 1
-    let delline   = 1
-    " Loop over all windows,
-    " reset use_e_cmd when another one is editing the current buffer.
-    let i = 1
-    while 1
-      if i != winnr() && winbufnr(i) == curbufnr
-        let use_e_cmd = 0
-        break
-      endif
-      let i = i + 1
-      if winbufnr(i) < 0
-        break
-      endif
-    endwhile
-   endif
- 
-   if use_e_cmd > 0
-    " ':edit' the temp file, wipe out the old buffer and rename the buffer
-    let curfilename = expand("%")
- 
-    let binlocal = &l:bin
-    let binglobal = &g:bin
-    if binlocal
-      setglobal bin		" Need to set 'bin' globally for ":e" command.
-    endif
-    silent exe "e! ".v:cmdarg." ".fname
-    if binlocal && !binglobal
-      setglobal nobin
-      setlocal bin
-    endif
- 
-    exe curbufnr . "bwipe!"
-    exe "f ".escape(curfilename," ")
-    " the ":f newname" apparently leaves the temporary file as the alternate
-    " file in the buffer list (see :ls!).  The following command wipes it out.
-    exe bufnr("#")."bwipe!"
-   else
-    let oldul= &ul
-    setlocal ul=-1
-    exe a:readcmd." ".v:cmdarg." ".escape(fname," ")
-    if delline > 0
-     " wipe out last line, which should be a blank line anyway
-     $del
-    endif
-    let &ul= oldul
-   endif
+  " get file into buffer
+   " record remote filename
+   let rfile= bufname("%")
+"   call Decho("edit remotefile<".rfile.">")
+   " rename the current buffer to the temp file (ie. fname)
+   exe "keepalt file ".fname
+   " edit temporary file
+   e
+   " rename buffer back to remote filename
+   exe "keepalt file ".rfile
+   " wipe out the buffer with the temp file name
+   exe "bwipe ".fname
+   let line1 = 1
+   let line2 = line("$")
+
   elseif filereadable(fname)
-"   call Decho("exe<".a:readcmd." ".v:cmdarg." ".fname.">")
+   " read file after current line
+   let curline = line(".")
+   let lastline= line("$")
+"   call Decho("exe<".a:readcmd." ".v:cmdarg." ".fname.">  line#".curline)
    exe a:readcmd." ".v:cmdarg." ".fname
+   let line1        = curline + 1
+   let line2        = line("$") - lastline + 1
+   let s:netrw_line = s:netrw_line + 1
+   let s:netrw_col  = 1
   else
-"   call Dret("NetGetFile")
+   " not readable
+"   call Dret("NetGetFile : fname<".fname."> not readable")
    return
   endif
  
   " User-provided (ie. optional) fix-it-up command
   if exists("*NetReadFixup")
-   let line1= line(".")
-   if a:readcmd == "r"
-    let line2= line("$") - line2 + line1
-   else
-    let line2= line("$") - line2
-   endif
 "   call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")")
    call NetReadFixup(a:method, line1, line2)
   endif
 "   call Decho("scp://...")
    let b:netrw_method = 4
    let g:netrw_machine= substitute(a:choice,scpurm,'\1',"")
-   let b:netrw_port   = substitute(a:choice,scpurm,'\2',"")
+   let g:netrw_port   = substitute(a:choice,scpurm,'\2',"")
    let b:netrw_fname  = substitute(a:choice,scpurm,'\3',"")
  
   " http://user@hostname/...path-to-file
    let g:netrw_machine= substitute(a:choice,ftpurm,'\3',"")
    let g:netrw_port   = substitute(a:choice,ftpurm,'\4',"")
    let b:netrw_fname  = substitute(a:choice,ftpurm,'\5',"")
-   if g:netrw_port != ""
-     let g:netrw_port = substitute(g:netrw_port,"[#:]","","")
-   endif
    if userid != ""
     let g:netrw_uid= userid
    endif
    endif
    let b:netrw_method  = -1
   endif
+
+  " remove any leading [:#] from port number
+  if g:netrw_port != ""
+    let g:netrw_port = substitute(g:netrw_port,'[#:]\+','','')
+  endif
  
 "  call Decho("a:choice       <".a:choice.">")
 "  call Decho("b:netrw_method <".b:netrw_method.">")

File src/Makefile

 # automatically be used if it is found.  If you have GNOME, but do not want to
 # use it (e.g., want a GTK-only version), then use --enable-gui=gtk.
 #
+# KDE doesn't fully work, unfortunately.  See the todo list.
+#
 # If the selected GUI isn't found, the GUI is disabled automatically
 #CONF_OPT_GUI = --enable-gui=gtk
 #CONF_OPT_GUI = --enable-gui=gtk --disable-gtktest

File src/buffer.c

 #endif
     buf->b_u_synced = TRUE;
     buf->b_flags = BF_CHECK_RO | BF_NEVERLOADED;
+    if (flags & BLN_DUMMY)
+	buf->b_flags |= BF_DUMMY;
     buf_clear_file(buf);
     clrallmarks(buf);			/* clear marks */
     fmarks_check_names(buf);		/* check file marks for this file */
     }
 }
 
+#if defined(FEAT_QUICKFIX) || defined(FEAT_EVAL) || defined(PROTO)
+/*
+ * Find file in buffer list by name (it has to be for the current window).
+ * Returns NULL if not found.
+ */
+    buf_T *
+buflist_findname_exp(fname)
+    char_u *fname;
+{
+    char_u	*ffname;
+    buf_T	*buf = NULL;
+
+    /* First make the name into a full path name */
+    ffname = FullName_save(fname,
+#ifdef UNIX
+	    TRUE	    /* force expansion, get rid of symbolic links */
+#else
+	    FALSE
+#endif
+	    );
+    if (ffname != NULL)
+    {
+	buf = buflist_findname(ffname);
+	vim_free(ffname);
+    }
+    return buf;
+}
+#endif
+
 /*
  * Find file in buffer list by name (it has to be for the current window).
  * "ffname" must have a full path.
+ * Skips dummy buffers.
+ * Returns NULL if not found.
  */
     buf_T *
 buflist_findname(ffname)
 /*
  * Same as buflist_findname(), but pass the stat structure to avoid getting it
  * twice for the same file.
+ * Returns NULL if not found.
  */
     static buf_T *
 buflist_findname_stat(ffname, stp)
     buf_T	*buf;
 
     for (buf = firstbuf; buf != NULL; buf = buf->b_next)
-	if (!otherfile_buf(buf, ffname
+	if ((buf->b_flags & BF_DUMMY) == 0 && !otherfile_buf(buf, ffname
 #ifdef UNIX
 		    , stp
 #endif
 setfname(buf, ffname, sfname, message)
     buf_T	*buf;
     char_u	*ffname, *sfname;
-    int		message;
+    int		message;	/* give message when buffer already exists */
 {
-    buf_T	*obuf;
+    buf_T	*obuf = NULL;
 #ifdef UNIX
     struct stat st;
 #endif
 #ifdef UNIX
 	if (mch_stat((char *)ffname, &st) < 0)
 	    st.st_dev = (dev_T)-1;
-	obuf = buflist_findname_stat(ffname, &st);
+#endif
+	if (!(buf->b_flags & BF_DUMMY))
+#ifdef UNIX
+	    obuf = buflist_findname_stat(ffname, &st);
 #else
-	obuf = buflist_findname(ffname);
+	    obuf = buflist_findname(ffname);
 #endif
 	if (obuf != NULL && obuf != buf)
 	{

File src/charset.c

 }
 
 /*
- * return TRUE if 'c' is a normal identifier character
- * letters and characters from 'isident' option.
+ * Return TRUE if 'c' is a normal identifier character:
+ * Letters and characters from the 'isident' option.
  */
     int
 vim_isIDc(c)

File src/configure.in

   AC_MSG_RESULT(GTK+ 2 GUI selected; fontset has been disabled)
   enable_fontset="no"
 fi
+if test "x$GUITYPE:$enable_fontset" = "xKDE:yes"; then
+  AC_MSG_RESULT(KDE GUI selected; fontset has been disabled)
+  enable_fontset="no"
+fi
 
 dnl There is no test for the BeOS GUI, if it's selected it's used
 if test -z "$SKIP_BEOS"; then

File src/ex_docmd.c

      */
     if ((ea.cmdidx == CMD_make
 			 || ea.cmdidx == CMD_grep || ea.cmdidx == CMD_grepadd)
-	    && !grep_internal(&ea))
+	    && !grep_internal(ea.cmdidx))
     {
 	char_u		*new_cmdline;
 	char_u		*program;
 	p++;
     xp->xp_pattern = p;
 
-    if (argt & XFILE)
+    if ((argt & XFILE)
+#ifdef FEAT_QUICKFIX
+	    || cmdidx == CMD_vimgrep
+	    || cmdidx == CMD_vimgrepadd
+	    || grep_internal(cmdidx)
+#endif
+       )
     {
 	int in_quote = FALSE;
 	char_u *bow = NULL;	/* Beginning of word */
 
     p = eap->arg;
 #ifdef FEAT_QUICKFIX
-    if (eap->cmdidx == CMD_vimgrep
-	    || eap->cmdidx == CMD_vimgrepadd
-	    || grep_internal(eap))
+    if (*p != NUL && (eap->cmdidx == CMD_vimgrep
+		|| eap->cmdidx == CMD_vimgrepadd
+		|| grep_internal(eap->cmdidx)))
     {
 	/* Skip over the pattern. */
-	p = skip_regexp(p + 1, *p, TRUE, NULL);
-	if (*p == *eap->arg)
-	    ++p;
+	if (vim_isIDc(*p))
+	    p = skiptowhite(p);
+	else
+	{
+	    p = skip_regexp(p + 1, *p, TRUE, NULL);
+	    if (*p == *eap->arg)
+		++p;
+	}
     }
 #endif
 

File src/ex_getln.c

 }
 #endif
 
-#if (defined(FEAT_XIM) && defined(FEAT_GUI_GTK)) || defined(PROTO)
+#if (defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE))) \
+							     || defined(PROTO)
 /*
  * Return the virtual column number at the current cursor position.
  * This is used by the IM code to obtain the start of the preedit string.

File src/feature.h

  * +xfontset		X fontset support.  For outputting wide characters.
  */
 #ifndef FEAT_XFONTSET
-# if defined(FEAT_MBYTE) && defined(HAVE_X11) && !defined(HAVE_GTK2)
+# if defined(FEAT_MBYTE) && defined(HAVE_X11) \
+		&& !defined(HAVE_GTK2) && !defined(FEAT_GUI_KDE)
 #  define FEAT_XFONTSET
 # else
 /* #  define FEAT_XFONTSET */
 	    || defined(FEAT_NETBEANS_INTG))
 # define FEAT_BEVAL
 # if !defined(FEAT_XFONTSET) && !defined(FEAT_GUI_GTK) \
-	&& !defined(FEAT_GUI_W32)
+	&& !defined(FEAT_GUI_KDE) && !defined(FEAT_GUI_W32)
 #  define FEAT_XFONTSET
 # endif
 #endif

File src/globals.h

 #ifdef FEAT_XIM
 # ifdef FEAT_GUI_KDE
 EXTERN colnr_T		preedit_start_col INIT(= MAXCOL);
+EXTERN colnr_T		preedit_end_col INIT(= MAXCOL);
 EXTERN char		*draw_feedback INIT(= NULL);
 # endif
 # ifdef FEAT_GUI_GTK
     long_u	hl_mask_todo;
     guicolor_T	fg_color;
     guicolor_T	bg_color;
-#if !defined(MSWIN16_FASTTEXT) && !defined(HAVE_GTK2)
+#if !defined(MSWIN16_FASTTEXT) && !defined(HAVE_GTK2) && !defined(FEAT_GUI_KDE)
     GuiFont	font = NOFONT;
 # ifdef FEAT_XFONTSET
     GuiFontset	fontset = NOFONTSET;
 	highlight_mask = gui.highlight_mask;
     hl_mask_todo = highlight_mask;
 
-#if !defined(MSWIN16_FASTTEXT) && !defined(HAVE_GTK2)
+#if !defined(MSWIN16_FASTTEXT) && !defined(HAVE_GTK2) && !defined(FEAT_GUI_KDE)
     /* Set the font */
     if (aep != NULL && aep->ae_u.gui.font != NOFONT)
 	font = aep->ae_u.gui.font;
 	    /* print the string so far if it's the last character or there is
 	     * a composing character. */
 	    if (i + cl >= len || (comping && i > start) || dowide
-#  if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined (FEAT_GUI_KDE)
+#  if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
 		    || (cn > 1
 #   ifdef FEAT_XFONTSET
 			/* No fontset: At least draw char after wide char at
 		cells = 0;
 		if (dowide)
 		{
+#ifndef FEAT_GUI_KDE
 		    gui_mch_set_font(gui.wide_font);
+#endif
 		    gui_mch_draw_string(gui.row, scol - cn,
 						   s + start, cl, draw_flags);
+#ifndef FEAT_GUI_KDE
 		    gui_mch_set_font(font);
+#endif
 		    start += cl;
 		}
 

File src/gui_kde.cc

     char_u full_pathname[MAXPATHL + 1];
 
     if (gui_find_bitmap(name, full_pathname, "xpm") == OK)
-    {
 	return QPixmap((const char *)full_pathname);
-    }
     else
 	return QPixmap();
 }//}}}
 #endif
 
     void
-gui_mch_add_menu(vimmenu_T * menu, int idx)//{{{
+gui_mch_add_menu(vimmenu_T *menu, int idx)//{{{
 {
 #ifdef FEAT_MENU
     QPopupMenu *me;
 
     if (menu_is_popup(menu->name))
     {
-	menu->widget = new QPopupMenu(vmw , (const char *)menu->name);
+	menu->widget = new QPopupMenu(vmw , QSTR(menu->name));
 	QObject::connect(menu->widget, SIGNAL(activated(int)), vmw,
 						   SLOT(menu_activated(int)));
 	return;
     if (parent)
     {
 	idx++; // for tearoffs to be first in menus
-	me = new QPopupMenu(parent->widget, (const char *)menu->name);
-	parent->widget->insertItem(QString((const char *)menu->name), me,
-								(int)me, idx);
+	me = new QPopupMenu(parent->widget, QSTR(menu->name));
+	parent->widget->insertItem(QSTR(menu->name), me, (int)me, idx);
     }
     else
     {
-	me = new QPopupMenu(vmw->menuBar() , (const char *)menu->name);
-	vmw->menuBar()->insertItem(QString((const char *)menu->name), me,
-								(int)me, idx);
+	me = new QPopupMenu(vmw->menuBar(), QSTR(menu->name));
+	vmw->menuBar()->insertItem(QSTR(menu->name), me, (int)me, idx);
     }
 
     me->setCaption((const char *)(menu->dname));
 
 
     void
-gui_mch_add_menu_item(vimmenu_T * menu, int idx)//{{{
+gui_mch_add_menu_item(vimmenu_T *menu, int idx)//{{{
 {
 #ifdef FEAT_MENU
     vimmenu_T *parent = menu->parent;
 		pix,
 		(int)menu, // id
 		true,
-		(char *)(menu->strings[MENU_INDEX_TIP]), // tooltip or text
+		QSTR(menu->strings[MENU_INDEX_TIP]), // tooltip or text
 		idx);
 	menu->parent=parent;
 	return;
 	parent->widget->insertSeparator();
 	return;
     }
-    parent->widget->insertItem(QString((const char *)menu->name), (int)menu, idx);
+    parent->widget->insertItem(QSTR(menu->name), (int)menu, idx);
 #endif
 }//}}}
 
 	void
 gui_mch_toggle_tearoffs(int enable)//{{{
 {
-	vmw->have_tearoff=enable;
-	toggle_tearoffs(root_menu, enable);
+    vmw->have_tearoff=enable;
+    toggle_tearoffs(root_menu, enable);
 }//}}}
 #endif
 
  * Destroy the machine specific menu widget.
  */
     void
-gui_mch_destroy_menu(vimmenu_T * menu)//{{{
+gui_mch_destroy_menu(vimmenu_T *menu)//{{{
 {
 #ifdef FEAT_TOOLBAR
     if (menu->parent && menu_is_toolbar(menu->parent->name))
 {
     if (!sb->w)
 	return;
+
     //we add the menubar and toolbar height/width
     int X = 0;
     int Y = 0;
 }//}}}
 
     void
-gui_mch_destroy_scrollbar(scrollbar_T * sb)//{{{
+gui_mch_destroy_scrollbar(scrollbar_T *sb)//{{{
 {
     sbpool->destroy(sb);
 }//}}}
 /*ARGSUSED*/
     char_u *
 gui_mch_browse(int saving,//{{{
-		char_u * title,
-		char_u * dflt,
-		char_u * ext,
-		char_u * initdir,
-		char_u * filter)
+		char_u *title,
+		char_u *dflt,
+		char_u *ext,
+		char_u *initdir,
+		char_u *filter)
 {
     char *filt_glob;
 
 
     QString s;
     if (!saving)
-	s = KFileDialog::getOpenFileName((char *)initdir, (char *)filt_glob,
-							  vmw, (char *)title);
+	s = KFileDialog::getOpenFileName(QSTR(initdir), QSTR(filt_glob),
+							  vmw, QSTR(title));
     else
 	s = KFileDialog::getSaveFileName();
 
 		char_u *title,		/* title of dialog */
 		char_u *message,	/* message text */
 		char_u *buttons,	/* names of buttons */
-		int def_but,		/* default button */
+		int    def_but,		/* default button */
 		char_u *textfield)
 {
     gui_mch_mousehide(FALSE);
 
 #if defined(FEAT_MENU) || defined(PROTO)
     void
-gui_mch_show_popupmenu(vimmenu_T * menu)//{{{
+gui_mch_show_popupmenu(vimmenu_T *menu)//{{{
 {
     menu->widget->popup(QCursor::pos());
 }//}}}

File src/gui_kde_wid.cc

     char_u code1;
 } special_keys[] =
 {
-    { Qt::Key_Up,		'k', 'u' },
-    { Qt::Key_Down,		'k', 'd' },
-    { Qt::Key_Left,		'k', 'l' },
-    { Qt::Key_Right,		'k', 'r' },
-    { Qt::Key_F1,		'k', '1' },
-    { Qt::Key_F2,		'k', '2' },
-    { Qt::Key_F3,		'k', '3' },
-    { Qt::Key_F4,		'k', '4' },
-    { Qt::Key_F5,		'k', '5' },
-    { Qt::Key_F6,		'k', '6' },
-    { Qt::Key_F7,		'k', '7' },
-    { Qt::Key_F8,		'k', '8' },
-    { Qt::Key_F9,		'k', '9' },
-    { Qt::Key_F10,		'k', ';' },
-    { Qt::Key_F11,		'F', '1' },
-    { Qt::Key_F12,		'F', '2' },
-    { Qt::Key_F13,		'F', '3' },
-    { Qt::Key_F14,		'F', '4' },
-    { Qt::Key_F15,		'F', '5' },
-    { Qt::Key_F16,		'F', '6' },
-    { Qt::Key_F17,		'F', '7' },
-    { Qt::Key_F18,		'F', '8' },
-    { Qt::Key_F19,		'F', '9' },
-    { Qt::Key_F20,		'F', 'A' },
-    { Qt::Key_F21,		'F', 'B' },
-    { Qt::Key_F22,		'F', 'C' },
-    { Qt::Key_F23,		'F', 'D' },
-    { Qt::Key_F24,		'F', 'E' },
-    { Qt::Key_F25,		'F', 'F' },
-    { Qt::Key_F26,		'F', 'G' },
-    { Qt::Key_F27,		'F', 'H' },
-    { Qt::Key_F28,		'F', 'I' },
-    { Qt::Key_F29,		'F', 'J' },
-    { Qt::Key_F30,		'F', 'K' },
-    { Qt::Key_F31,		'F', 'L' },
-    { Qt::Key_F32,		'F', 'M' },
-    { Qt::Key_F33,		'F', 'N' },
-    { Qt::Key_F34,		'F', 'O' },
-    { Qt::Key_F35,		'F', 'P' },
-    { Qt::Key_Help,		'%', '1' },
-    //    { Qt::Key_Undo,		'&', '8' }, <= hmmm ?
-    { Qt::Key_BackSpace,	'k', 'b' },
-    { Qt::Key_Insert,		KS_EXTRA, KE_KINS },
-    { Qt::Key_Delete,		KS_EXTRA, KE_KDEL },
-    { Qt::Key_Home,		'K', '1' },
-    { Qt::Key_End,		'K', '4' },
-    { Qt::Key_Prior,		'K', '3' },
-    { Qt::Key_Next,		'K', '5' },
-    { Qt::Key_Print,		'%', '9' },
+    {Qt::Key_Up,	'k', 'u'},
+    {Qt::Key_Down,	'k', 'd'},
+    {Qt::Key_Left,	'k', 'l'},
+    {Qt::Key_Right,	'k', 'r'},
+    {Qt::Key_F1,	'k', '1'},
+    {Qt::Key_F2,	'k', '2'},
+    {Qt::Key_F3,	'k', '3'},
+    {Qt::Key_F4,	'k', '4'},
+    {Qt::Key_F5,	'k', '5'},
+    {Qt::Key_F6,	'k', '6'},
+    {Qt::Key_F7,	'k', '7'},
+    {Qt::Key_F8,	'k', '8'},
+    {Qt::Key_F9,	'k', '9'},
+    {Qt::Key_F10,	'k', ';'},
+    {Qt::Key_F11,	'F', '1'},
+    {Qt::Key_F12,	'F', '2'},
+    {Qt::Key_F13,	'F', '3'},
+    {Qt::Key_F14,	'F', '4'},
+    {Qt::Key_F15,	'F', '5'},
+    {Qt::Key_F16,	'F', '6'},
+    {Qt::Key_F17,	'F', '7'},
+    {Qt::Key_F18,	'F', '8'},
+    {Qt::Key_F19,	'F', '9'},
+    {Qt::Key_F20,	'F', 'A'},
+    {Qt::Key_F21,	'F', 'B'},
+    {Qt::Key_F22,	'F', 'C'},
+    {Qt::Key_F23,	'F', 'D'},
+    {Qt::Key_F24,	'F', 'E'},
+    {Qt::Key_F25,	'F', 'F'},
+    {Qt::Key_F26,	'F', 'G'},
+    {Qt::Key_F27,	'F', 'H'},
+    {Qt::Key_F28,	'F', 'I'},
+    {Qt::Key_F29,	'F', 'J'},
+    {Qt::Key_F30,	'F', 'K'},
+    {Qt::Key_F31,	'F', 'L'},
+    {Qt::Key_F32,	'F', 'M'},
+    {Qt::Key_F33,	'F', 'N'},
+    {Qt::Key_F34,	'F', 'O'},
+    {Qt::Key_F35,	'F', 'P'},
+    {Qt::Key_Help,	'%', '1'},
+    //    { Qt::Key_Undo,	'&', '8'}, <= hmmm ?
+    {Qt::Key_BackSpace,	'k', 'b'},
+    {Qt::Key_Insert,	KS_EXTRA, KE_KINS },
+    {Qt::Key_Delete,	KS_EXTRA, KE_KDEL },
+    {Qt::Key_Home,	'K', '1'},
+    {Qt::Key_End,	'K', '4'},
+    {Qt::Key_Prior,	'K', '3'},
+    {Qt::Key_Next,	'K', '5'},
+    {Qt::Key_Print,	'%', '9'},
 
-    { Qt::Key_Plus,	'K', '6'},
-    { Qt::Key_Minus,	'K', '7'},
-    { Qt::Key_Slash,	'K', '8'},
-    { Qt::Key_multiply,	'K', '9'},
-    { Qt::Key_Enter,	'K', 'A'},
-    { Qt::Key_Period,	'K', 'B'},
+    {Qt::Key_Plus,	'K', '6'},
+    {Qt::Key_Minus,	'K', '7'},
+    {Qt::Key_Slash,	'K', '8'},
+    {Qt::Key_multiply,	'K', '9'},
+    {Qt::Key_Enter,	'K', 'A'},
+    {Qt::Key_Period,	'K', 'B'},
 
-    { Qt::Key_0,	'K', 'C'},
-    { Qt::Key_1,	'K', 'D'},
-    { Qt::Key_2,	'K', 'E'},
-    { Qt::Key_3,	'K', 'F'},
-    { Qt::Key_4,	'K', 'G'},
-    { Qt::Key_5,	'K', 'H'},
-    { Qt::Key_6,	'K', 'I'},
-    { Qt::Key_7,	'K', 'J'},
-    { Qt::Key_8,	'K', 'K'},
-    { Qt::Key_9,	'K', 'L'},
+    {Qt::Key_0,		'K', 'C'},
+    {Qt::Key_1,		'K', 'D'},
+    {Qt::Key_2,		'K', 'E'},
+    {Qt::Key_3,		'K', 'F'},
+    {Qt::Key_4,		'K', 'G'},
+    {Qt::Key_5,		'K', 'H'},
+    {Qt::Key_6,		'K', 'I'},
+    {Qt::Key_7,		'K', 'J'},
+    {Qt::Key_8,		'K', 'K'},
+    {Qt::Key_9,		'K', 'L'},
+
     /* End of list marker: */
-    { 0, 0, 0 }
+    {0, 0, 0}
 };//}}}
 
 #ifdef FEAT_CLIENTSERVER
-typedef int (*QX11EventFilter) (XEvent*);
-extern QX11EventFilter qt_set_x11_event_filter (QX11EventFilter filter);
-static QX11EventFilter oldFilter = 0;
-static int kvim_x11_event_filter( XEvent* e);
+typedef int (*QX11EventFilter)(XEvent*);
+extern	    QX11EventFilter qt_set_x11_event_filter(QX11EventFilter filter);
+static	    QX11EventFilter oldFilter = 0;
+static int  kvim_x11_event_filter(XEvent* e);
 #endif
-void gui_keypress(QKeyEvent *e);
+void	    gui_keypress(QKeyEvent *e);
 
 /*
  * Return OK if the key with the termcap name "name" is supported.
 /*
  * custom Frame for drawing ...
  */
-void VimWidget::paintEvent(QPaintEvent *e)//{{{
+    void
+VimWidget::paintEvent(QPaintEvent *e)//{{{
 {
     QRect r = e->rect();
     gui_redraw(r.x(), r.y(), r.width(), r.height());
 }//}}}
 
-void VimWidget::draw_string(int x, int y, QString s, int len, int flags)//{{{
+    void
+VimWidget::draw_string(int x, int y, QString s, int len, int flags)//{{{
 {
     gui.current_font->setBold(flags & DRAW_BOLD);
     gui.current_font->setUnderline(flags & DRAW_UNDERL);
     gui.current_font->setItalic(flags & DRAW_ITALIC);
-    painter->setBackgroundMode(flags & DRAW_TRANSP ? Qt::TransparentMode : Qt::OpaqueMode);
+    painter->setBackgroundMode(flags & DRAW_TRANSP
+				      ? Qt::TransparentMode : Qt::OpaqueMode);
     painter->setFont(*(gui.current_font));
     painter->drawText(x, y, s, len);
 }//}}}
 
-void VimWidget::mousePressEvent(QMouseEvent *event)//{{{
+    void
+VimWidget::mousePressEvent(QMouseEvent *event)//{{{
 {
-    int button=0;
-    int modifiers=0;
+    int		button = 0;
+    int		modifiers = 0;
     ButtonState state = event->state();
     ButtonState buttons = event->button();
 
 	modifiers |= MOUSE_CTRL;
     if (state & QMouseEvent::AltButton)
 	modifiers |= MOUSE_ALT;
-    gui_send_mouse_event(button,event->x(),event->y(),FALSE,modifiers);
+    gui_send_mouse_event(button, event->x(), event->y(), FALSE, modifiers);
 #if QT_VERSION>=300
     QByteArray params;
     QDataStream stream(params, IO_WriteOnly);
-    stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col;
-    kapp->dcopClient()->emitDCOPSignal("mousePEvent(QCString,int,int,int,int)", params);
+    stream << kapp->dcopClient()->appId() << button << modifiers
+							<< gui.row << gui.col;
+    kapp->dcopClient()->emitDCOPSignal(
+			 "mousePEvent(QCString, int, int, int, int)", params);
 #endif
     event->accept();
 }//}}}
 
 #if defined(FEAT_SESSION)
-void VimMainWindow::saveGlobalProperties (KConfig *conf)
+    void
+VimMainWindow::saveGlobalProperties(KConfig *conf)
 {
     //we write a mksession file to a file written in the user's ~/.kde/share/config/
     //the name of the file in saved in 'conf'
 #endif
 }
 
-void VimMainWindow::readGlobalProperties (KConfig *conf)
+    void
+VimMainWindow::readGlobalProperties (KConfig *conf)
 {
 #if 0
     QString filename = conf->readPathEntry("sessionfile");
 }
 #endif
 
-void VimMainWindow::wheelEvent (QWheelEvent *event)//{{{
+    void
+VimMainWindow::wheelEvent (QWheelEvent *event)//{{{
 {
     ButtonState state = event->state();
-    int button=0;
-    int modifiers=0;
+    int		button = 0;
+    int		modifiers = 0;
 
-    if (event->delta()>0)
-	button|=MOUSE_4;
-    else button|=MOUSE_5;
+    if (event->delta() > 0)
+	button |= MOUSE_4;
+    else button |= MOUSE_5;
 
     if (state & ShiftButton)
-	modifiers|=MOUSE_SHIFT;
+	modifiers |= MOUSE_SHIFT;
     if (state & ControlButton)
-	modifiers|=MOUSE_CTRL;
+	modifiers |= MOUSE_CTRL;
     if (state & AltButton)
-	modifiers|=MOUSE_ALT;
+	modifiers |= MOUSE_ALT;
 
-    gui_send_mouse_event(button,event->x(),event->y(),FALSE,modifiers);
+    gui_send_mouse_event(button, event->x(), event->y(), FALSE, modifiers);
 #if QT_VERSION>=300
     QByteArray params;
     QDataStream stream(params, IO_WriteOnly);
-    stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col;
-    kapp->dcopClient()->emitDCOPSignal("mouseWhlEvent(QCString, int, int,int,int)", params);
+    stream << kapp->dcopClient()->appId() << button << modifiers
+							<< gui.row << gui.col;
+    kapp->dcopClient()->emitDCOPSignal(
+		       "mouseWhlEvent(QCString, int, int, int, int)", params);
 #endif
     event->accept();
 }//}}}
 
-void VimWidget::mouseDoubleClickEvent(QMouseEvent *event)//{{{
+    void
+VimWidget::mouseDoubleClickEvent(QMouseEvent *event)//{{{
 {
     ButtonState state = event->state();
     ButtonState buttons = event->button();
-    int modifiers=0;
-    int button=0;
+    int		modifiers = 0;
+    int		button = 0;
 
     //Look at button states
     if (buttons & LeftButton)
-	button|=MOUSE_LEFT;
+	button |= MOUSE_LEFT;
     if (buttons & RightButton)
-	button|=MOUSE_RIGHT;
+	button |= MOUSE_RIGHT;
     if (buttons & MidButton)
-	button|=MOUSE_MIDDLE;
+	button |= MOUSE_MIDDLE;
 
     //Look for keyboard modifiers
     if (state & ShiftButton)
-	modifiers|=MOUSE_SHIFT;
+	modifiers |= MOUSE_SHIFT;
     if (state & ControlButton)
-	modifiers|=MOUSE_CTRL;
+	modifiers |= MOUSE_CTRL;
     if (state & AltButton)
-	modifiers|=MOUSE_ALT;
+	modifiers |= MOUSE_ALT;
 
-    gui_send_mouse_event(button,event->x(),event->y(),TRUE,modifiers);
+    gui_send_mouse_event(button, event->x(), event->y(), TRUE, modifiers);
 #if QT_VERSION>=300
     QByteArray params;
     QDataStream stream(params, IO_WriteOnly);
-    stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col;
-    kapp->dcopClient()->emitDCOPSignal("mouseDblClickEvent(QCString, int, int,int,int)", params);
+    stream << kapp->dcopClient()->appId() << button << modifiers
+							<< gui.row << gui.col;
+    kapp->dcopClient()->emitDCOPSignal(
+		  "mouseDblClickEvent(QCString, int, int, int, int)", params);
 #endif
     event->accept();
 }//}}}
 
-void VimWidget::mouseMoveEvent(QMouseEvent *event){//{{{
+    void
+VimWidget::mouseMoveEvent(QMouseEvent *event)//{{{
+{
     ButtonState state = event->state();
-    int modifiers=0;
-    int button=0;
+    int		modifiers = 0;
+    int		button = 0;
 
     gui_mch_mousehide(FALSE);
 
     //Look at button states
     //warning: we use state here, this is important !
-    if (state & QMouseEvent::LeftButton || state & QMouseEvent::RightButton || state & QMouseEvent::MidButton)
-	button|=MOUSE_DRAG;
+    if (state & QMouseEvent::LeftButton
+	    || state & QMouseEvent::RightButton
+	    || state & QMouseEvent::MidButton)
+	button |= MOUSE_DRAG;
 
     //Look for keyboard modifiers
     if (state & ShiftButton)
-	modifiers|=MOUSE_SHIFT;
+	modifiers |= MOUSE_SHIFT;
     if (state & ControlButton)
-	modifiers|=MOUSE_CTRL;
+	modifiers |= MOUSE_CTRL;
     if (state & AltButton)
-	modifiers|=MOUSE_ALT;
-    if (button!=MOUSE_DRAG)
-	gui_mouse_moved(event->x(),event->y());
+	modifiers |= MOUSE_ALT;
+    if (button != MOUSE_DRAG)
+	gui_mouse_moved(event->x(), event->y());
     else
-	gui_send_mouse_event(MOUSE_DRAG,event->x(),event->y(),FALSE,modifiers);
+	gui_send_mouse_event(MOUSE_DRAG, event->x(), event->y(),
+							    FALSE, modifiers);
 }//}}}
 
-void VimWidget::mouseReleaseEvent(QMouseEvent *event)//{{{
+    void
+VimWidget::mouseReleaseEvent(QMouseEvent *event)//{{{
 {
     ButtonState state = event->state();
-    int modifiers=0;
+    int		modifiers = 0;
 
     //Look for keyboard modifiers
     if (state & ShiftButton)
-	modifiers|=MOUSE_SHIFT;
+	modifiers |= MOUSE_SHIFT;
     if (state & ControlButton)
-	modifiers|=MOUSE_CTRL;
+	modifiers |= MOUSE_CTRL;
     if (state & AltButton)
-	modifiers|=MOUSE_ALT;
+	modifiers |= MOUSE_ALT;
 
-    gui_send_mouse_event(MOUSE_RELEASE,event->x(),event->y(),FALSE,modifiers);
+    gui_send_mouse_event(MOUSE_RELEASE, event->x(), event->y(),
+							    FALSE, modifiers);
     event->accept();
 }//}}}
 
 /*
  *  The main widget (everything but toolbar/menubar)
  */
-    VimWidget::VimWidget( QWidget *parent, const char *name, WFlags f )//{{{
-:QWidget(parent, name, f)
-    ,DCOPObject("KVim")
+VimWidget::VimWidget(QWidget *parent, const char *name, WFlags f)//{{{
+    :QWidget(parent, name, f)
+    , DCOPObject("KVim")
 #ifdef FEAT_MZSCHEME
-    ,mzscheme_timer_id(-1)
+    , mzscheme_timer_id(-1)
 #endif
 {
     //to be able to show/hide the cursor when moving the mouse
     setMouseTracking(true);
-    painter=new QPainter(this);
+    painter = new QPainter(this);
 
     setKeyCompression(true);
-    setFocusPolicy( QWidget::StrongFocus );
+    setFocusPolicy(QWidget::StrongFocus);
     setAcceptDrops(TRUE); // DND
     blink_state = BLINK_NONE;
     blink_on_time = 700;
     blink_off_time = 400;
     blink_wait_time = 250;
-    connect( &blink_timer, SIGNAL( timeout() ), SLOT( blink_cursor() ));
-    connect( &wait_timer, SIGNAL( timeout() ), SLOT ( wait_timeout() ));
+    connect( &blink_timer, SIGNAL(timeout()), SLOT(blink_cursor()));
+    connect( &wait_timer, SIGNAL(timeout()), SLOT(wait_timeout()));
+    setInputMethodEnabled(true);
 }//}}}
 
-void VimWidget::execNormal(QString command)//{{{
+    void
+VimWidget::execNormal(QString command)//{{{
 {
     QString cmd("execute 'normal ");
-    cmd+=command;
-    cmd+="'";
+    cmd += command;
+    cmd += "'";
     QCString unistring = vmw->codec->fromUnicode(cmd);
     do_cmdline_cmd((char_u *)(const char*)unistring);
     gui_update_screen();
 }//}}}
 
-void VimWidget::execInsert(QString command)//{{{
+    void
+VimWidget::execInsert(QString command)//{{{
 {
     QString cmd("execute 'normal i");
-    cmd+=command;
-    cmd+="'";
+    cmd += command;
+    cmd += "'";
     QCString unistring = vmw->codec->fromUnicode(cmd);
     do_cmdline_cmd((char_u *)(const char*)unistring);
     gui_update_screen();
 }//}}}
 
-void VimWidget::execRaw(QString command)//{{{
+    void
+VimWidget::execRaw(QString command)//{{{
 {
     QString cmd("execute '");
-    cmd+=command;
-    cmd+="'";
+    cmd += command;
+    cmd += "'";
     QCString unistring = vmw->codec->fromUnicode(cmd);
     do_cmdline_cmd((char_u *)(const char*)unistring);
     gui_update_screen();
 }//}}}
 
-void VimWidget::execCmd(QString command)//{{{
+    void
+VimWidget::execCmd(QString command)//{{{
 {
     QCString unistring = vmw->codec->fromUnicode(command);
     do_cmdline_cmd((char_u *)(const char*)unistring);
     gui_update_screen();
 }//}}}
 
-QString VimWidget::eval(QString expr)//{{{
+    QString
+VimWidget::eval(QString expr)//{{{
 {
 #ifdef FEAT_EVAL
     QCString unistring = vmw->codec->fromUnicode(expr);
-    QString val((const char *)eval_to_string((char_u *)(const char*)unistring,NULL));
+    QString val((const char *)eval_to_string(
+				     (char_u *)(const char*)unistring, NULL));
     return val;
 #else
     return QString::null;
 #endif
 }//}}}
 
-void VimWidget::wait(long wtime)//{{{
+    void
+VimWidget::wait(long wtime)//{{{
 {
-    if ( wait_timer.isActive() ) wait_timer.stop();
+    if (wait_timer.isActive())
+	wait_timer.stop();
     wait_done = false;
     wait_timer.start( wtime, true);
 }//}}}
 
-void VimWidget::wait_timeout() //{{{
+    void
+VimWidget::wait_timeout() //{{{
 {
     wait_done = true;
 }//}}}
 
-void VimWidget::dragEnterEvent (QDragEnterEvent *e)//{{{
+    void
+VimWidget::dragEnterEvent (QDragEnterEvent *e)//{{{
 {
 #if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO)
     e->accept(QUriDrag::canDecode(e));
 #endif
 }//}}}
 
-void VimWidget::dropEvent (QDropEvent *e) // {{{
+    void
+VimWidget::dropEvent(QDropEvent *e) // {{{
 {
 #if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO)
-    QStrList  urls;
+    QStrList	urls;
 
     char_u	**fnames;
     int		redo_dirs = FALSE;
     if (QUriDrag::decode(e, urls))
     {
 	n = urls.count();
-        fnames = (char_u **)lalloc((n+1) * sizeof(char_u *), TRUE);
+	fnames = (char_u **)lalloc((n+1) * sizeof(char_u *), TRUE);
 	nfiles = 0;
 #if QT_VERSION>=300
 	QPtrListIterator<char> it(urls);
-	for (; it.current(); ++it )
+	for (; it.current(); ++it)
 	{
 	    KURL u(*it);
 #else
-	    for (i=0;i<urls.count();++i)
+	    for (i = 0; i < urls.count(); ++i)
 	    {
 		KURL u(urls.at(i));
 #endif
-		if ( !u.isLocalFile() )
+		if (!u.isLocalFile())
 		    url = TRUE;
 		else
 		{
 		{
 		    char_u	dirname[MAXPATHL];
 		    char_u	*s;
+
 		    if (mch_dirname(dirname, MAXPATHL) == OK)
 			for (i = 0; i < nfiles; ++i)
 			    if (fnames[i] != NULL)
 #endif
 } // }}}
 
-void VimWidget::keyPressEvent( QKeyEvent *e ) // {{{
+    void
+VimWidget::keyPressEvent(QKeyEvent *e) // {{{
 {
     gui_keypress(e);
 } // }}}
 
-void gui_keypress(QKeyEvent *e) { // {{{
-    int key = (int)e->key();
-    int modifiers = 0,i;
-    uchar string[256],string2[256];
-    uchar *s,*d;
+    void
+gui_keypress(QKeyEvent *e) // {{{
+{
+    int		    key = (int)e->key();
+    int		    modifiers = 0, i;
+    uchar	    string[256], string2[256];
+    uchar	    *s, *d;
     Qt::ButtonState state = e->state();
 
     QCString unistring = vmw->codec->fromUnicode(e->text());
-    if (unistring.length()>0)
-	strncpy((char*)string, (const char*)unistring,unistring.length());
+    if (unistring.length() > 0)
+	strncpy((char*)string, (const char*)unistring, unistring.length());
     string[unistring.length()] = 0;
-    int len=unistring.length();
+    int len = unistring.length();
 
     // ignore certain keys
-    if (key == Qt::Key_Shift || key == Qt::Key_Alt || key == Qt::Key_Control || key == Qt::Key_Meta
-	    || key == Qt::Key_CapsLock || key == Qt::Key_NumLock || key == Qt::Key_ScrollLock )
+    if (key == Qt::Key_Shift
+	    || key == Qt::Key_Alt
+	    || key == Qt::Key_Control
+	    || key == Qt::Key_Meta
+	    || key == Qt::Key_CapsLock
+	    || key == Qt::Key_NumLock
+	    || key == Qt::Key_ScrollLock)
     {
 	e->ignore();
 	return;
 
 
     // change shift-tab (backtab) into S_TAB
-    if ( key == Qt::Key_BackTab && state & Qt::ShiftButton)
+    if (key == Qt::Key_BackTab && state & Qt::ShiftButton)
 	key = Qt::Key_Tab;
 
     // Change C-@ and C-2 in NUL ? Gtk does this
-    if ( (key == Qt::Key_2 || key == Qt::Key_At)
-	    && state & Qt::ControlButton )
+    if ((key == Qt::Key_2 || key == Qt::Key_At) && state & Qt::ControlButton)
     {
 	string[0] = NUL;
 	len = 1;
     /* Check for special keys, making sure BS and DEL are recognised. */
     if (len == 0 || key == Qt::Key_BackSpace || key == Qt::Key_Delete)
     {
-	while (special_keys[i].qtkey != 0 && special_keys[i].qtkey != key ) i++;
+	while (special_keys[i].qtkey != 0 && special_keys[i].qtkey != key)
+	    i++;
 	if (special_keys[i].qtkey != 0)
 	{
-		string[0] = CSI;
-		string[1] = special_keys[i].code0;
-		string[2] = special_keys[i].code1;
-		len = -3;
+	    string[0] = CSI;
+	    string[1] = special_keys[i].code0;
+	    string[2] = special_keys[i].code1;
+	    len = -3;
 	}
 /*
 	for (i = 0; special_keys[i].qtkey != 0 ; i++)
 
 
     /* Special keys (and a few others) may have modifiers */
-    if (len == -3 || key == Qt::Key_Space || key == Qt::Key_Tab ||
-	    key == Qt::Key_Return || key == Qt::Key_Enter ||
-	    key == Qt::Key_Escape)
+    if (len == -3
+	    || key == Qt::Key_Space
+	    || key == Qt::Key_Tab
+	    || key == Qt::Key_Return
+	    || key == Qt::Key_Enter
+	    || key == Qt::Key_Escape)
     {
-
 	modifiers = 0;
-	if (state & Qt::ShiftButton) modifiers |= MOD_MASK_SHIFT;
-	if (state & Qt::ControlButton) modifiers |= MOD_MASK_CTRL;
-	if (state & Qt::AltButton) modifiers |= MOD_MASK_ALT;
+	if (state & Qt::ShiftButton)
+	    modifiers |= MOD_MASK_SHIFT;
+	if (state & Qt::ControlButton)
+	    modifiers |= MOD_MASK_CTRL;
+	if (state & Qt::AltButton)
+	    modifiers |= MOD_MASK_ALT;
 
 	/*
 	 * For some keys a shift modifier is translated into another key
 	    key = string[0];
 
 	key = simplify_key(key, &modifiers);
-	if (key == CSI) key=K_CSI;
+	if (key == CSI)
+	    key = K_CSI;
 
 	if (IS_SPECIAL(key))
 	{
 	    len = 1;
 	}
 
-
-	if (modifiers!=0)
+	if (modifiers != 0)
 	{
 	    uchar string2[10];
 	    string2[0] = CSI;
     } /* special keys */
 
     if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts)
-		|| (string[0] == intr_char && intr_char != Ctrl_C)))
+			  || (string[0] == intr_char && intr_char != Ctrl_C)))
     {
 	trash_input_buf();
 	got_int = TRUE;
     QByteArray params;
     QDataStream stream(params, IO_WriteOnly);
     stream << kapp->dcopClient()->appId() << unistring << gui.row << gui.col;
-    kapp->dcopClient()->emitDCOPSignal("keyboardEvent(QCString, QCString,int,int)", params);
+    kapp->dcopClient()->emitDCOPSignal(
+		       "keyboardEvent(QCString, QCString, int, int)", params);
 #endif
     e->ignore();
 } // }}}
 
 #ifdef FEAT_CLIENTSERVER
-void VimWidget::serverActivate(WId id) //{{{
+    void
+VimWidget::serverActivate(WId id) //{{{
 {
     if (serverName == NULL && serverDelayedStartName != NULL)
     {
 #endif
 
 #ifdef FEAT_XIM
-void VimWidget::imStartEvent(QIMEvent *e)
+
+static int preedit_buf_len = 0;
+static int im_preedit_cursor = 0;
+static int im_preedit_trailing = 0;
+
+    static void
+im_delete_preedit(void)
 {
+    char_u bskey[]  = {CSI, 'k', 'b'};
+    char_u delkey[] = {CSI, 'k', 'D'};
+
+    if (State & NORMAL)
+    {
+	im_preedit_cursor = 0;
+	return;
+    }
+    for (; im_preedit_cursor > 0; --im_preedit_cursor)
+	add_to_input_buf(bskey, (int)sizeof(bskey));
+
+    for (; im_preedit_trailing > 0; --im_preedit_trailing)
+	add_to_input_buf(delkey, (int)sizeof(delkey));
+}
+
+    void
+im_set_position(int row, int col)
+{
+    vmw->w->setMicroFocusHint(
+	    TEXT_X(gui.col),
+	    TEXT_Y(gui.row), 0, 0, TRUE, &vmw->w->font());
+}
+
+    int
+im_is_preediting()
+{
+    return (preedit_start_col != MAXCOL);
+}
+
+    int
+im_get_feedback_attr(int col)
+{
+    if (draw_feedback != NULL && col < preedit_buf_len)
+    {
+	if (draw_feedback[col] & XIMReverse)
+	    return HL_INVERSE;
+	else if (draw_feedback[col] & XIMUnderline)
+	    return HL_UNDERLINE;
+	else
+	    return hl_attr(HLF_V);
+    }
+
+    return -1;
+}
+
+    void
+VimWidget::imStartEvent(QIMEvent *e)
+{
+    if (State & CMDLINE)
+	preedit_start_col = cmdline_getvcol_cursor();
+    else if (curwin != NULL)
+	getvcol(curwin, &curwin->w_cursor, &preedit_start_col, NULL, NULL);
+    xic = (XIC)!NULL;
     e->accept();
 }
 
-void VimWidget::imEndEvent(QIMEvent *e)
+    void
+VimWidget::imEndEvent(QIMEvent *e)
 {
     uchar string[256];
 
+    im_delete_preedit();
+
     QCString unistring = vmw->codec->fromUnicode(e->text());
-    if (unistring.length()>0)
-	strncpy((char*)string, (const char*)unistring,unistring.length());
+    if (unistring.length() > 0)
+	strncpy((char*)string, (const char*)unistring, unistring.length());
     string[unistring.length()] = 0;
-    int len=unistring.length();
+    int len = unistring.length();
 
-    add_to_input_buf(string, len);
+    add_to_input_buf_csi(string, len);
+    im_preedit_cursor = 0;
+    im_preedit_trailing = 0;
+    preedit_start_col = MAXCOL;
+    preedit_buf_len = 0;
+    if (draw_feedback)
+    {
+	free(draw_feedback);
+	draw_feedback = NULL;
+    }
+    xic = 0;
     e->accept();
 }
 
-void VimWidget::imComposeEvent(QIMEvent *e)
+    void
+VimWidget::imComposeEvent(QIMEvent *e)
 {
-    //i should do something here, displaying the text somewhere ... (status area ?)
+    uchar string[256];
+    char_u backkey[] = {CSI, 'k', 'l'};
+
+    im_delete_preedit();
+
+    if (State & NORMAL)
+    {
+	im_preedit_cursor = 0;
+	return;
+    }
+
+    QCString unistring = vmw->codec->fromUnicode(e->text());
+    if (unistring.length() > 0)
+	strncpy((char*)string, (const char*)unistring,unistring.length());
+    string[unistring.length()] = 0;
+    int len = unistring.length();
+    add_to_input_buf_csi(string, len);
+
+    preedit_buf_len = e->text().length();
+    if (draw_feedback == NULL)
+	draw_feedback = (char *)alloc(preedit_buf_len);
+    else
+	draw_feedback = (char *)realloc(draw_feedback, preedit_buf_len);
+    preedit_end_col = preedit_start_col;
+
+    char_u *p = string;
+    for (int n = 0; n < preedit_buf_len; n++)
+    {
+	if (n < e->cursorPos() || n >= e->cursorPos() + e->selectionLength())
+	    draw_feedback[n] = XIMUnderline;
+	else
+	    draw_feedback[n] = XIMReverse;
+	preedit_end_col += (*mb_ptr2cells)(p);
+	p += (*mb_ptr2len_check)(p);
+    }
+    im_preedit_cursor = e->cursorPos();
+    im_preedit_trailing = preedit_buf_len - im_preedit_cursor;
+
+#  ifdef FEAT_RIGHTLEFT
+    if ((State & CMDLINE) == 0 && curwin != NULL && curwin->w_p_rl)
+	backkey[2] = 'r';
+#  endif
+    for (int n = 0; n < im_preedit_trailing; n++)
+	add_to_input_buf(backkey, (int)sizeof(backkey));
+
     e->accept();
 }
 #endif
 
 
-void VimMainWindow::lock()
+    void
+VimMainWindow::lock()
 {
-    locked=true;
+    locked = true;
 }
 
-void VimMainWindow::unlock()
+    void
+VimMainWindow::unlock()
 {
-    locked=false;
+    locked = false;
 }
 
-bool VimMainWindow::isLocked()
+    bool
+VimMainWindow::isLocked()
 {
     return locked;
 }
 
 // ->resize VimWidget if not locked
 //
-void VimMainWindow::resizeEvent ( QResizeEvent *e ) //{{{
+    void
+VimMainWindow::resizeEvent(QResizeEvent *e) //{{{
 {
-    if ( vmw->isLocked() ) return;
+    if (vmw->isLocked())
+	return;
     //remove toolbar and menubar height
     int height = e->size().height();
     int width = e->size().width();
 	    )
 	height -= vmw->menuBar()->height();
 #ifdef FEAT_TOOLBAR
-    if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
-	    (vmw->toolBar()->barPos()==KToolBar::Top ||
-	     vmw->toolBar()->barPos()==KToolBar::Bottom))
+    if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
+	    && (vmw->toolBar()->barPos() == KToolBar::Top
+		|| vmw->toolBar()->barPos() == KToolBar::Bottom))
 	height -= vmw->toolBar()->height();
 
-    if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
-	    (vmw->toolBar()->barPos()==KToolBar::Left ||
-	     vmw->toolBar()->barPos()==KToolBar::Right))
+    if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
+	    && (vmw->toolBar()->barPos() == KToolBar::Left
+		|| vmw->toolBar()->barPos() == KToolBar::Right))
 	width -= vmw->toolBar()->width();
 #endif
-    height = ( ((int)(height/gui.char_height))*gui.char_height );
-    if (!vmw->isLocked()) gui_resize_shell(width,height);
+    height = ((int)(height/gui.char_height))*gui.char_height;
+    if (!vmw->isLocked())
+	gui_resize_shell(width, height);
 }//}}}
 
-void VimWidget::focusInEvent( QFocusEvent * fe ) // {{{
+    void
+VimWidget::focusInEvent(QFocusEvent *fe) // {{{
 {
     gui_focus_change(true);
 
 	gui_mch_start_blink();
 } // }}}
 
-void VimWidget::focusOutEvent( QFocusEvent * fe )//{{{
+    void
+VimWidget::focusOutEvent(QFocusEvent *fe)//{{{
 {
     gui_focus_change(false);
 
 	gui_mch_stop_blink();
 }//}}}
 
-void VimWidget::set_blink_time( long wait, long on, long off)//{{{
+    void
+VimWidget::set_blink_time(long wait, long on, long off)//{{{
 {
<