diff options
author | Bram Moolenaar <Bram@vim.org> | 2004-06-30 16:16:41 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2004-06-30 16:16:41 +0000 |
commit | 843ee41eb8258ac50ed81976757d8b228382a880 (patch) | |
tree | d0fcdff9e19b05b182de1bb1be46b2e6f5b8b0b7 | |
parent | f4b8e57ffd048f9ca46dd7618939ba7a1b2294ec (diff) | |
download | vim-git-843ee41eb8258ac50ed81976757d8b228382a880.tar.gz |
updated for version 7.0003
72 files changed, 15741 insertions, 1074 deletions
@@ -130,6 +130,7 @@ SRC_UNIX = \ pixmaps/gen-inline-pixbufs.sh \ pixmaps/stock_icons.h \ src/INSTALL \ + src/INSTALLkde.txt \ src/Makefile \ src/auto/configure \ src/config.aap.in \ @@ -146,6 +147,11 @@ SRC_UNIX = \ src/gui_gtk_f.c \ src/gui_gtk_f.h \ src/gui_gtk_x11.c \ + src/gui_kde.cc \ + src/gui_kde_widget.cc \ + src/gui_kde_widget.h \ + src/gui_kde_x11.cc \ + src/kvim_iface.h \ src/gui_motif.c \ src/gui_x11.c \ src/hangulin.c \ @@ -164,6 +170,8 @@ SRC_UNIX = \ src/proto/gui_athena.pro \ src/proto/gui_gtk.pro \ src/proto/gui_gtk_x11.pro \ + src/proto/gui_kde.pro \ + src/proto/gui_kde_x11.pro \ src/proto/gui_motif.pro \ src/proto/gui_x11.pro \ src/proto/hangulin.pro \ @@ -504,6 +512,13 @@ RT_SCRIPTS = \ # Unix runtime RT_UNIX = \ README_unix.txt \ + runtime/KVim.desktop \ + runtime/hi16-action-make.png \ + runtime/hi22-action-make.png \ + runtime/kde-tips \ + runtime/kvim32x32.png \ + runtime/kvim48x48.png \ + runtime/kvim64x64.png \ runtime/vim16x16.png \ runtime/vim16x16.xpm \ runtime/vim32x32.png \ @@ -630,8 +645,6 @@ EXTRA = \ src/tee/Makefile* \ src/tee/tee.c \ csdpmi4b.zip \ - emx.dll \ - emxlibcs.dll \ # generic language files LANG_GEN = \ diff --git a/emx.dll b/emx.dll Binary files differdeleted file mode 100644 index e16f07f58..000000000 --- a/emx.dll +++ /dev/null diff --git a/emxlibcs.dll b/emxlibcs.dll Binary files differdeleted file mode 100644 index 587f0e7de..000000000 --- a/emxlibcs.dll +++ /dev/null diff --git a/runtime/KVim.desktop b/runtime/KVim.desktop new file mode 100644 index 000000000..25ef20a56 --- /dev/null +++ b/runtime/KVim.desktop @@ -0,0 +1,44 @@ +# KDE Config File +[Desktop Entry] +Type=Application +Exec=kvim -f %F +Icon=kvim +MiniIcon=kvim +DocPath=kvim/index.html +Comment= +Comment[xx]=xx +Terminal=0 +Name=KVim +Name[eo]=VIM-fasado +Name[sv]=Kvim +Name[xx]=xx +Comment=Text Editor +Comment[ar]=محرر نصوص +Comment[bg]=Текст Редактор +Comment[de]=Texteditor +Comment[el]=Διορθωτής Κειμένου +Comment[eo]=Tekstredaktilo +Comment[et]=Tekstiredaktor +Comment[eu]=Testu Editorea +Comment[fi]=Tekstieditori +Comment[he]=עורך טקסט +Comment[is]=Textaritill +Comment[ja]=テキストエディタ +Comment[lt]=Teksto redaktorius +Comment[mt]=Editur tat-test +Comment[pt_BR]=Editor de Texto +Comment[ro]=Editor de text +Comment[ru]=редактор +Comment[sk]=Textový editor +Comment[sl]=Urejevalnik besedil +Comment[ta]=¯¨Ã ¦¾¡ÌôÀ¡Ç÷ +Comment[tr]=Metin Düzenleyici +Comment[uk]=Редактор текстів +Comment[vi]=Trình soạn văn bản +Comment[xx]=xx +Comment[zh_CN]=文本编辑器 +Comment[zh_TW]=文字編輯器 +MimeType=application/mathml+xml;application/xhtml+xml;application/x-perl;application/x-python;application/x-shellscript;audio/x-mpegurl;audio/x-scpls;image/svg+xml;message/news;message/rfc822;text/calendar;text/css;text/english;text/html;text/mrml;text/plain;text/rdf;text/rss;text/rtf;text/sgml;text/vnd.wap.wml;text/x-adasrc;text/x-bibtex;text/x-chdr;text/x-c++hdr;text/x-csrc;text/x-c++src;text/x-csv;text/x-diff;text/x-java;text/x-katefilelist;text/x-latex;text/x-log;text/x-lyx;text/x-makefile;text/xmcd;text/xml;text/x-moc;text/x-mswinurl;text/x-objcsrc;text/x-pascal;text/x-perl;text/x-python;text/x-tcl;text/x-tex;text/x-vcalendar;text/x-vcard;text/x-xslfo;text/x-xslt +X-KDE-StartupNotify=true +X-KDE-AuthorizeAction=shell access + diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 4cc747211..e723db5e8 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -1,4 +1,4 @@ -*autocmd.txt* For Vim version 7.0aa. Last change: 2004 Apr 20 +*autocmd.txt* For Vim version 7.0aa. Last change: 2004 Jun 30 VIM REFERENCE MANUAL by Bram Moolenaar @@ -304,7 +304,8 @@ FocusGained When Vim got input focus. Only for the GUI *FocusLost* FocusLost When Vim lost input focus. Only for the GUI version and a few console versions where this - can be detected. + can be detected. May also happen when a + dialog pops up. *FuncUndefined* FuncUndefined When a user function is used but it isn't defined. Useful for defining a function only @@ -467,6 +468,21 @@ VimLeave Before exiting Vim, just after writing the *EncodingChanged* EncodingChanged Fires off when the 'encoding' option is changed. Useful to set up fonts, for example. + *InsertEnter* +InsertEnter When starting Insert mode. Also for Replace + mode and Virtual Replace mode. The + |v:insertmode| variable indicates the mode. + Be careful not to move the cursor or do + anything else that the user does not expect. + *InsertChange* +InsertChange When typing <Insert> while in Insert or + Replace mode. The |v:insertmode| variable + indicates the new mode. + Be careful not to move the cursor or do + anything else that the user does not expect. + *InsertLeave* +InsertLeave When leaving Insert mode. Also when using + CTRL-O |i_CTRL-O|. *FileEncoding* FileEncoding Obsolete. It still works and is equivalent to |EncodingChanged|. diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 9d39f61f6..14d0dd803 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.0aa. Last change: 2004 Jun 22 +*eval.txt* For Vim version 7.0aa. Last change: 2004 Jun 30 VIM REFERENCE MANUAL by Bram Moolenaar @@ -679,6 +679,13 @@ v:foldend Used for 'foldtext': last line of closed fold. v:foldstart Used for 'foldtext': first line of closed fold. Read-only. |fold-foldtext| + *v:insertmode* *insertmode-variable* +v:insertmode Used for the |InsertEnter| and |InsertChange| autocommand + events. Values: + i Insert mode + r Replace mode + v Virtual Replace mode + *v:lang* *lang-variable* v:lang The current locale setting for messages of the runtime environment. This allows Vim scripts to be aware of the @@ -2765,6 +2772,7 @@ gui_athena Compiled with Athena GUI. gui_beos Compiled with BeOS GUI. gui_gtk Compiled with GTK+ GUI (any version). gui_gtk2 Compiled with GTK+ 2 GUI (gui_gtk is also defined). +gui_kde Compiled with KDE GUI |KVim| gui_mac Compiled with Macintosh GUI. gui_motif Compiled with Motif GUI. gui_photon Compiled with Photon GUI. diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt index 2e59cc084..b83acd6c2 100644 --- a/runtime/doc/gui.txt +++ b/runtime/doc/gui.txt @@ -25,8 +25,8 @@ Other GUI documentation: First you must make sure you actually have a version of Vim with the GUI code included. You can check this with the ":version" command, it should include -"+GUI_Athena", "+GUI_BeOS", "+GUI_GTK", "+GUI_Motif" or "MS-Windows ... bit -GUI version". +"+GUI_Athena", "+GUI_BeOS", "+GUI_GTK", "+GUI_KDE", "+GUI_Motif" or +"MS-Windows ... bit GUI version". How to start the GUI depends on the system used. Mostly you can run the GUI version of Vim with: @@ -94,8 +94,8 @@ There are a number of options which only have meaning in the GUI version of Vim. These are 'guicursor', 'guifont', 'guipty' and 'guioptions'. They are documented in |options.txt| with all the other options. -If using the Motif or Athena version of the GUI (but not for the GTK+ or Win32 -version), a number of X resources are available. See |gui-resources|. +If using the Motif or Athena version of the GUI (but not for the KDE, GTK+ or +Win32 version), a number of X resources are available. See |gui-resources|. Another way to set the colors for different occasions is with highlight groups. The "Normal" group is used to set the background and foreground @@ -479,7 +479,7 @@ a menu entry. Hit <Enter> to execute it. Hit <Esc> if you want to cancel. This does require the |+menu| feature enabled at compile time. *tear-off-menus* -GTK+ and Motif support Tear-off menus. These are sort of sticky menus or +KDE, GTK+ and Motif support Tear-off menus. These are sort of sticky menus or pop-up menus that are present all the time. If the resizing does not work correctly, this may be caused by using something like "Vim*geometry" in the defaults. Use "Vim.geometry" instead. @@ -646,8 +646,8 @@ because the item will never be selected. Use a single colon to keep it simple. *gui-toolbar* -The toolbar is currently available in the Win32, Athena, Motif, GTK+ (X11) and -Photon GUI. It should turn up in other GUIs in due course. The default +The toolbar is currently available in the Win32, Athena, Motif, GTK+ (X11), +KDE and Photon GUI. It should turn up in other GUIs in due course. The default toolbar is setup in menu.vim. The display of the toolbar is controlled by the 'guioptions' letter 'T'. You can thus have menu & toolbar together, or either on its own, or neither. @@ -735,7 +735,7 @@ from the main menu bar. You must then use the |:popup| or |:tearoff| command to display it. *popup-menu* -In the Win32, GTK+, Motif, Athena and Photon GUI, you can define the special +In the Win32, KDE, GTK+, Motif, Athena and Photon GUI, you can define the special menu "PopUp". This is the menu that is displayed when the right mouse button is pressed, if 'mousemodel' is set to popup or popup_setpos. diff --git a/runtime/doc/gui_x11.txt b/runtime/doc/gui_x11.txt index d54730229..3e3a8e40c 100644 --- a/runtime/doc/gui_x11.txt +++ b/runtime/doc/gui_x11.txt @@ -12,8 +12,9 @@ Vim's Graphical User Interface *gui-x11* *GUI-X11* 4. Various |gui-x11-various| 5. GTK version |gui-gtk| 6. GNOME version |gui-gnome| -7. Compiling |gui-x11-compiling| -8. X11 selection mechanism |x11-selection| +7. KDE version |gui-kde| +8. Compiling |gui-x11-compiling| +9. X11 selection mechanism |x11-selection| Other relevant documentation: |gui.txt| For generic items of the GUI. @@ -59,7 +60,7 @@ flag in 'guioptions'. |-f|. ============================================================================== 2. GUI Resources *gui-resources* *.Xdefaults* -If using the Motif or Athena version of the GUI (not for the GTK+ or Win32 +If using the Motif or Athena version of the GUI (not for the KDE, GTK+ or Win32 version), a number of X resources are available. You should use Vim's class "Vim" when setting these. They are as follows: @@ -434,7 +435,61 @@ the WM to identify the window by restoring the window role (using the |--role| command line argument). ============================================================================== -7. Compiling *gui-x11-compiling* +7. KDE version *gui-kde* *KDE* *KVim* + +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. +Most important difference is the font handling, KVim uses QFont to display the +text. To set your font use the following syntax : +> + :set guifont=Fixed\ [Misc]/10/-1/5/50/0/0/0/1/0 +< +the '10' value is the font size, other settings concerns more specific Qt +options which you should not need to care with. +The suggested way to choose your font is through the font selection dialog +available with the command : + :set guifont=* + +Note: X Font names are not supported any more, so if you use GVim too, you'll +have to set something like this in your ~/.gvimrc : > + + if has("gui_kde") + :set guifont=Fixed\ [Misc]/10/-1/5/50/0/0/0/1/0 + else if has("gui_gtk") + :set guifont=-misc-fixed-medium-r-normal-*-*-100-*-*-c-*-iso10646-1 + endif +< + *antialias* +KVim uses antialias for its font, so that the text looks better, to disable +this you have to refer to Qt's documentation (export QT_XFT=0 for QT 2.x). + +KDE provides some other features, like being able to move the menubar and the +toolbar wherever you want around the text area. + + *kde-toolbar* +KVim can be used with a KDE-look toolbar instead of Vim's default toolbar. To +enable this feature you have to run the configure script with the +--enable-kde-toolbar switch. It may be moved to a runtime option in the +future. + + *DCOP* +Since Vim 6.0, the new ClientServer feature has been added, it works fine in +KVim too. KVim also provides its own communication scheme based on DCOP. This +is mainly used by the |vimpart| but can freely be used by other applications +or manually through KDE's DCOP tools. The DCOP servername is synchronized with +the X11 servername so that it's easier to identify the same KVim through the +two communication systems. + + *vimpart* *vim-kpart* +KVim developers are also working on a component to allow embedding of Vim into +KDE's applications. As of this writing, the component is working and can be +used in different KDE applications. New KDE applications should support it +soon. To get more information about this component, refer to +http://freehackers.org/kvim or to the KDE project. + +============================================================================== +8. Compiling *gui-x11-compiling* If using X11, Vim's Makefile will by default first try to find the necessary GTK+ files on your system. If the GTK+ files cannot be found, then the Motif @@ -489,6 +544,12 @@ menus look a bit better. Edit the Makefile and look for "XAW_LIB". The scrollbars will remain the same, because Vim has its own, which are already 3D (in fact, they look more like Motif). + *gui-x11-kde* +For Vim-KDE, you need at least Qt(>=2.x) and the corresponding kdelibs. +To compile, you must use the --with-qt-dir configure flag because QTDIR is not +automatically detected yet. Giving KDE's directories to the configure script +may also help in some cases. + *gui-x11-neXtaw* The neXtaw version is mostly like Athena, but uses different widgets. @@ -499,7 +560,7 @@ X11R5 with a library for X11R6 probably doesn't work (although the linking won't give an error message, Vim will crash later). ============================================================================== -8. X11 selection mechanism *x11-selection* +9. X11 selection mechanism *x11-selection* If using X11, in either the GUI or an xterm with an X11-aware Vim, then Vim provides varied access to the X11 selection and clipboard. These are accessed diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 297012d47..bfaad469d 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 7.0aa. Last change: 2004 Jun 21 +*options.txt* For Vim version 7.0aa. Last change: 2004 Jun 28 VIM REFERENCE MANUAL by Bram Moolenaar @@ -468,10 +468,10 @@ short for "example:"). *modeline-local* The options are set like with ":setlocal": The new value only applies to the -buffer that contains the window. Although it's possible to set global options -from a modeline, this is unusual. If you have two windows open and the files -in it set the same global option to a different value, the result depends on -which one was opened last. +buffer and window that contain the file. Although it's possible to set global +options from a modeline, this is unusual. If you have two windows open and +the files in it set the same global option to a different value, the result +depends on which one was opened last. *modeline-version* If the modeline is only to be used for some versions of Vim, the version @@ -5436,7 +5436,7 @@ A jump table for the options with a short description can be found at |Q_op|. |shift-left-right|. What gets inserted (a Tab or spaces) depends on the 'expandtab' option. Also see |ins-expandtab|. When 'expandtab' is not set, the - number of spaces minimized by using <Tab>s. + number of spaces is minimized by using <Tab>s. NOTE: This option is reset when 'compatible' is set. *'softtabstop'* *'sts'* @@ -5480,9 +5480,9 @@ A jump table for the options with a short description can be found at |Q_op|. global {not in Vi} When "on" the commands listed below move the cursor to the first - blank of the line. When off the cursor is kept in the same column + non-blank of the line. When off the cursor is kept in the same column (if possible). This applies to the commands: CTRL-D, CTRL-U, CTRL-B, - CTRL-F, "G", "H", "M", "L", , and to the commands "d", "<<" and ">>" + CTRL-F, "G", "H", "M", "L", gg, and to the commands "d", "<<" and ">>" with a linewise operator, with "%" with a count and to buffer changing commands (CTRL-^, :bnext, :bNext, etc.). Also for an Ex command that only has a line number, e.g., ":25" or ":+". diff --git a/runtime/doc/os_amiga.txt b/runtime/doc/os_amiga.txt index fd215834f..069e76964 100644 --- a/runtime/doc/os_amiga.txt +++ b/runtime/doc/os_amiga.txt @@ -1,4 +1,4 @@ -*os_amiga.txt* For Vim version 7.0aa. Last change: 2004 Apr 25 +*os_amiga.txt* For Vim version 7.0aa. Last change: 2004 Jun 28 VIM REFERENCE MANUAL by Bram Moolenaar @@ -30,6 +30,12 @@ the |+digraphs| feature. If you want to use Vim with other terminals you can recompile with the TERMCAP option. Vim compiles with Manx 5.x and SAS 6.x. See the makefiles and feature.h. +If you notice Vim crashes on some files when syntax highlighting is on, or +when using a search pattern with nested wildcards, it might be that the stack +is too small. Try increasing the stack size. In a shell use the Stack +command before launching Vim. On the Workbench, select the Vim icon, use the +workbench "Info" menu and change the Stack field in the form. + If you want to use different colors set the termcap codes: t_mr (for inverted text) t_md (for bold text) diff --git a/runtime/doc/pi_netrw.txt b/runtime/doc/pi_netrw.txt index 0a13dc251..8112af86b 100644 --- a/runtime/doc/pi_netrw.txt +++ b/runtime/doc/pi_netrw.txt @@ -1,4 +1,4 @@ -*pi_netrw.txt* For Vim version 6.2. Last change: Jun 15, 2004 +*pi_netrw.txt For Vim version 6.2. Last change: Jun 25, 2004 VIM REFERENCE MANUAL by Charles E. Campbell, Jr. @@ -16,7 +16,7 @@ 4. Transparent File Transfer...........................|netrw-transparent| 5. Ex Commands.........................................|netrw-ex| 6. Variables and Options...............................|netrw-var| -7. Remote Directory Listing............................|netrw-dir| +7. Remote Directory Browser............................|netrw-browse| 8. Debugging...........................................|netrw-debug| 9. History.............................................|netrw-history| 10. Credits.............................................|netrw-credits| @@ -493,28 +493,116 @@ from <netrw.vim> itself: > ============================================================================== -7. Remote Directory Listing *netrw-dir* *netrw-list* +7. Remote Directory Browser *netrw-browse* *netrw-dir* *netrw-list* +> + ------- ----------- + Command Explanation + ------- ----------- + <cr> Netrw will enter the directory or read the file + <del> Netrw will attempt to remove the file/directory + D Netrw will attempt to remove the file(s)/directory(ies) + R Netrw will attempt to rename the file(s)/directory(ies) + - Makes Netrw go up one directory + a Show all of a directory (temporarily ignore g:netrw_list_hide) + o Enter the file/directory under the cursor in a new browser + window. A horizontal split is used. + v Enter the file/directory under the cursor in a new browser + window. A vertical split is used. + x Apply a function to a file. + <c-l> Causes Netrw to refresh the directory listing + ? Causes Netrw to issue help +< + *netrw-browse-var* +> + --- ----------- + Var Explanation + --- ----------- + g:netrw_list_cmd supports listing + g:netrw_rm_cmd supports removing files + g:netrw_rmf_cmd supports removing softlinks to directories + g:netrw_rmdir_cmd supports removing directories + g:netrw_winsize specify initial size of new o/v windows + g:netrw_list_hide comma separated list of patterns for + hiding files +< +Netrw supports the browsing of directories on remote hosts, including +generating listing directories, entering directories, editing files +therein, deleting files/directories, and moving (renaming) files and +directories. -Netrw supports listing (browsing) directories on remote hosts; simply attempt -to read a "file" with a trailing slash and it will be interpreted as a -request to browse a directory: +To enter the netrw directory browser, simply attempt to read a "file" with a +trailing slash and it will be interpreted as a request to list a directory: vim [protocol]://[user@]hostname/path/ -Netrw will modify the command in g:netrw_list to perform the directory listing -operation. By default the command is: +Netrw will modify the command in g:netrw_list_cmd to perform the directory +listing operation. By default the command is: - ssh HOSTNAME ls -Fa + ssh HOSTNAME ls -FLa -where the HOSTNAME becomes the hostname as requested by the attempted -read. Naturally, the user may override this command with whatever is +where the HOSTNAME becomes the [user@]hostname as requested by the attempt +to read. Naturally, the user may override this command with whatever is preferred. The NetList function which implements remote directory browsing expects that directories will be flagged by a trailing slash. Browsing is simple: move the cursor onto a file or directory of interest. -Hitting the <cr> (the return key) will select the file or directory. Directories -will themselves be listed, and files will be opened using the protocol given -in the original read request. +Hitting the <cr> (the return key) will select the file or directory. +Directories will themselves be listed, and files will be opened using the +protocol given in the original read request. + + *netrw-delete* *netrw-remove* + +Deleting/removing files and directories involves moving the cursor to the +file/directory to be deleted and pressing "D". Directories must be empty +first before they can be successfully removed. If the directory is a softlink +to a directory, then netrw will make two requests to remove the directory +before succeeding. Netrw will ask for confirmation before doing the +removal(s). You may select a range of lines with the "V" command (visual +selection), and then pressing "D". + +The g:netrw_rm_cmd, g:netrw_rmf_cmd, and g:netrw_rmdir_cmd variables are +used to control the attempts to remove files and directories. The +g:netrw_rm_cmd is used with files, and its default value is: + + g:netrw_rm_cmd: ssh HOSTNAME rm + +The g:netrw_rmdir_cmd is used with directories. Its default value is: + + g:netrw_rmdir_cmd: ssh HOSTNAME rmdir + +If removing a directory fails with g:netrw_rmdir_cmd, netrw then will attempt +to remove it again using the g:netrw_rmf_cmd. Its default value is: + + g:netrw_rmf_cmd: ssh HOSTNAME rm -f + + *netrw-x* + +The Netrw executor applies a user-defined function to a file, based on its +extension. Of course, the handler function must exist for it to be called. +> + Ex. mypgm.html x -> NetrwFileHandler_html("scp://user@host/some/path/mypgm.html") +< +See the <NetrwFileHandlers.vim> + + *netrw-move* *netrw-rename* + +Renaming/moving files and directories involves moving the cursor to the +file/directory to be moved (renamed) and pressing "R". You will then be +queried for where you want the file/directory to be moved. You may select a +range of lines with the "V" command (visual selection), and then pressing "R". + +The g:netrw_rename_cmd is used to implement renaming. By default its +value is: + + ssh HOSTNAME mv + + *netrw-list-hack* +For Linux/Unix systems, I suggest looking into + + http://hacks.oreilly.com/pub/h/66 + +It gives a tip for setting up password-less use of ssh and scp, and discusses +the associated security issues. ============================================================================== @@ -551,6 +639,7 @@ which is loaded automatically at startup (assuming :set nocp). ============================================================================== 9. History *netrw-history* + v47: * v46: * now handles remote directory browsing * g:netrw_silent (if 1) will cause all transfers to be silent'd v45: * made the [user@]hostname:path form a bit more restrictive diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index f2fa8f6e6..faf31168b 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -483,13 +483,14 @@ if the pattern starts with "^" and ends in "$"). A "*" matches any sequence of characters. 'ignorecase' is not used, but "\c" can be used in the pattern to ignore case |/\c|. Don't include the () for the function name! -The match for sourced scripts is done against the full file name. Examples: > - breakadd file explorer -won't match, the path is missing. > +The match for sourced scripts is done against the full file name. If no path +is specified the current directory is used. Examples: > + breakadd file explorer.vim +matches "explorer.vim" in the current directory. > breakadd file *explorer.vim -matches ".../plugin/explorer.vim" and ".../plugin/iexplorer.vim". > +matches ".../plugin/explorer.vim", ".../plugin/iexplorer.vim", etc. > breakadd file */explorer.vim -matches ".../plugin/explorer.vim" only. +matches ".../plugin/explorer.vim" and "explorer.vim" in any other directory. The match for functions is done against the name as it's shown in the output of ":function". For local functions this means that something like "<SNR>99_" diff --git a/runtime/doc/tags b/runtime/doc/tags index 25f0a2087..e3873df1f 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -2874,6 +2874,7 @@ CursorHold autocmd.txt /*CursorHold* CursorHold-example windows.txt /*CursorHold-example* CursorIM mbyte.txt /*CursorIM* D change.txt /*D* +DCOP gui_x11.txt /*DCOP* DOS os_dos.txt /*DOS* DOS-format editing.txt /*DOS-format* DOS-format-write editing.txt /*DOS-format-write* @@ -3583,9 +3584,14 @@ IM-server mbyte.txt /*IM-server* IME mbyte.txt /*IME* Insert insert.txt /*Insert* Insert-mode insert.txt /*Insert-mode* +InsertChange autocmd.txt /*InsertChange* +InsertEnter autocmd.txt /*InsertEnter* +InsertLeave autocmd.txt /*InsertLeave* J change.txt /*J* Japanese mbyte.txt /*Japanese* K various.txt /*K* +KDE gui_x11.txt /*KDE* +KVim gui_x11.txt /*KVim* Korean mbyte.txt /*Korean* L motion.txt /*L* Linux-backspace options.txt /*Linux-backspace* @@ -3634,6 +3640,7 @@ Operator-pending intro.txt /*Operator-pending* Operator-pending-mode intro.txt /*Operator-pending-mode* OverTheSpot mbyte.txt /*OverTheSpot* P change.txt /*P* +PATHEXT eval.txt /*PATHEXT* Pattern pattern.txt /*Pattern* Perl if_perl.txt /*Perl* Posix intro.txt /*Posix* @@ -3908,6 +3915,7 @@ alternate-file editing.txt /*alternate-file* amiga-window starting.txt /*amiga-window* ant-syntax syntax.txt /*ant-syntax* ant.vim syntax.txt /*ant.vim* +antialias gui_x11.txt /*antialias* ap motion.txt /*ap* apache-syntax syntax.txt /*apache-syntax* apache.vim syntax.txt /*apache.vim* @@ -4213,6 +4221,7 @@ cpo-C options.txt /*cpo-C* cpo-D options.txt /*cpo-D* cpo-E options.txt /*cpo-E* cpo-F options.txt /*cpo-F* +cpo-I options.txt /*cpo-I* cpo-J options.txt /*cpo-J* cpo-K options.txt /*cpo-K* cpo-L options.txt /*cpo-L* @@ -4780,6 +4789,7 @@ gui-gtk gui_x11.txt /*gui-gtk* gui-gtk-socketid gui_x11.txt /*gui-gtk-socketid* gui-horiz-scroll gui.txt /*gui-horiz-scroll* gui-init gui.txt /*gui-init* +gui-kde gui_x11.txt /*gui-kde* gui-mouse gui.txt /*gui-mouse* gui-mouse-focus gui.txt /*gui-mouse-focus* gui-mouse-mapping gui.txt /*gui-mouse-mapping* @@ -4811,6 +4821,7 @@ gui-x11 gui_x11.txt /*gui-x11* gui-x11-athena gui_x11.txt /*gui-x11-athena* gui-x11-compiling gui_x11.txt /*gui-x11-compiling* gui-x11-gtk gui_x11.txt /*gui-x11-gtk* +gui-x11-kde gui_x11.txt /*gui-x11-kde* gui-x11-misc gui_x11.txt /*gui-x11-misc* gui-x11-motif gui_x11.txt /*gui-x11-motif* gui-x11-neXtaw gui_x11.txt /*gui-x11-neXtaw* @@ -4830,6 +4841,8 @@ gvim starting.txt /*gvim* gvimdiff diff.txt /*gvimdiff* gvimrc gui.txt /*gvimrc* gw change.txt /*gw* +gwgw change.txt /*gwgw* +gww change.txt /*gww* gzip pi_gzip.txt /*gzip* gzip-autocmd pi_gzip.txt /*gzip-autocmd* gzip-example autocmd.txt /*gzip-example* @@ -5097,6 +5110,7 @@ insert_expand insert.txt /*insert_expand* inserting insert.txt /*inserting* inserting-ex insert.txt /*inserting-ex* inserting-file insert.txt /*inserting-file* +insertmode-variable eval.txt /*insertmode-variable* install usr_90.txt /*install* install-home usr_90.txt /*install-home* install-registry gui_w32.txt /*install-registry* @@ -5125,6 +5139,7 @@ jumplist motion.txt /*jumplist* jumpto-diffs diff.txt /*jumpto-diffs* k motion.txt /*k* kcc uganda.txt /*kcc* +kde-toolbar gui_x11.txt /*kde-toolbar* key-codes intro.txt /*key-codes* key-codes-changed version4.txt /*key-codes-changed* key-mapping map.txt /*key-mapping* @@ -5360,23 +5375,32 @@ netbeans-support netbeans.txt /*netbeans-support* netbeans.txt netbeans.txt /*netbeans.txt* netrw pi_netrw.txt /*netrw* netrw-activate pi_netrw.txt /*netrw-activate* +netrw-browse pi_netrw.txt /*netrw-browse* +netrw-browse-var pi_netrw.txt /*netrw-browse-var* netrw-contents pi_netrw.txt /*netrw-contents* netrw-credits pi_netrw.txt /*netrw-credits* netrw-debug pi_netrw.txt /*netrw-debug* +netrw-delete pi_netrw.txt /*netrw-delete* +netrw-dir pi_netrw.txt /*netrw-dir* netrw-ex pi_netrw.txt /*netrw-ex* netrw-file pi_netrw.txt /*netrw-file* netrw-fixup pi_netrw.txt /*netrw-fixup* +netrw-history pi_netrw.txt /*netrw-history* +netrw-list pi_netrw.txt /*netrw-list* +netrw-list-hack pi_netrw.txt /*netrw-list-hack* +netrw-move pi_netrw.txt /*netrw-move* netrw-netrc pi_netrw.txt /*netrw-netrc* -netrw-new pi_netrw.txt /*netrw-new* -netrw-newstuff pi_netrw.txt /*netrw-newstuff* netrw-options pi_netrw.txt /*netrw-options* netrw-passwd pi_netrw.txt /*netrw-passwd* netrw-protocol pi_netrw.txt /*netrw-protocol* netrw-ref pi_netrw.txt /*netrw-ref* +netrw-remove pi_netrw.txt /*netrw-remove* +netrw-rename pi_netrw.txt /*netrw-rename* netrw-transparent pi_netrw.txt /*netrw-transparent* netrw-uidpass pi_netrw.txt /*netrw-uidpass* netrw-urls pi_netrw.txt /*netrw-urls* netrw-var pi_netrw.txt /*netrw-var* +netrw-x pi_netrw.txt /*netrw-x* netrw-xfer pi_netrw.txt /*netrw-xfer* netrw.vim pi_netrw.txt /*netrw.vim* netterm-mouse options.txt /*netterm-mouse* @@ -5545,7 +5569,6 @@ phtml-syntax syntax.txt /*phtml-syntax* phtml.vim syntax.txt /*phtml.vim* pi_expl.txt pi_expl.txt /*pi_expl.txt* pi_gzip.txt pi_gzip.txt /*pi_gzip.txt* -pi_netrw.txt pi_netrw.txt /*pi_netrw.txt* pi_spec.txt pi_spec.txt /*pi_spec.txt* plugin usr_05.txt /*plugin* plugin-details filetype.txt /*plugin-details* @@ -6265,6 +6288,7 @@ v:folddashes eval.txt /*v:folddashes* v:foldend eval.txt /*v:foldend* v:foldlevel eval.txt /*v:foldlevel* v:foldstart eval.txt /*v:foldstart* +v:insertmode eval.txt /*v:insertmode* v:lang eval.txt /*v:lang* v:lc_time eval.txt /*v:lc_time* v:lnum eval.txt /*v:lnum* @@ -6348,6 +6372,7 @@ v_g_CTRL-] tagsrch.txt /*v_g_CTRL-]* v_gf editing.txt /*v_gf* v_gq change.txt /*v_gq* v_gv visual.txt /*v_gv* +v_gw change.txt /*v_gw* v_i motion.txt /*v_i* v_i( motion.txt /*v_i(* v_i) motion.txt /*v_i)* @@ -6409,6 +6434,7 @@ vim-announce intro.txt /*vim-announce* vim-arguments starting.txt /*vim-arguments* vim-default-editor gui_w32.txt /*vim-default-editor* vim-dev intro.txt /*vim-dev* +vim-kpart gui_x11.txt /*vim-kpart* vim-mac intro.txt /*vim-mac* vim-modes intro.txt /*vim-modes* vim-modes-intro intro.txt /*vim-modes-intro* @@ -6429,6 +6455,7 @@ viminfo-file-marks starting.txt /*viminfo-file-marks* viminfo-file-name starting.txt /*viminfo-file-name* viminfo-read starting.txt /*viminfo-read* viminfo-write starting.txt /*viminfo-write* +vimpart gui_x11.txt /*vimpart* vimrc starting.txt /*vimrc* vimrc-filetype usr_05.txt /*vimrc-filetype* vimrc-intro usr_05.txt /*vimrc-intro* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index ea6dea263..17b7b40d5 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 Jun 24 +*todo.txt* For Vim version 7.0aa. Last change: 2004 Jun 30 VIM REFERENCE MANUAL by Bram Moolenaar @@ -30,35 +30,8 @@ be worked on, but only if you sponsor Vim development. See |sponsor|. *known-bugs* -------------------- Known bugs and current work ----------------------- -Change for fsync() error in Vim 6 as patch? - For version 7.0: - Include many PATCHES: - 9 Merge in ideas from tutor.txt (Gabriel Zachmann) - New version 2004 June 16. - 8 ":winpos" doesn't work. Patch from Vipin Aravind. - 8 Add GTK 2.3 file dialog support. Patch by Grahame Bowland, 2004 Mar 15, - but it doesn't use "initdir" or "dflt". (will update patch) - 8 On Sinix SYS_NMLN isn't defined. Include patch from Cristiano De - Michele. He no longer has such a machine. - 8 Add file locking. Lock a file when starting to edit it with flock() or - fcntl(). This patch has advisory file locking while reading/writing - the file: ~/vim/patches/kahn_file_locking . - Do we still want this? Andy doesn't have time to work on it. - 8 Add buffer-local autocommands? Reduces overhead for autocommands that - trigger often (inserting a character, switching mode). - :au Event <buffer> do-something - E.g.: - :au BufEnter <buffer> menu enable ... - :au BufLeave <buffer> menu disable ... - Patch from Yakov Lerner, including test (2004 Jan 7). - He'll send updated patch. - Autocommands: - VimResized - When the Vim window has been resized (SIGWINCH) - patch from Yakov Lerner, 2003 July 24. - He'll write documentation and send updated patch. - InsmodEnter - InsmodLeave Taro Muraoka, 2004 Jun 16 - Include the kvim patch. http://freenux.org/vim/ (Mickael Marchand) Do not add Qtopia yet, it doesn't work very well. update from Mickael 2004 Jun 20. @@ -130,6 +103,20 @@ For version 7.0: 'isfname'. E.g. ":set flipcase=a-zA-Z,xX,23-33:143-153". The colon to separate the from and to part is optional. Resp: no time now. + 8 Add GTK 2.3 file dialog support. Patch by Grahame Bowland, 2004 Mar 15, + but it doesn't use "initdir" or "dflt". (will update patch) + 8 Add buffer-local autocommands? Reduces overhead for autocommands that + trigger often (inserting a character, switching mode). + :au Event <buffer> do-something + E.g.: + :au BufEnter <buffer> menu enable ... + :au BufLeave <buffer> menu disable ... + Patch from Yakov Lerner, including test (2004 Jan 7). + He'll send updated patch. + Autocommands: + VimResized - When the Vim window has been resized (SIGWINCH) + patch from Yakov Lerner, 2003 July 24. + He'll write documentation and send updated patch. --- responses above -- 7 Make "5dd" on last-but-one-line not delete anything (Vi compatible). Add flag in 'cpoptions' for this. When not present, "2dd" in the last @@ -247,8 +234,11 @@ For version 7.0: - findmatch() should be adjusted for Lisp. See remark at get_lisp_indent(). Esp. \( and \) should be skipped. (Dorai Sitaram, incomplete patch Mar 18) + + - Change ga_room into ga_maxlen, so that it doesn't need to be incremented/decremented each time. +- For string variables, use length instead of NUL termination. - new DATA TYPES: lists, dictionaries and function references. Check old patch from Robert Webb for array support. Add type checking? See ~/vim/ideas.txt. @@ -311,6 +301,7 @@ For version 7.0: - FileChangedShellPost autocommand event: after (not) reloading a changed file. Can be used to update statusline oslt. - Displaying size of Visual area: use 24-33 column display. +- Mac: Unicode input and display (Eckehard Berns, June 27) Vi incompatibility: @@ -1577,6 +1568,13 @@ Robustness: A long line with a " in it can cause a crash when it runs out of stack space (on systems where this isn't caught). How can we catch this for more systems? +6 Add file locking. Lock a file when starting to edit it with flock() or + fcntl(). This patch has advisory file locking while reading/writing + the file for Vim 5.4: ~/vim/patches/kahn_file_locking . + The patch is incomplete (needs support for more systems, autoconf). + Andy doesn't have time to work on it. + Disadvantage: Need to find ways to gracefully handle failure to obtain a + lock. When to release a lock: When buffer is unloaded? Performance: @@ -2016,8 +2014,8 @@ Autocommands: ReplaceEnter - Entering Replace mode CmdEnter - Entering Cmdline mode VisualEnter - Entering Visual mode + *Leave - Leaving a mode (in pair with the above *Enter) CmdUndefined - Like FuncUndefined but for user commands. - *Leave - Leaving the mode SearchPost - After doing a search command (e.g. to do "M") PreDirChanged/PostDirChanged - Before/after ":cd" has been used (for changing the diff --git a/runtime/doc/usr_27.txt b/runtime/doc/usr_27.txt index 46fb19070..82d17b215 100644 --- a/runtime/doc/usr_27.txt +++ b/runtime/doc/usr_27.txt @@ -1,4 +1,4 @@ -*usr_27.txt* For Vim version 7.0aa. Last change: 2003 Oct 28 +*usr_27.txt* For Vim version 7.0aa. Last change: 2004 Jun 26 VIM USER MANUAL - by Bram Moolenaar @@ -304,9 +304,9 @@ Will match "ab" in "abbb". Actually, it will never match more than one b, because there is no reason to match more. It requires something else to force it to match more than the lower limit. The same rules apply to removing "n" and "m". It's even possible to remove -both of the, resulting in "\{-}". This matches the item before it zero or -more times, as few as possible. The item by itself always match zero times. -It is useful when combined with something else. Example: > +both of the numbes, resulting in "\{-}". This matches the item before it zero +or more times, as few as possible. The item by itself always matches zero +times. It is useful when combined with something else. Example: > /a.\{-}b diff --git a/runtime/doc/version7.txt b/runtime/doc/version7.txt index e366f0763..8f3dbba23 100644 --- a/runtime/doc/version7.txt +++ b/runtime/doc/version7.txt @@ -1,4 +1,4 @@ -*version7.txt* For Vim version 7.0aa. Last change: 2004 Jun 24 +*version7.txt* For Vim version 7.0aa. Last change: 2004 Jun 30 VIM REFERENCE MANUAL by Bram Moolenaar @@ -61,6 +61,15 @@ In Vim scripts the following types have been added: Many functions and commands have been added to support the new types. +NOT IMPLEMENTED YET! + + +KDE support *new-kde* +----------- + +Kvim is the KDE version of Vim. It uses the Qt toolkit. See |KVim|. +(Thomas Capricelli, Philippe Fremy, Mickael Marchand, Mark Westcott, et al.) + Various new items *new-items-7* ----------------- @@ -73,12 +82,18 @@ Options: ~ Ex commands: ~ +Win32: The ":winpos" command now also works in the console. (Vipin Aravind) + New functions: ~ New autocommand events: ~ +InsertEnter starting Insert or Replace mode +InsertChange going from Insert to Replace mode or back +InsertLeave leaving Insert or Replace mode + New Syntax files: ~ @@ -89,6 +104,9 @@ character selections can be used between two Vims. (Eckehard Berns) Also fixes the problem that setting 'clipboard' to "unnamed" breaks using "yyp". +The netrw plugin now also supports viewing a directory, when "scp://" is used. +Deleting and renaming files is possible. (Charles Campbell) + ============================================================================== IMPROVEMENTS *improvements-7* @@ -97,6 +115,8 @@ IMPROVEMENTS *improvements-7* ":breakadd here" and ":breakdel here" can be used to set or delete a breakpoint at the cursor. +The tutor was updated to make it simpler to use and added text to explain a +few more important commands. Used ideas from Gabriel Zachmann. ============================================================================== COMPILE TIME CHANGES *compile-changes-7* @@ -152,4 +172,7 @@ After using cursor(line, col) moving up/down doesn't keep the same column. Win32: Borland C before 5.5 requires using ".u." for LowPart and HighPart fields. (Walter Briscoe) +On Sinix SYS_NMLN isn't always defined. Define it ourselves. (Cristiano De +Michele) + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/filetype.vim b/runtime/filetype.vim index eba1c19c3..897fe7180 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2004 Jun 10 +" Last Change: 2004 Jun 27 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -956,6 +956,7 @@ if has("fname_case") else au BufNewFile,BufRead *.pl call FTCheck_pl() endif +au BufNewFile,BufRead *.plx setf perl fun! FTCheck_pl() if exists("g:filetype_pl") diff --git a/runtime/ftplugin/aspvbs.vim b/runtime/ftplugin/aspvbs.vim index 006e3ce20..e3bc70980 100644 --- a/runtime/ftplugin/aspvbs.vim +++ b/runtime/ftplugin/aspvbs.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: aspvbs " Maintainer: Dan Sharp <dwsharp at hotmail dot com> -" Last Changed: 2003 Sep 29 +" Last Changed: 2004 Jun 28 " URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin if exists("b:did_ftplugin") | finish | endif @@ -35,15 +35,16 @@ endif " thanks to Gontran BAERTS if exists("loaded_matchit") let s:notend = '\%(\<end\s\+\)\@<!' + let b:match_ignorecase = 1 let b:match_words = - \ s:notend . '\<If\>:^\s\+\<Else\>:\<ElseIf\>:\<end\s\+\<if\>,' . - \ s:notend . '\<Select\s\+\<Case\>:\<Case\>:\<Case\s\+\<Else\>:\<End\s\+\<Select\>,' . - \ '^\s*\<Sub\>:\<End\s\+\<Sub\>,' . - \ '^\s*\<Function\>:\<End\s\+\<Function\>,' . - \ '\<Class\>:\<End\s\+\<Class\>,' . - \ '^\s*\<Do\>:\<Loop\>,' . - \ '^\s*\<For\>:\<Next\>,' . - \ '\<While\>:\<Wend\>,' . + \ s:notend . '\<if\>\%(.\{-}then\s\+\w\)\@!:\<elseif\>:^\s*\<else\>:\<end\s\+\<if\>,' . + \ s:notend . '\<select\s\+case\>:\<case\>:\<case\s\+else\>:\<end\s\+select\>,' . + \ '^\s*\<sub\>:\<end\s\+sub\>,' . + \ '^\s*\<function\>:\<end\s\+function\>,' . + \ '\<class\>:\<end\s\+class\>,' . + \ '^\s*\<do\>:\<loop\>,' . + \ '^\s*\<for\>:\<next\>,' . + \ '\<while\>:\<wend\>,' . \ s:match_words endif @@ -52,7 +53,7 @@ if has("gui_win32") let b:browsefilter="ASP Files (*.asp)\t*.asp\n" . s:browsefilter endif -let b:undo_ftplugin = "unlet! b:match_words b:browsefilter | " . s:undo_ftplugin +let b:undo_ftplugin = "unlet! b:match_words b:match_ignorecase b:browsefilter | " . s:undo_ftplugin " Restore the saved compatibility options. let &cpo = s:save_cpo diff --git a/runtime/hi16-action-make.png b/runtime/hi16-action-make.png Binary files differnew file mode 100644 index 000000000..824c7580e --- /dev/null +++ b/runtime/hi16-action-make.png diff --git a/runtime/hi22-action-make.png b/runtime/hi22-action-make.png Binary files differnew file mode 100644 index 000000000..f9abb7796 --- /dev/null +++ b/runtime/hi22-action-make.png diff --git a/runtime/kde-tips b/runtime/kde-tips new file mode 100644 index 000000000..67b350d86 --- /dev/null +++ b/runtime/kde-tips @@ -0,0 +1,9314 @@ +*vimtips.txt* This file comes from the Vim Online tip database. These tips +were downloaded on Tue, 24 Sep 2002 15:27:26 -0700 More tips can be found at <A +HREF="http://vim.sf.net/tip_index.php">http://vim.sf.net/tip_index.php</A><BR> +A new tip file can be downloaded from <A +HREF="http://vim.sf.net/tip_download.php">http://vim.sf.net/tip_download.php</A><BR> + +Thanks for using vim online. + +<Tip category="KVim"> <html><center>the super star</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=1">http://vim.sf.net/tip_view.php?tip_id=1</A><BR> + +When a discussion started about learning vim on the vim list Juergen Salk +mentioned the "*" key as something that he wished he had know earlier. When +I read the mail I had to go help on what the heck the "*" did. I also wish +I had known earlier... + +Using the "*" key while in normal mode searches for the word under the cursor. + +If that doesn't save you a lot of typing, I don't know what will. + +</pre></tip> </html> <Tip category="KVim"> <html><center>easy +edit of files in the same directory</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=2">http://vim.sf.net/tip_view.php?tip_id=2</A><BR> + +It was often frustrating when I would open a file deep in the code tree and +then realize I wanted to open another file in that same directory. Douglas +Potts taught me a nice way to do this. Add the following snipit to your vimrc: + +" Edit another file in the same directory as the current file " uses +expression to extract path from current file's path " (thanks Douglas Potts) +if has("unix") + map ,e :e <C-R>=expand("%:p:h") . "/" <CR> +else + map ,e :e <C-R>=expand("%:p:h") . "\" <CR> +endif + +Then when you type ,e in normal mode you can use tab to complete to the +file. You can also expand this to allow for spitting, etc. Very very nice. + +</pre></tip> </html> <Tip category="KVim"> <html><center>use +vim to quickly compile java files</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=3">http://vim.sf.net/tip_view.php?tip_id=3</A><BR> + +For a number of years I used vim on an SGI box. When I left my job at SGI +I went to a company that developed on PCs. For 2 years I used IDEs. I was +unhappy. I was frustrated. I couldn't figure out why. (Beyond my machine +crashing twice a day.) Finally I upgraded to windows 2000 (kind of stable!) and +started using vim as an IDE. All was good. Here is how you use vim to compile +your java: + +1. While I'm sure this works with javac, javac is slow slow slow. So download +the Jikes complier first. (Jikes is from ibm, search on google for jikes +and you will find it..available on most platforms.) + +2. Add the following to your vimrc: + +set makeprg=jikes -nowarn -Xstdout +E % set +errorformat=%f:%l:%c:%*\d:%*\d:%*\s%m + +3. When you are editing a java file type :make and it will compile the +current file and jump you to the first error in the file (if any). Read +":help quickfix" for how to move between errors. + +To setup your classpath environment either launch gvim from a shell that +has your classpath/path setup or use the "let" command to configure it in +your vimrc. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Any word completion</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=4">http://vim.sf.net/tip_view.php?tip_id=4</A><BR> + +Either when programming or writing, I tend to have some identifiers or words +that I use all the time. By sheer accident, I noticed the 'ctrl-n' command, +that will attempt to complete the word under the cursor. Hit it once, and it +will try to complete it with the first match in the current file. If there is +no match, it will (at least in the case of C code) search through all files +included from the current one. Repeated invocations will cycle through all +found matches. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Quickly searching for a word</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=5">http://vim.sf.net/tip_view.php?tip_id=5</A><BR> + +To search for a word under the cursor in the current file you can use either +the "*" or "#" keys. + +The "*" key will search for the word from the current cursor position to +the end of the file. The "#" key will search for the word from the current +cursor position to the top of the file. + +Note that the above two keys will search for the whole word and not the +partial word. This is equivalent to using the <word> pattern in the +search commands (/ and ?). + +To search for partial matches, you can use the "g*" and "g#" key sequence. + +You can also use the mouse to search for a word. This will only work in +the GUI version of VIM (gvim) or a console version of VIM in an xterm which +accepts a mouse. Also, the 'mousemodel' should be set to 'extend'. Add the +following line to your .vimrc: + +set mousemodel=extend + +To search for a word under the cursor from the current cursor position to +the end of the file, press the shift key and click on the word using the +left mouse button. To search in the opposite direction, press the shift +key and click on the word using the the right mouse button. + +To get more help on these, use + +:help * :help # :help g* :help g# :help <S-LeftMouse> :help +<S-RightMouse> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Using the % key</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=6">http://vim.sf.net/tip_view.php?tip_id=6</A><BR> + +The % key can be used + +1. To jump to a matching opening or closing parenthesis, square + bracket or a curly brace i.e. ([{}]) +2. To jump to start or end of a C-style comment /* */. 3. To jump to a +matching #if, #ifdef, #else, #elif, #endif C + preprocessor conditionals. + +To get more information about this, do + + :help % + +The % key can be extended to support other matching pairs by modifying the +"matchpairs" option. Read the help on + + :help matchpairs + +</pre></tip> </html> <Tip category="KVim"> <html><center>Jumping +to the start and end of a code block</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=7">http://vim.sf.net/tip_view.php?tip_id=7</A><BR> + +To jump to the beginning of a C code block (while, switch, if etc), use the +[{ command. + +To jump to the end of a C code block (while, switch, if etc), use the ]} +command. + +The above two commands will work from anywhere inside the code block. + +To jump to the beginning of a parenthesis use the [( command. + +To jump to the end of a parenthesis use the ]) command. + +To get more help on these commands, do + +:help [{ :help ]} :help [( :help ]) + +</pre></tip> </html> <Tip category="KVim"> <html><center>Jumping +to the declaration of a local/global variable</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=8">http://vim.sf.net/tip_view.php?tip_id=8</A><BR> + +'gd' command: To jump to the declaration of a local variable in a C program, +position the cursor on the name of the variable and use the gd command. + +'gD' command: To jump to the declaration of a global variable in a C program, +position the cursor on the name of the variable and use the gD command. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Displaying +a variable/macro definition</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=9">http://vim.sf.net/tip_view.php?tip_id=9</A><BR> + +To display the definition of a variable, place the cursor on the variable +and use the [i command. To display a macro definition, place the cursor on +the macro name and use the [d command. Note that these commands will work +most of the time (not all the time). To get more help on these commands, use + +:help [i :help [d + +</pre></tip> </html> <Tip category="KVim"> <html><center>Jumping +to previosuly visited locations in a file</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=10">http://vim.sf.net/tip_view.php?tip_id=10</A><BR> + +Vim remembers all the locations visited by you in a file in a session. +You can jump to the older locations by pressing the Ctrl-O key. You can +jump to the newer locations by pressing the Ctrl-I or the <Tab> key. + +To get more help on these keys, use + +:help CTRL-O :help CTRL-I :help jump-motions + +</pre></tip> </html> <Tip category="KVim"> <html><center>Completing +words quicky in insert mode</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=11">http://vim.sf.net/tip_view.php?tip_id=11</A><BR> + +In Insert mode, press the Ctrl-p or Ctrl-n key to complete part of a word +that has been typed. + +This is useful while typing C programs to complete long variable and +function names. This also helps in avoiding typing mistakes. + +Note that using the 'complete' option, you can complete keywords defined in +one of the include files, tag file, etc. + +To get more help on this, use + +:help i_Ctrl-N :help i_Ctrl-P :help ins-completion :help complete + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Converting tabs to spaces</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=12">http://vim.sf.net/tip_view.php?tip_id=12</A><BR> + +To insert space characters whenever the tab key is pressed, set the +'expandtab' option: + + set expandtab + +With this option set, if you want to enter a real tab character use +Ctrl-V<Tab> key sequence. + +To control the number of space characters that will be inserted when the tab +key is pressed, set the 'tabstop' option. For example, to insert 4 spaces +for a tab, use: + + set tabstop=4 + +After the 'expandtab' option is set, all the new tab characters entered will +be changed to spaces. This will not affect the existing tab characters. +To change all the existing tab characters to match the current tab settings, +use + + :retab + +To change the number of space characters inserted for indentation, use the +'shiftwidth' option: + + set shiftwidth=4 + +For example, to get the following coding style, + - No tabs in the source file - All tab characters are 4 space + characters + +use the following set of options: + + set tabstop=4 set shiftwidth=4 set expandtab + +Add the above settings to your .vimrc file. + +To get more help on these options, use :help tabstop :help shiftwidth :help +expandtab + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Incremental search</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=13">http://vim.sf.net/tip_view.php?tip_id=13</A><BR> + +To move the cursor to the matched string, while typing the search string, +set the following option in the .vimrc file: + + set incsearch + +You can complete the search by pressing the Enter key. To cancel the search, +press the escape key. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Highlighting +all the search pattern matches</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=14">http://vim.sf.net/tip_view.php?tip_id=14</A><BR> + +To highlight all the search pattern matches in a file set the following option: + + :set hlsearch + +After this option is set, if you search for a pattern, all the matches in +the file will be highlighted in yellow. + +To disable the highlighting temporarily, use the command + + :nohlsearch + +This command will remove the highlighting for the current search. +The highlighting will come back for the next search. + +To disable the highlighting completely, set the following option: + + :set nohlsearch + +By default, the hlsearch option is turned off. + +To get more help on this option, use + +:help 'hlsearch' :help :nohlsearch + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Displaying status line always</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=15">http://vim.sf.net/tip_view.php?tip_id=15</A><BR> + +To display the status line always, set the following option in your .vimrc +file: + + set laststatus=2 + +The advantage of having the status line displayed always is, you can see +the current mode, file name, file status, ruler, etc. + +To get more help on this, use + +:help laststatus + +</pre></tip> </html> <Tip category="KVim"> <html><center>Avoiding +the "Hit ENTER to continue" prompts</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=16">http://vim.sf.net/tip_view.php?tip_id=16</A><BR> + +To avoid the "Hit ENTER to continue" prompt, use the 'shortmess' option. +Add the following line to your .vimrc file: + + set shortmess=a + +Also, you can increase the height of the command line to 2 + + set cmdheight=2 + +The default command height is 1. + +To get more help on these options, use + +:help hit-enter :help shortmess :help cmdheight + +</pre></tip> </html> <Tip category="KVim"> <html><center>Erasing +previosuly entered characters in insert mode</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=17">http://vim.sf.net/tip_view.php?tip_id=17</A><BR> + +In insert mode, to erase previously entered characters, set the following +option: + + set backspace=2 + +By default, this option is empty. If this option is empty, in insert mode, +you can not erase characters entered before this insert mode started. +This is the standard Vi behavior. + +To get more help on this, use + +:help 'backspace' + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Cleanup your HTML</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=18">http://vim.sf.net/tip_view.php?tip_id=18</A><BR> + +From Johannes Zellner on the vim list: + +You can use vim's makeprg and equalprg to clean up HTML. First download +html tidy from <A HREF="http://www.w3.org/People/Raggett/tidy/. Then use +the following commands.">http://www.w3.org/People/Raggett/tidy/. Then use +the following commands.</A><BR> + +vim6? exe 'setlocal equalprg=tidy -quiet -f '.&errorfile setlocal makeprg=tidy +-quiet -e % + +vim5? exe 'set equalprg=tidy -quiet -f '.&errorfile set makeprg=tidy -quiet +-e % + +At this point you can use make to clean up the full file or you can use = +to clean up sections. + +:help = :help equalprg :help makeprg + +</pre></tip> </html> <Tip category="KVim"> +<html><center>line numbers...</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=19">http://vim.sf.net/tip_view.php?tip_id=19</A><BR> + +I have started doing all my code reviews on a laptop because of the number +command. + +:set number will put line numbers along the left side of a window + +:help number + +</pre></tip> </html> <Tip category="KVim"> <html><center>Are *.swp +and *~ files littering your working directory?</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=20">http://vim.sf.net/tip_view.php?tip_id=20</A><BR> + +Have you ever been frustrated at swap files and backups cluttering up your +working directory? + +Untidy: + ons.txt ons.txt~ README README~ tester.py tester.py~ + +Here are a couple of options that can help: + + set backupdir=./.backup,.,/tmp set directory=.,./.backup,/tmp + +This way, if you want your backups to be neatly grouped, just create +a directory called '.backup' in your working directory. Vim will stash +backups there. The 'directory' option controls where swap files go. If your +working directory is not writable, Vim will put the swap file in one of the +specified places. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>easy pasting to windows apps</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=21">http://vim.sf.net/tip_view.php?tip_id=21</A><BR> + +In Vim, the unnamed register is the " register, and the Windows Clipboard is +the * register. This means that if you yank something, you have to yank it to +the * register if you want to paste it into a Windows app. If this is too much +trouble, set the 'clipboard' option to 'unnamed'. Then you always yank to *. + +So pasting to windows apps doesn't require prefixing "* : + + set clipboard=unnamed + +</pre></tip> </html> <Tip category="KVim"> <html><center>handle +common typos for :commands</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=22">http://vim.sf.net/tip_view.php?tip_id=22</A><BR> + +I frequently hold the shift key for too long when typing, for instance :wq, +and end up with :Wq. Vim then whines "Not an editor command: Wq" + +In my .vimrc, I have taught vim my common typos: command! Q quit command! W +write command! Wq wq " this one won't work, because :X is already a built-in +command command! X xit + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Vim xterm title</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=23">http://vim.sf.net/tip_view.php?tip_id=23</A><BR> + +Check out your .vimrc. If 'set notitle' is an entry, comment it out with +a quotation mark ("). Now your xterm should inherit the title from Vim. +e.g. 'Vim - ~/.vimrc'. This can be quite nice when programming and editing +lots of files at the same time. by [jonasbn@wanadoo.dk] + +</pre></tip> </html> <Tip category="KVim"> <html><center>changing +the default syntax highlighting</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=24">http://vim.sf.net/tip_view.php?tip_id=24</A><BR> + + Here are some pointers to the vim documentation. Notice that the + mechanism is different in vim 6.0 and vim 5.x. + +1. I want *.foo files to be highlighted like HTML files. + +:help new-filetype <A +HREF="http://www.vim.org/html/autocmd.html#new-filetype">http://www.vim.org/html/autocmd.html#new-filetype</A><BR> + +2. I want to define a syntax file for *.bar files. Read the above and also + +:help mysyntaxfile <A +HREF="http://www.vim.org/html/syntax.html#mysyntaxfile">http://www.vim.org/html/syntax.html#mysyntaxfile</A><BR> + +3. I want to make a few changes to the existing syntax highlighting. +Depending on the x in 5.x, either read the above and page down a few screens, +or you may be able to skip right to + +:help mysyntaxfile-add <A +HREF="http://www.vim.org/html/syntax.html#mysyntaxfile-add">http://www.vim.org/html/syntax.html#mysyntaxfile-add</A><BR> + +4. I want to change some of the colors from their defaults. Again, read + +:help mysyntaxfile <A +HREF="http://www.vim.org/html/syntax.html#mysyntaxfile">http://www.vim.org/html/syntax.html#mysyntaxfile</A><BR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>color +highlighting on telnet (esp w/ SecureCRT)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=25">http://vim.sf.net/tip_view.php?tip_id=25</A><BR> + +The following settings in .vimrc will enable color highlighting when using +SecureCRT and may work on other telnet packages. The terminal type should +be selected as ANSI and color enabled. + +if !has("gui_running") set t_Co=8 set t_Sf=^[[3%p1%dm set t_Sb=^[[4%p1%dm endif + +The ^[ is entered as "<ctrl-v><esc>" + +</pre></tip> </html> <Tip category="KVim"> <html><center>Getting +rid of ^M - mixing dos and unix</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=26">http://vim.sf.net/tip_view.php?tip_id=26</A><BR> + +If you work in a mixed environment you will often open files that have ^M's +in them. An example would be this: + +------------------------------------------------------------------ +import java.util.Hashtable; ^M import java.util.Properties; ^Mimport +java.io.IOException; import org.xml.sax.AttributeList; ^M import +org.xml.sax.HandlerBase; ^Mimport org.xml.sax.SAXException; + +/**^M + * XMLHandler: This class parses the elements contained^M * within a XML + message and builds a Hashtable^M + +[snip] ------------------------------------------------------------------ + +Notice that some programs are not consistent in the way they insert the line +breaks so you end up with some lines that have both a carrage return and a +^M and some lines that have a ^M and no carrage return (and so blend into +one). There are two steps to clean this up. + +1. replace all extraneous ^M: + +:%s/^M$//g + +BE SURE YOU MAKE the ^M USING "CTRL-V CTRL-M" NOT BY TYPING "CARROT M"! This +expression will replace all the ^M's that have carriage returns after them +with nothing. (The dollar ties the search to the end of a line) + +2. replace all ^M's that need to have carriage returns: + +:%s/^M//g + +Once again: BE SURE YOU MAKE the ^M USING "CTRL-V CTRL-M" NOT BY TYPING +"CARROT M"! This expression will replace all the ^M's that didn't have +carriage returns after them with a carriage return. + +Voila! Clean file. Map this to something if you do it frequently. + +:help ffs - for more info on file formats + +thanks to jonathan merz, douglas potts, and benji fisher + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Convert hex to dec</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=27">http://vim.sf.net/tip_view.php?tip_id=27</A><BR> + +when you check the output of objdump, you'll confused by the $0xFFFFFFc +operand, this function translate the hexcamal to decimal. function! Hex2Dec() + let lstr = getline(".") let hexstr = matchstr(lstr, '0x[a-f0-9]+') + while hexstr != "" + let hexstr = hexstr + 0 exe 's#0x[a-f0-9]+#'.hexstr."#" let lstr = + substitute(lstr, '0x[a-f0-9]+', hexstr, "") let hexstr = matchstr(lstr, + '0x[a-f0-9]+') + endwhile +endfunction usage: 5,8call Hex2Dec() + +</pre></tip> </html> <Tip category="KVim"> <html><center>add a line-number +to every line without cat or awk alike utilities.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=28">http://vim.sf.net/tip_view.php?tip_id=28</A><BR> + +With Unix-like environment, you can use cat or awk to generate a line number +easily, because vim has a friendly interface with shell, so everything work +in vim as well as it does in shell. :%!call -n or :%!awk '{print NR,$0}' + +But, if you use vim in MS-DOS, of win9x, win2000, you loss these tookit. +here is a very simple way to archive this only by vim: fu! LineIt() + exe ":s/^/".line(".")."/" +endf + +Well, a sequence composed with alphabet is as easy as above: + exe "s/^/".nr2char(line("."))."/" + +</pre></tip> </html> <Tip category="KVim"> <html><center>reverse +all the line with only 7 keystroke in vim</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=29">http://vim.sf.net/tip_view.php?tip_id=29</A><BR> + +:g/^/m0 well, 1. : bring you to command-line mode(also known as ex-mode) +from normal-mode(also known as command mode). 2. g means you'll take an +action through the whole file, generally perform a search, `v' also perform +a search but it match the line not match the canonical expression. 3. / +begins the regular express 4. ^ is a special character respect the start +of a line. 5. the second / ends the regular express and indicate that the +remains is action to do. 6. m means move, `t` and `co' for copy, `d' for +delete 7. 0 is the destination line. + +you can use :g/regexp/t$ to filter all lines and pick the match line together +and copy them to the end of the buffer or :g/regexp/y A to put them into a +register(not eax, ebx...) + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Increasing or decreasing numbers</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=30">http://vim.sf.net/tip_view.php?tip_id=30</A><BR> + +To increase a number under or nearest to the right of the cursor, go to +Normal mode and type: + Ctrl-A + +To decrease, type: + Ctrl-X + +Using this in a macro simplifies generating number sequences a lot. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Find and Replace</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=31">http://vim.sf.net/tip_view.php?tip_id=31</A><BR> + +To find and replace one or more occurences of a given text pattern with a +new text string, use the s[ubstitute] command. + +There are a variety of options, but these are what you most probably want: + +:%s/foo/bar/g find each occurance of 'foo' and replace it with +'bar' without asking for confirmation + +:%s/foo/bar/gc find each occurance of 'foo' and replace it with +'bar' asking for confirmation first + +:%s/<foo>/bar/gc find (match exact word only) and replace each +occurance of 'foo' with 'bar' + +:%s/foo/bar/gci find (case insensitive) and replace each occurance of +'foo' with 'bar' + +:%s/foo/bar/gcI find (case sensitive) and replace each occurance of +'foo' with 'bar' + +NB: Without the 'g' flag, replacement occurs only for the first occurrence +in each line. + +For a full description and some more interesting examples of the substitute +command refer to + +:help substitute + +See also: + +:help cmdline-ranges :help pattern :help gdefault + +</pre></tip> </html> <Tip category="KVim"> <html><center>Write +your own vim function(scripts)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=32">http://vim.sf.net/tip_view.php?tip_id=32</A><BR> + +compare to C and shell(bash), herein is some vim specifics about vim-script: +1. A function name must be capitalized. + hex2dec is invalid Hex2dec is valid while in c and shell(bash), both + lowercase and uppercase is allowed. +2. how to reference the parameters + fu! Hex2dec(var1, var2) + let str=a:var1 let str2=a:var2 + you must prefix the parameter name with "a:", and a:var1 itself is read-only + in c, you reference the parameter directly and the parameter is writable. +3. how to implement variable parameter + fu! Hex2dec(fixpara, ...) + a:0 is the real number of the variable parameter when you invoke the + function, with :Hex2dec("asdf", 4,5,6), a:0=3, and a:1=4 a:2=5 a:3=6 + you can combine "a:" and the number to get the value while i<a:0 + exe "let num=a:".i let i=i+1 + endwhile in c, the function get the real number by checking the additional + parameter such as printf family, or by checking the special value such + as NULL +4. where is the vim-library + yes, vim has its own function-library, just like *.a in c :help functions +5. can I use += or ++ operator? + Nop, += and ++ (and -=, -- and so on)operator gone away in vim. +6. How can I assign a value to a variables and fetch its value? + let var_Name=value let var1=var2 like it does in c, except you must use + let keyword +7. Can I use any ex-mode command in a function? + As I know, yes, just use it directly, as if every line you type appears + in the familar : +8. Can I call a function recurse? + Yes, but use it carefully to avoid infinte call. +9. Can I call another function in a function? + Course, like C does. +10. Must I compile the function? + No, you needn't and you can't, just :so script_name, after this you can + call the function freely. +11. Is it has integer and char or float data type? + No, like perl, vim script justify the variable type depend upon the context + :let a=1 :let a=a."asdf" :echo a you'll get `1asdf' :let a=1 :let a=a+2 + :echo a you'll get 3 But it differs from perl. +12. Must I append a `;' in every statement? + No, never do that. ; is required in C, and optional in shell for each + statement in a alone line. But is forbidden in vim. if you want combine + servals statement in one single line, use `|'. Take your mind that every + statement appears in function should be valid in ex-mode(except for some + special statement). + +</pre></tip> </html> <Tip category="KVim"> <html><center>toggle +off the line-number when enter on-line help</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=33">http://vim.sf.net/tip_view.php?tip_id=33</A><BR> + +I like the line-number for myself editing. But I hate it in on-line help +page because it force the screen wrapped. :au filetype help :se nonu + +</pre></tip> </html> <Tip category="KVim"> <html><center>control +the position of the new window</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=34">http://vim.sf.net/tip_view.php?tip_id=34</A><BR> + +:se splitbelow make the new window appears below the current window. +:se splitright make the new window appears in right.(only 6.0 version can +do a vsplit) + +</pre></tip> </html> <Tip category="KVim"> <html><center>translate +// style comment to /* */and vice vesa</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=35">http://vim.sf.net/tip_view.php?tip_id=35</A><BR> + +the `|' concatenate servals ex-command in one line. It's the key to translate +// style comments to /* */ style :g#^s{-}//#s##/*# | s#$#*/# + +the `|' keep the current line matchs ^s{-}// to perform s#$#*/ + +/* ... */ ---> //style :g#/*(.{-})*/#//1# + +/* .... + .... ..... +*/ =====> //...... //...... //...... style: ? Anyone implement it? + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Using Gnu-info help in vim</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=36">http://vim.sf.net/tip_view.php?tip_id=36</A><BR> + +K in normal bring you the man page about the keyword under current cursor. +:nnoremap <F1> :exe ":!info ".expand("<cword>") Now press F1 +while the cursor is hold by a keyword such as printf will bring you to +Gnu-info help page :h <F1> :h nnoremap + +</pre></tip> </html> <Tip category="KVim"> <html><center>The +basic operation about vim-boolean optionals</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=37">http://vim.sf.net/tip_view.php?tip_id=37</A><BR> + +:set number switch the number on :set nonumber switch it off :set invnumber +or :set number! switch it inverse against the current setting :set number& +get the default value vim assums. + +replace number with any legal vim-boolean optionals, they all works well. +for vim-non-boolean optionals :set optional& also works properly. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Cursor +one line at a time when :set wrap</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=38">http://vim.sf.net/tip_view.php?tip_id=38</A><BR> + +If your tierd of the cursor jumping past 5 lines when :set wrap then add +these mappings to you vimrc file. + +nnoremap j gj nnoremap k gk vnoremap j gj vnoremap k gk nnoremap <Down> +gj nnoremap <Up> gk vnoremap <Down> gj vnoremap <Up> +gk inoremap <Down> <C-o>gj inoremap <Up> <C-o>gk + +What they do is remap the cursor keys to use there `g' equvilant. See :help gj + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Undo and Redo</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=39">http://vim.sf.net/tip_view.php?tip_id=39</A><BR> + +To undo recent changes, use the u[ndo] command: + +u undo last change (can be repeated to undo preceding commands) +U return the line to its original state (undo all changes in +current line) CTRL-R Redo changes which were undone (undo the undo's). + +For a full description of the undo/redo commands refer to + +:help undo + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Insert a file</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=40">http://vim.sf.net/tip_view.php?tip_id=40</A><BR> + +To insert the contents of a file (or the output of a system command) into +the current buffer, use the r[ead] command: + +Examples: + +:r foo.txt inserts the file foo.txt below the cursor + +:0r foo.txt inserts the file foo.txt above the first line + +:r !ls inserts a listing of your directory below the cursor + +:$r !pwd inserts the current working directory below the last line + +For more information about the r[ead] command refer to: + +:help read + +See also: + +:help cmdline-ranges :help !cmd + +</pre></tip> </html> <Tip category="KVim"> <html><center>Command-history +facilities for Oracle/sqlplus user</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=41">http://vim.sf.net/tip_view.php?tip_id=41</A><BR> + + First of all, thanks Benji fisher, Stefan Roemer... +and others in vim@vim.org which spend much time to answer questions, +sometimes foolish question asked by someone like me. Without their I can't +get the final solution for my sqlplus work descripted follows. + As Oracle user known, sqlplus has a very bad +command-line edition environment. It has no command-history, don't support +most of getline facilities. which MySQL and shell does it well. Even Microsoft +recogonize this point. In Windows2000, doskey is installed by default. + Below is my vim-solution to sqlplus, which +record the command-history when you use edit(sqlplus builtin command) to +open the editor specified by EDITOR environment variable. It saves the SQL +statement into a standalone file such as .sqlplus.history + Every time you open the file +afiedt.buf(sqlplus's default command-buffer file), you get two splited windows, +the buffer above is afiedt.buf, the buffer below is .sqlplus.history, you +can see every SQL statement in the windows. If you want to use SQL statement +in line 5 to replace + the current command-buffer, just press 5K, then + :xa to back to you sqlplus. and use / to repeat the command + saved in command-buffer file called afiedt.buf by default. + It can't process multi-line SQL statement convinencely. + Todo this, just use you favorite vim trick to do that: + fu! VimSQL() + nnoremap <C-K> :<C-U> + exe "let linenum=".v:count<CR>:1,$-1d<CR><C-W>j:exe + lin enum."y"<CR><C-W>kP + let linenum=line("$") 1,$-1w! >> ~/.sqlplus.history e + ~/.sqlplus.history execute ":$-".(linenum-1).",$m0" %!uniq if + line("$")>100 + 101,$d + endif b# set splitbelow sp ~/.sqlplus.history au! BufEnter afiedt.buf +endf au BufEnter afiedt.buf call VimSQL() + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Using marks</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=42">http://vim.sf.net/tip_view.php?tip_id=42</A><BR> + +To mark one or more positions in a file, use the m[ark] command. + +Examples: + +ma - set current cursor location as mark a + +'a - jump to beginning of line of mark a + +`a - jump to postition of mark a + +d'a - delete from current line to line of mark a + +d`a - delete from current cursor position to mark a + +c'a - change text from current line to line of mark a + +y`a - yank text to unnamed buffer from cursor to mark a + +:marks - list all the current marks + +NB: Lowercase marks (a-z) are valid within one file. Uppercase marks (A-Z), +also called file marks, are valid between files. + +For a detailed description of the m[ark] command refer to + +:help mark + +See also: + +:help various-motions + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Using abbreviations</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=43">http://vim.sf.net/tip_view.php?tip_id=43</A><BR> + +To define abbreviations, use the ab[breviate] command. + +Examples: + +:ab rtfm read the fine manual - Whenever you type 'rtfm' followed by a +<space> (or <esc> or <cr>) vim + will expand this to 'read the fine manual'. + +:ab - list all defined abbreviations + +:una[bbreviate] rtfm - remove 'rtfm' from the list of abbreviations + +:abc[lear] - remove all abbreviations + +NB: To avoid expansion in insert mode, type CTRL-V after the last character +of the abbreviation. + +For a detailed description of the ab[breviate] command and some more examples +refer to + +:help abbreviations + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Repeat last changes</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=44">http://vim.sf.net/tip_view.php?tip_id=44</A><BR> + +Simple text changes in normal mode (e.g. "dw" or "J") can be repeated with +the "." command. The last command-line change (those invoked with ":", +e.g. ":s/foo/bar") can be repeated with the "@:" command. + +For more informations about repeating single changes refer to: + +:help single-repeat + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Using command-line history</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=45">http://vim.sf.net/tip_view.php?tip_id=45</A><BR> + +You can recall previous command lines from a history table by hitting the +<Up> and <Down> cursor keys in command-line mode. For example, +this can be used to find the previous substitute command: Type ":s" and +then <Up>. + +There are separate history tables for the ':' commands and for previous '/' +or '?' search strings. + +To display the history of last entered commands or search strings, use the +:his[tory] command: + +:his - Display command-line history. + +:his s - Display search string history. + + +For a detailed description of the command-line history refer to: + +:help cmdline-history + +See also: + +:help Cmdline-mode + +</pre></tip> </html> <Tip category="KVim"> <html><center>Win32 +binaries with perl, python, and tcl</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=46">http://vim.sf.net/tip_view.php?tip_id=46</A><BR> + +> Does anyone know if windows binaries of vim 5.7 are available with perl +and > python support turned on? + +<A +HREF="ftp://vim.sourceforge.net/pub/vim/upload_binaries/">ftp://vim.sourceforge.net/pub/vim/upload_binaries/</A><BR> + +<A +HREF="http://vim.sourceforge.net/bin_download/">http://vim.sourceforge.net/bin_download/</A><BR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>Swapping +characters, words and lines</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=47">http://vim.sf.net/tip_view.php?tip_id=47</A><BR> + +To swap two characters or lines, use the following commands: + +xp - delete the character under the cursor and put it afterwards. + (In other words, it swaps the characters.) + +ddp - delete the current line and put it afterwards. + (In other words, it swaps the lines.) + +Unfortunately there is no universal solution to swap two words. You may +try the following ones, but don't expect too much of them: + +dawwP - delete the word under the cursor, move forward one word + and put it back after the cursor. (In other words, it swaps + the current and following word.) + +dawbP - delete the word under the cursor, move backward on word + and put it back after the cursor. (In other words, it swaps + the current and preceeding word.) + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Moving around</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=48">http://vim.sf.net/tip_view.php?tip_id=48</A><BR> + +You can save a lot of time when navigating through the text by using +appropriate movements commands. In most cases the cursor keys, <PageUp> +or <PageDown> are NOT the best choice. + +Here is a selection of some basic movement commands that hopefully helps +you to acquire a taste for more: + +e - move to the end of a word w - move forward to the beginning of a +word 3w - move forward three words b - move backward to the beginning of +a word 3b - move backward three words + +$ - move to the end of the line <End> - same as $ 0 - +move to the beginning of the line <Home> - same as 0 + +) - jump forward one sentence ( - jump backward one sentence + +} - jump forward one paragraph { - jump backward one paragraph + +H - jump to the top of the display M - jump to the middle of the display +L - jump to the bottom of the display + +'m - jump to the beginning of the line of mark m `m - jump to the location +of mark m + +G - jump to end of file 1G - jump to beginning of file 50G - jump to line 50 + +'' - return to the line where the cursor was before the latest jump `` - +return to the cursor position before the latest jump (undo the jump). + +% - jump to corresponding item, e.g. from an open brace to its + matching closing brace + +For some more interesting movement commands (especially those for programmers) +refer to: + +:help motion.txt + +:help search-commands + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Switching case of characters</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=49">http://vim.sf.net/tip_view.php?tip_id=49</A><BR> + +To switch the case of one or more characters use the "~", "gU" or "gu" +commands. + +Examples: + +~ - switch case of character under cursor + (in visual-mode: switch case of highlighted text) + +3~ - switch case of next three characters + +g~~ - switch case of current line + +U - in visual-mode: make highlighted text uppercase + +gUU - make current line uppercase + +u - in visual-mode: make highlighted text lowercase + +guu - make current line lowercase + +gUaw - make current word uppercase + +guaw - make current word lowercase + +For some more examples refer to + +:help ~ + +See also: + +:help simple-change + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Recovering files</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=50">http://vim.sf.net/tip_view.php?tip_id=50</A><BR> + +If your computer has crashed while editing a file, you should be able to +recover the file by typing + + vi -r <filename> + +where <filename> is the name of the file you were editing at the time +of the crash. If you were editing without a file name, give an empty string +as argument: + + vim -r "" + +To get a list of recoverable files start vim without arguments: + + vim -r + +For more information about file recovery refer to: + +:help recovery + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Entering german umlauts</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=51">http://vim.sf.net/tip_view.php?tip_id=51</A><BR> + +To enter german umlauts (or any other of those weired characters) not +available on your keyboard use 'digraphs': + +In insert-mode type for example: + + CTRL-K "a + + CTRL-K ^e + +which gives an '' and 'e' with a hat. + +You can also set the digraph option: + + :set digraph (or :set dg) + +With digraph option set you can enter + + " <BS> a + + ^ <BS> e + +which gives the same result. + +To get a list of currently defined digraphs type + + :dig[graphs] + +For more information about defining and using digraphs refer to: + +:help digraph.txt + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Scrolling synchronously</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=52">http://vim.sf.net/tip_view.php?tip_id=52</A><BR> + +If you want to bind two or more windows such that when one window is scrolled, +the other windows are scrolled simultaneously, set the 'scrollbind' option +for these windows: + +:set scrollbind + +When a window that has 'scrollbind' set is scrolled, all other 'scrollbind' +windows are scrolled the same amount, if possible. + +For more information about the 'scrollbind' option refer to + +:help scoll-binding + +</pre></tip> </html> <Tip category="KVim"> <html><center>Better +colors for syntax highlighting</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=53">http://vim.sf.net/tip_view.php?tip_id=53</A><BR> + +For syntax highlighting there are two sets of default color maps: One for a +light and another one for a dark background. If you have a black background, +use the following command to get a better color map for syntax highlighting: + +:set background=dark + +You have to switch off and on again syntax highlighting to activate the new +color map: + +:syntax off :syntax on + +For a detailled description of syntax highlighting refer to + +:help syntax.txt + +See also the Vim syntax support file: $VIMRUNTIME/syntax/synload.vim + +</pre></tip> </html> <Tip category="KVim"> <html><center>View +a Java Class File Decompiled thru Vim</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=54">http://vim.sf.net/tip_view.php?tip_id=54</A><BR> + +Hi All, Wish u could view a Java Class File using Vim, Well ur query +ends here. First of all u will need a Java Decompiler to decompile the +Class File. I would suggest the JAD decompiler by Pavel Kouznetsov <A +HREF="http://www.geocities.com/SiliconValley/Bridge/8617/jad.html">http://www.geocities.com/SiliconValley/Bridge/8617/jad.html</A><BR> + +Its a command line decompiler and absolutely free. U can use any command +line decompiler of ur choice. + +Next create a vimscript file called jad.vim as ######################### +FILE START ################ augr class au! au bufreadpost,filereadpost +*.class %!d:jad.exe -noctor -ff -i -p % au bufreadpost,filereadpost +*.class set readonly au bufreadpost,filereadpost *.class set ft=java au +bufreadpost,filereadpost *.class normal gg=G au bufreadpost,filereadpost +*.class set nomodified augr END ######################## FILE END +##################### + +Note:- Keep the Jad.exe in a directory with out white spaces. The -p options +directs JAD to send the output to standard output instead of a .jad file. Other +options are described on the JAD site. + +Next add the following line in the .vimrc file. so jad.vim + +Next time u do vim abc.class. Viola u have the source code for abc.class. + +NOTE:- I have written the script so as to open the class file read only, +So that u dont accidently modify it. U can also exted this script to unjar +a jar file and then view each file in the JAR file. thanks bhaskar Any +suggestions are welcome + +</pre></tip> </html> <Tip category="KVim"> +<html><center>previous buffer</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=55">http://vim.sf.net/tip_view.php?tip_id=55</A><BR> + +One of the keys to vim is buffer management. If I have to use another IDE +that makes me click on a tab every time I want to look at another file I'm +going to go postal. + +So of course you know about :ls which lists all the current open buffers. This +gets a little unweildly once you have a full project open so you can also use +:b <any snipit of text> <tab> to complete to an open buffer. This +is really nice because you can type any fragment of a file name and it will +complete to the matching file. (i.e. RequestManager.java can be completed +using "tma"<tab> or "req"<tab> or "r.java"<tab>). + +Now for awhile I was also using :bn and :bp which jumps you to the next +and previous buffer respectively. I found I was often frustrated because I +wanted :bp to be the previous buffer I was in, not the previous buffer in +the list. So (drum roll) the reason I wrote this tip was because of: + +:b# + +jump to the previous buffer you were in. Very very handy. The only thing +nicer are tag, but that's a tip for another time. + +:help buffers :help bn :help bp + +If anybody knows where to get help on # in this context please add notes. + +</pre></tip> </html> <Tip category="KVim"> <html><center>how +to avoid obliterating window layout</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=58">http://vim.sf.net/tip_view.php?tip_id=58</A><BR> + +If you take the time to lay out several windows with vim (especially vertically +in version 6), you may be bummed when you hit an errant key and find that +all but what one window disappears. + +What happens: while navigating between windows, you hit <C-W>j, +<C-W>k, etc. At some point you accidently hit <C-W> but then +don't follow with a window command. Now hitting 'o' to start insert mode +issues a command equivalent to :only, and closes all windows execept for +the one you are in (unless some windows have unsaved changes in them). + +How to avoid this: petition the vim-dev mailing list about how :only is +sufficient for the infrequenty use this might get (j/k). + +Really: use mapping to disable the <C-W>o functionality; put this in +your .vimrc: + +nnoremap <C-W>O :echo "sucker"<CR> nnoremap <C-W>o :echo +"sucker"<CR> nnoremap <C-W><C-O> :echo "sucker"<CR> + +references: + +:help :only :help CTRL-W_o + +That is all. Scott + +</pre></tip> </html> <Tip category="KVim"> <html><center>Applying +substitutes to a visual block</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=62">http://vim.sf.net/tip_view.php?tip_id=62</A><BR> + +If you'd like to apply a substitute, or even any ex command, to a visual-block +selected text region (ctrl-v and move), then you'll want Stefan Roemer's <A +HREF="http://www.erols.com/astronaut/vim/vimscript/vis.vim . Just source +it in,">http://www.erols.com/astronaut/vim/vimscript/vis.vim . Just source +it in,</A><BR> and then press ":B". On the command line you'll see + +:'<,'>BCtrl-V + +Just continue with the substitute or whatever... + +:'<,'>B s/abc/ABC/g + +and the substitute will be applied to just that block of text! + +Example: Ctrl-V Select..........|......Type ..................just +the central....|......:B s/abc/ABC/g ..................four +"abc"s..............| ..................----------------....|...------------- +..................abcabcabcabc............|......abcabcabcabc +..................abcabcabcabc............|......abcABCABCabc +..................abcabcabcabc............|......abcABCABCabc +..................abcabcabcabc............|......abcabcabcabc + (dots inserted to retain tabular format) + +</pre></tip> </html> <Tip category="KVim"> <html><center>Applying +substitutes to a visual block</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=63">http://vim.sf.net/tip_view.php?tip_id=63</A><BR> + +If you'd like to apply a substitute, or even any ex command, to a visual-block +selected text region (ctrl-v and move), then you'll want Stefan Roemer's <A +HREF="http://www.erols.com/astronaut/vim/vimscript/vis.vim . Just source +it in,">http://www.erols.com/astronaut/vim/vimscript/vis.vim . Just source +it in,</A><BR> and then press ":B". On the command line you'll see + +:'<,'>BCtrl-V + +Just continue with the substitute or whatever... + +:'<,'>B s/abc/ABC/g + +and the substitute will be applied to just that block of text! + +Example: Ctrl-V Select..........|......Type +..................just the central.......|......:B +s/abc/ABC/g ..................four "abc"s.................| +..................---------............|...------------- +..................abcabcabcabc............|......abcabcabcabc +..................abcabcabcabc............|......abcABCABCabc +..................abcabcabcabc............|......abcABCABCabc +..................abcabcabcabc............|......abcabcabcabc + (dots inserted to retain tabular format) + +</pre></tip> </html> <Tip category="KVim"> <html><center>Always set +your working directory to the file you're editing</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=64">http://vim.sf.net/tip_view.php?tip_id=64</A><BR> + +Sometimes I think it's helpful if your working directory is always the same +as the buffer you are editing. You need to put this in your .vimrc: + +function! CHANGE_CURR_DIR() + let _dir = expand("%:p:h") exec "cd " . _dir unlet _dir +endfunction + +autocmd BufEnter * call CHANGE_CURR_DIR() + +Doing this will make a "cd" command to your the current buffer each time +you switch to it. This is actually similar to vimtip#2 but more automatic. + +You should see for more details: :help autocmd :help expand :help function + +Note: This tip was contributed by somebody on the list a while ago (sorry +for no reference) and it has been extremely helpful to me. Thanks! + +</pre></tip> </html> <Tip category="KVim"> <html><center>Insert +line number into the actuall text of the file.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=65">http://vim.sf.net/tip_view.php?tip_id=65</A><BR> + +Although :set number will add nice line number for you At time you may wish +to actually place the line numbers into the file. For example on GNU Unix +you can acomplish a simular task using cat -n file > new_file + +In VIM you can use the global command to do this + +:g/^/exec "s/^/".strpart(line(".")." ", 0, 4) + +What this does is run the exec comand on every line that matches /^/ (All) +The exec command taks a string and executes it as if it were typed in. + +line(".")." " -> returns the number of the current line plus four spaces. +strpart("123 ", 0, 4) -> returns only the first four characters ("123 "). +"s/^/123 " -> substituts the begining of the line with "123 ". + +</pre></tip> </html> <Tip category="KVim"> <html><center>Transfer +text between two Vim 'sessions',</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=66">http://vim.sf.net/tip_view.php?tip_id=66</A><BR> + +This one is a one of my favorites from Dr. Chip, and I haven't seen it come +across vim tips yet... + +Can use either visual, or marking to denote the text. + +" transfer/read and write one block of text between vim sessions " Usage: " +`from' session: " ma " move to end-of-block " xw " " `to' session: +" move to where I want block inserted " xr " if has("unix") + nmap xr :r $HOME/.vimxfer<CR> nmap xw + :'a,.w! $HOME/.vimxfer<CR> vmap xr c<esc>:r + $HOME/.vimxfer<CR> vmap xw :w! $HOME/.vimxfer<CR> +else + nmap xr :r c:/.vimxfer<CR> nmap xw :'a,.w! c:/.vimxfer<CR> + vmap xr c<esc>:r c:/.vimxfer<cr> vmap xw + :w! c:/.vimxfer<CR> +endif + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Ascii Value</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=67">http://vim.sf.net/tip_view.php?tip_id=67</A><BR> + +Sometimes we, the programmers, need the value of a character, don't we? +You can learn the ascii value of a character by pressing g and a keys.(ga)! +It displays the value in dec, hex and octal... + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Delete key</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=68">http://vim.sf.net/tip_view.php?tip_id=68</A><BR> + +Don't worry if your delete key does not work properly. Just press +<CTRL>-Backspace. It works under both mode(insert or normal). + +</pre></tip> </html> <Tip category="KVim"> +<html><center>dot makes life easier</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=69">http://vim.sf.net/tip_view.php?tip_id=69</A><BR> + +You can copy and paste the last changes you made in the last insert mode +without using y and p by pressing . (just dot). Vim memorizes the keys you +pressed and echos them if you hit the dot key. You must be in command mode +as usual. It can be helpful... + +</pre></tip> </html> <Tip category="KVim"> +<html><center>running a command on all buffers</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=70">http://vim.sf.net/tip_view.php?tip_id=70</A><BR> + +From Peter Bismuti on the vim list: + +How to global search and replace in all buffers with one command? You need +the AllBuffers command: + +:call AllBuffers("%s/string1/string2/g") + +"put this in a file and source it function AllBuffers(cmnd) + let cmnd = a:cmnd let i = 1 while (i <= bufnr("$")) + if bufexists(i) + execute "buffer" i execute cmnd + endif let i = i+1 + endwhile +endfun + +":call AllBuffers("%s/foo/bar/ge|update") + +Thanks Peter! + +</pre></tip> </html> <Tip category="KVim"> <html><center>Transfer +text between two gvim sessions using clipboard</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=71">http://vim.sf.net/tip_view.php?tip_id=71</A><BR> + +If you use gvim, you can transfer text from one instance of gvim into another +one using clipboard. It is convenient to use * (star) register, like this: + +In one instance yank two lines into clipboard: + "*2yy +Paste it in another instance in normal mode: + "*p +or in insert mode: + <Ctrl-R>* + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Remove unwanted empty lines</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=72">http://vim.sf.net/tip_view.php?tip_id=72</A><BR> + +Sometimes to improve the readability of the document I insert empty lines, +which will be later removed. To get rid off them try: :%g/^$/d This will +remove a l l empty line in the document. Some other tipps you can find +under www.linuxclass.de/vim.phtml + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Using vim as calculator</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=73">http://vim.sf.net/tip_view.php?tip_id=73</A><BR> + +Basic calculations can done within vim easily by typing (insert-mode): STRG +(=CTRL) + R followed by = then for example 2+2 and hit RETURN the result 4 +will be printed in the document. + +Some other tipps you can find under www.linuxclass.de/vim.phtml + +</pre></tip> </html> <Tip category="KVim"> <html><center>Using +Vim as an outline processor</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=74">http://vim.sf.net/tip_view.php?tip_id=74</A><BR> + +With the addition of folding, Vim6 can function as a high performance outline +processor. Simply :set ai and in insert mode use backspace to promote and +tab to demote headlines. + +In command mode, << promotes (n<< to promote multiple lines), +and >> demotes. Also, highlight several headlines and < or > +to promote or demote. + +:set foldmethod=indent, and then your z commands can expand or collapse +headline trees, filewide or by the tree. + +The VimOutliner GPL distro contains the scripts and configs to easily +configure Vim6 as an outliner, including scripts to create tag files enabling +interoutline hyperlinking. + +The VimOutliner project is at <A +HREF="http://www.troubleshooters.com/projects/vimoutliner/index.htm.">http://www.troubleshooters.com/projects/vimoutliner/index.htm.</A><BR> + +Steve (Litt) slitt@troubleshooters.com + +</pre></tip> </html> <Tip category="KVim"> <html><center>Remap +CAPSLOCK key in Windows 2000 Professional and NT4.0</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=75">http://vim.sf.net/tip_view.php?tip_id=75</A><BR> + +If you're Windows 2000 Professional user and got tired to move your hands off +basic row when hitting <ESC> key here the solution (not for Windows 9x.): +remap CapsLock key as <ESC> key. It's located in useful position. Put +this lines into <EscLock.reg> file and start it in explorer.Reboot.Enjoy. + +REGEDIT4 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] +"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00 + +To restore you capslock back just delete this entry from Registry and reboot. +And below is remapping <capslock> as <Left Control>: + +REGEDIT4 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] +"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00 + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Folding for Quickfix</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=76">http://vim.sf.net/tip_view.php?tip_id=76</A><BR> + +The Quickfix mode aims to "speed up the edit-compile-edit cycle" according to +':help quickfix'. After executing ':make' or ':grep' it is possible to skim +through the list of errors/matches and the appropriate source code locations +with, for instance, the ':cnext' command. Another way to get a quick overview +is to use VIMs folding mode, to fold away all the error-free/match-free +regions. The script at the end of this message can be used for this +purpose. It is at the moment not elaborate enough to put it up as a 'script'; +but it might give someone inspiration to do so. Big restrictions / bugs are +as follows: 1. Vim Perl interface is required, i.e. the output of ':version' +must contain '+perl' (People with Vim scripting knowledge might fix this) +2. Works only for one file, i.e. the current buffer. 3. It's a quick hack. +Sample usage: (a) edit a file, (b) do ':grep regexp %' to get a quickfix +error list and (c) ':source foldqf.vim' will fold as described Increasing +the value of $CONTEXT gives you more context around the error regions. + +Here comes it, it should be 7 lines: ---foldqf.vim cwindow perl $CONTEXT = 0; +perl @A = map { m/\|(\d+)\|/; $1 +0 } $curbuf->Get(1..$curbuf->Count()); +close normal zD perl sub fold { VIM::DoCommand( $_[0] . ',' . ($_[1]) . "fold" +) if( $_[0] < $_[1] ); } perl $last = 0; for (@A) { fold( $last+1+$CONTEXT, +$_-1-$CONTEXT ); $last = $_; }; VIM::DoCommand(($A[-1]+1+$CONTEXT ) +. ',$fold' ); + +</pre></tip> </html> <Tip category="KVim"> <html><center>Displaying +search results using folds</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=77">http://vim.sf.net/tip_view.php?tip_id=77</A><BR> + +A guy I work with told me about a function that an old IBM text editor had +that he said was useful, and that is to create folds in the file after a +search such that every line that is visible contains the search pattern(except +possibly the first). All lines that do not contain the search pattern are +folded up to the last occurence of the pattern or the top of the file. + +One use for such a function is to be able to make a quick and dirty api of +a source file. For example, if working in Java, you could run the function +using the pattern "public|protected|private" and ithe results would be that +only the method headers would be visible (well, close enough). + +function! Foldsearch(search) + normal zE "erase all folds to begin with normal G$ + "move to the end of the file let folded = 0 "flag to set when + a fold is found let flags = "w" "allow wrapping in the search let + line1 = 0 "set marker for beginning of fold while search(a:search, + flags) > 0 + let line2 = line(".") "echo "pattern found at line # + " line2 if (line2 -1 > line1) + "echo line1 . ":" . (line2-1) "echo "A fold goes here." + execute ":" . line1 . "," . (line2-1) . "fold" + let folded = 1 "at + least one fold has been found + endif let line1 = line2 "update marker let flags = "W" + "turn off wrapping + endwhile + " Now create the last fold which goes to the end of the file. + normal $G let line2 = line(".") + "echo "end of file found at line # " line2 + if (line2 > line1 && folded == 1) + "echo line1 . ":" . line2 "echo "A fold goes here." + execute ":". line1 . "," . line2 . "fold" + endif +endfunction + +" Command is executed as ':Fs pattern'" command! -nargs=+ -complete=command +Fs call Foldsearch(<q-args>) " View the methods and variables in a +java source file." command! Japi Fs public\|protected\|private + +</pre></tip> </html> <Tip category="KVim"> +<html><center>rotating mail signatures</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=78">http://vim.sf.net/tip_view.php?tip_id=78</A><BR> + +For people using mutt and vim for mail, the following script will allow +you to insert a new signature (and again and again if you don\'t like the +current one) at the bottom of your mail. This is usefull eg when you don\'t +want to send a potentially offensive quote to someone you don\'t know very +well (or a mailing list), but are too lazy to delete the quote, open your +quotes file, and cut and paste another one in. (I put it here in \'tips\' +and not in \'scripts\' because it is imo too short to be a \'real\' script) + +" rotate_sig.vim " Maintainer: Roel Vanhout <roel@2e-systems.com> +" Version: 0.1 " Last Change: Tuesday, June 12, 2001 " Mapping I use: +" nmap ,r :call RotateSig()<CR> " Usage: " -Make sure you delimit +your sig with '-- ', or adjust the script " -Adjust the last execute to a +command that prints a sig to stdout " Known problems: " - You'll get an +error message when you're below the last " '^-- $' in your mail (nothing +bad though - just an not- " found marker) + +function! RotateSig() + normal mQG execute '?^-- $' execute ':nohl' normal o<ESC> normal + dG normal <CR> execute 'r !~/bin/autosig ~/.quotes \%' normal `Q +endfunction + +</pre></tip> </html> <Tip category="KVim"> <html><center>How to use +:grep to get a clickable list of function names</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=79">http://vim.sf.net/tip_view.php?tip_id=79</A><BR> + +The following function will make a :cwindow window with a line per function +in the current C source file. NOTE: It writes the file as a side effect. + +Invoke with ':call ShowFunc()' You may want to do :nmap <somekey> +:call ShowFunc()<CR> + +function! ShowFunc() + + let gf_s = &grepformat let gp_s = &grepprg + + let &grepformat = '%*\k%*\sfunction%*\s%l%*\s%f %*\s%m' let &grepprg = + 'ctags -x --c-types=f --sort=no -o -' + + write silent! grep % cwindow + + let &grepformat = gf_s let &grepprg = gp_s + +endfunc + +</pre></tip> </html> <Tip category="KVim"> <html><center>Restore +cursor to file position in previous editing session</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=80">http://vim.sf.net/tip_view.php?tip_id=80</A><BR> + +Here's something for your <.vimrc> which will allow you to restore +your cursor position in a file over several editing sessions. This technique +uses the viminfo option: + +Ex. set viminfo='10,\"100,:20,%,n~/.viminfo + au BufReadPost * if line("'\"") > 0|if line("'\"") <= + line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif + +If you're on Unix, the viminfo is probably fine as is (but check up on Vim's +help for viminfo to see if you like the settings above). For Windows you'll +need to change the "n" suboption to something like + +Ex. set viminfo='10,\"100,:20,%,nc:\\some\\place\\under\\Windoz\\_viminfo + +This tip is a somewhat improved version of the example given for :he line() +in the Vim on-line documentation. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Substitution of characters and lines in VIM is +made far easier with the s and S commands</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=81">http://vim.sf.net/tip_view.php?tip_id=81</A><BR> + +Substitute Characters ----------------------------------- I was just editing +a file that contained the same leading string on many lines. + +example: + +foo_bar_baz1=a foo_bar_baz1=abc674 foo_bar_baz1=qrs foo_bar_baz1=m1 +foo_bar_baz1=bz90 foo_bar_baz1=bc ... + +Needing to only substitute a portion of the string, I referred to a VIM +reference card and discovered a command answering my need exactly. The s +command is used to subsitute a certain number of characters. In my example +file above, if I only needed to subsititute the characters foo_bar, I set +the cursor on the first character where I'd like the subsitution to begin +and type 7s. VIM drops the characters foo_bar and goes to insert mode, +waiting for the substitution text. + +Substitute Lines ----------------------- After years of using vi and VIM and +always deleting multiple lines in order to replace them, I just discovered +the S command. If you need to subsitute three lines of text, simply type +3S. VIM drops the three lines and goes into insert mode, waiting for the +subsitution text. + +</pre></tip> </html> <Tip category="KVim"> <html><center>letting +variable values be overwritten in a script</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=82">http://vim.sf.net/tip_view.php?tip_id=82</A><BR> + +this is a simple function i wrote to get the value of a variable from three +different places (in that order): the current buffer, the global setting +or from the script itself. + +this allows me to set a default value for a configuration variable inside my +script and the user to change it on a global level by setting the same variable +with a g: prepended. then, they can further set it on a per-buffer level by +the the b: mechanism. one of the examples for this might be my comments script +(not uploaded). i have a variable in there that determines whether comment +characters (// for java, for example) are placed the beginning of the line or +just before the first-non-blanks in the text. i set up a default in my script: + +let s:comments_hug_start_of_line=0 " comments should hug the text + +that's fine as a default, but if i want to overwrite it for vim scripts, +i just put the following in my ftplugin/vim.vim: + +let b:comments_hug_start_of_line=1 " vim comments should hug the first +column, always + +" tries to return the buffer-specific value of a variable; if not +" found, tries to return the global value -- if that's not found " +either, returns the value set in the script itself function! GetVar(varName) + if (exists ("b:" . a:varName)) + exe "let retVal=b:" . a:varName + elseif (exists ("g:" . a:varName)) + exe "let retVal=g:" . a:varName + elseif (exists ("s:" . a:varName)) + exe "let retVal=s:" . a:varName + else + retVal=-1 + endif return retVal +endfunction + +personally, i never let it get to the -1 state by always having an s: set +with SOME default value. + +</pre></tip> </html> <Tip category="KVim"> <html><center>how +to indent (useful for source code)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=83">http://vim.sf.net/tip_view.php?tip_id=83</A><BR> + +Here is the most useful vim command that I know of and I'm surprised that +it's not yet in the tips list. + +I use the indent features of vim all the time. Basically, it lets you indent +your source code. + +SETUP: To make indentation work nicely I have the following in my .vimrc file: +set et set sw=4 set smarttab + +these make vim behave nicely when indenting, giving 4 spaces (not tabs) +for each "tabstop". + +HOW TO USE: in command mode, == will indent the current line selecting a range +of lines (with shift-v) then == will indent your selection typing a number +then == will indent that many lines, starting from your cursor (you get the +idea, there are many other things you can do to select a range of lines) + +Tell me that isn't great? + +</pre></tip> </html> <Tip category="KVim"> <html><center>Changing +the behaviour of . to include visual mode</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=84">http://vim.sf.net/tip_view.php?tip_id=84</A><BR> + +one of the things i do a lot in vim is to make a change to the beginning or +end of the line (such as adding the text '// remove' at the end of java +debug code). a quick way of doing this is to use a to append the text to +the end of the first line and then move down one, hit . (repeat last edit), +move down, hit . etc. etc. the following mapping allows one to simply +highlight the region in question and hit . -- it will automatically +execute the . once on each line: + + " allow the . to execute once for each line of a visual selection vnoremap + . :normal .<CR> + +another thing i do a lot is to record a quick macro in the "a" register +and then play it back a number of times. while @@ can be used to repeat the +last register used, my recorded macros sometimes use other registers so @@ +doesn't necessarily give me the same results as @a. also, i have mapped ' +to ` because i like to go to the precise location of my marks -- always -- +and never to the beginning of the line. this leaves my ` key unused. so: + + " make ` execute the contents of the a register nnoremap ` @a + +then, in keeping with the visual . above, i did the same for the ` -- is +thexecutes @a once on each highlighed line. + + vnoremap ` :normal @a<CR> + +as an example, say i have the following lines of java code: + + public String m_asdf; public String m_lkhj; public int m_hjkhjkh; + +and, for some reason, i need to get the following: + + "asdf" "lkhj" "hjkhjkh" + +i record the following into a: + + ^cf_"<ESC>$r" + +the ^ is because my java code is indented and i don't want to go to +column 0 and the <esc> is an actual escape i hit to exit insert mode. + +then, i simply select (visually) the other lines (only two in case -- +admittedly not an overly useful example) and just hit `. + +</pre></tip> </html> <Tip category="KVim"> <html><center>How to mimic +the vim 6.0 plugin feature with older versions</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=85">http://vim.sf.net/tip_view.php?tip_id=85</A><BR> + +If you do not have vim 6.0, but would like to mimic the plugins directory +feature then copy and paste this into your vimrc: + +exec "source " . substitute(glob($VIM."/plugins/*.vim"), "\n", "\nsource ", +"g") + +It will automatically source every vim script file located in the vim/plugins +directory. Now, to add a new plugin, just drop the script in this directory +and vim will automatically find it. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Helps +undo 1 line when entered many</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=86">http://vim.sf.net/tip_view.php?tip_id=86</A><BR> + +When U entered text, U cannot undo only 1 line, for example, when U press +"u", all entered in last "insert" text removed. + +If U add this line to .vimrc: inoremap <Return> <Return>^O^[ +where "^O" or "^[" is 1 char "u" will undo (remove) only 1 line. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Get +vim 5.x window in vim 6.x</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=87">http://vim.sf.net/tip_view.php?tip_id=87</A><BR> + +The format of the window title in vim 5.x (well, at least for 5.7,.8, for +Win32) used to be VIM - <full filename with path>. It's not in the +win32 binary of 6.0an that I found. I want my old way back. + +Turns out, all that it takes to get it back is :set title titlestring=VIM\ +-\ %F "make sure that the window caption setting is turned on and set caption +to vim 5.x style + +Oh, however, one thing I did like about the 6.0 style is that it puts the +word "help" in the title when the current buffer is a help file; so, I just +tacked %h to my titlestring giving: + +:set title titlestring=VIM\ -\ %F\ %h "make sure that the window caption +setting is turned on and set caption to vim 5.x style + +see also: :he 'titlestring' :he 'statusline' "for the format for titlestring + +</pre></tip> </html> <Tip category="KVim"> <html><center>How +to maximize vim on entry (win32)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=88">http://vim.sf.net/tip_view.php?tip_id=88</A><BR> + +Maybe it's just because I have far too small of a monitor, because I can +get distracted while coding if I have other stuff on the screen, or because I +starting using vim on a console, but I definitely like my vim window maximized. +Anyway, sticking the following in your vimrc will always maximize your vim +window on startup. + +au GUIEnter * simalt ~x + +:he win16-maximized + +</pre></tip> </html> <Tip category="KVim"> <html><center>Get more +screen real estate by hidding toolbar and/or menus</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=89">http://vim.sf.net/tip_view.php?tip_id=89</A><BR> + +I use gvim over console vim because gvim is much more readable (under Windows). +However, that doesn't mean I want to dedicate screen space to things I'll +never use (i.e. the toolbar and the menus). + +Anyway, you can give the following a try if you'd like. + +set guioptions-=T "get rid of toolbar set guioptions-=m "get rid of menu + +Oh, yeah. If you decide that you don't really like being without your the +toolbar or menus, issue the following: + +set guioptions+=T "bring back toolbar set guioptions+=m "bring back menu + +see also: :he 'guioptions + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Encryption</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=90">http://vim.sf.net/tip_view.php?tip_id=90</A><BR> + +You can encrypt your texts by using vim. :X prompts for an encryption key. +After writing your key, if you save your document it will be encrypted +and no one else (but you and vim) can read your documents. If you reopen +the file, VIM will ask for the key. If you want to disable encryption, +just type :set key= if you forget your key you will lose your document. +So please DO NOT forget your key, + + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Dictionary completions</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=91">http://vim.sf.net/tip_view.php?tip_id=91</A><BR> + +This tip will will explain how to use the dictionary completion facilities +provided by vim. This can be useful if you use vim to type your email, +edit code, etc. + +Dictionary completion is one of many search facilites provided by Insert mode +completion. It allows the user to get a list of keywords, based off of the +current word at the cursor. This is useful if you are typing a long word +(e.g. acknowledgeable) and don't want to finish typing or don't remember +the spelling. + +To start, we must first tell vim where our dictionary is located. This is done +via the 'dictionary' option. Below is an example. Your location may vary. +See :help 'dictionary' for hints as to where you should look. + + :set dictionary-=/usr/share/dict/words + dictionary+=/usr/share/dict/words + +Now, to use this list we have to enter insert mode completion. This is done +by hitting CTRL-X while in insert mode. Next, you have to specify what you +want to complete. For dictionaries use CTRL-K. Once in this mode the keys +CTRL-N and CTRL-P will cycle through the matches. So, to complete the word +"acknowledgeable" I would do the following in insert mode: + + acknow<CTRL-X><CTRL-K><CTRL-N> + +It can be cumbersome to type CTRL-X CTRL-K for many different completions. +So, vim gives us a shortcut. While in insert mode CTRL-N and CTRL-P +will cycle through a predetermined set of completion sources. By default, +dictionary completion is not a part of this set. This set is defined by the +'complete' option. Therefore, we must add dictionary to this as shown below: + + :set complete-=k complete+=k + +Now, while in insert mode we can type the following to complete our example: + + acknow<CTRL-N><CTRL-N> + +This shortcut may not save a whole lot of typing. However, I find that it +requires less hand movement to only worry myself with two key combinations, +rather than 4. + +I find that the completion facilites provided by vim save me a *HUGE* amount +of typing. These savings can be realized in only a short amount of time if +you are editing some code with functions and variables that have long names +with underscores in them. + +For more help: + help ins-completion help compl-dictionary help 'complete' help + 'dictionary' help :set+= + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Reducing 'doc' directory size</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=92">http://vim.sf.net/tip_view.php?tip_id=92</A><BR> + +As everyone knows, the $VIMRUNTIME/doc is increasing rapidly in size. The +directory contained so many plain-text documents that I often compress +them to save my diskspace. With the support of VIM's GZIP plugin, +VIM will automatically uncompress the files when we need to read them. +Here is my procedure: 1. If you have the source, go to 'runtime/doc' +and edit 'doctags.c', change printf("%s\t%s\t/*", p1, argv[0]); to +printf("%s\t%s.gz\t/*", p1, argv[0]); + then make. This is to modify the tag, or you'll have to change the + 'tags' file by hand if you don't have doctags.c. +2. Edit the new generated 'tags' file to rename 'help.txt.gz' back to +'help.txt' because it's hard-written in VIM executable binary. + :% s/help\.txt\.gz/help\.txt/g +3. Copy the new 'tags' to $VIMRNUTIME/doc and run 'gzip *.txt; gunzip help.txt' + +On VIM 6.0an, we can reduce the original size (3302k) to 1326k. I don't +know if this helps, but if someone likes to compress documents... this can +be reffered :) + + +</pre></tip> </html> <Tip category="KVim"> <html><center>if you use +'highlight search' feature, map a key to :noh</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=93">http://vim.sf.net/tip_view.php?tip_id=93</A><BR> + +It is very convenient to use 'hlsearch' option. However it can be annoying +to have the highlight stick longer than you want it. In order to run it +off you have to type at least 4 keystrokes, ":noh". So, it's a good idea +to map this to a key. I like to map it to control-n. This is the line I +use in my .vimrc file to do it: + +nmap <silent> <C-N> :silent noh<CR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>Questions +& Answers about using tags with Vim</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=94">http://vim.sf.net/tip_view.php?tip_id=94</A><BR> + +Using tags file with Vim ------------------------ This document gives you +a idea about the various facilities available in Vim for using a tags file +to browse through program source files. You can read the Vim online help, +which explains in detail the tags support, using :help tagsearch.txt. You can +also use the help keywords mentioned in this document to read more about a +particular command or option. To read more about a particular command or +option use, :help <helpkeyword> in Vim. + +1. How do I create a tags file? + + You can create a tags file either using the ctags utility or using a + custom script or utility. + + Help keyword(s): tag + +2. Where can I download the tools to generate the tags file? + + There are several utilities available to generate the tags file. + Depending on the programming language, you can use any one of them. + + 1. Exuberant ctags generates tags for the following programming + language files: + + Assembler, AWK, ASP, BETA, Bourne/Korn/Zsh Shell, C, C++, COBOL, + Eiffel, Fortran, Java, Lisp, Make, Pascal, Perl, PHP, Python, REXX, + Ruby, S-Lang, Scheme, Tcl, and Vim. + + You can download exuberant ctags from <A + HREF="http://ctags.sourceforge.net/">http://ctags.sourceforge.net/</A><BR> + + 2. On Unix, you can use the /usr/bin/ctags utility. This utility + is present in most of the Unix installations. + + 3. You can use jtags for generating tags file for java programs. + You can download jtags from: <A + HREF="http://www.fleiner.com/jtags/">http://www.fleiner.com/jtags/</A><BR> + + 4. You can use ptags for generating tags file for perl programs. + You can download ptags from: <A + HREF="http://www.eleves.ens.fr:8080/home/nthiery/Tags/">http://www.eleves.ens.fr:8080/home/nthiery/Tags/</A><BR> + + 5. You can download scripts from the following links for + generating tags file for verilog files: + + <A + HREF="http://www.probo.com/vtags.htm">http://www.probo.com/vtags.htm</A><BR> + <A + HREF="http://www.cs.albany.edu/~mosh/Perl/veri-tags">http://www.cs.albany.edu/~mosh/Perl/veri-tags</A><BR> + <A + HREF="http://www.verilog.net/vrtags.txt">http://www.verilog.net/vrtags.txt</A><BR> + + 6. You can download Hdrtag from the following linke: + + <A + HREF="http://www.erols.com/astronaut/vim/index.html#Tags">http://www.erols.com/astronaut/vim/index.html#Tags</A><BR> + + This utility generates tags file for the following programming languages: + assembly, c/c++, header files, lex, yacc,LaTeX, vim, and Maple V. + + 7. You can also use the following scripts which are part of the Vim + runtime files: + + pltags.pl - Create tags file for perl code tcltags - Create tags + file for TCL code shtags.pl - Create tags file for shell script + + Help keyword(s): ctags + +3. How do I generate a tags file using ctags? + + You can generate a tags file for all the C files in the current directory + using the following command: + + $ ctags *.c + + You can generate tags file for all the files in the current directory + and all the sub-directories using (this applies only to exuberant ctags): + + $ ctags -R . + + You can generate tags file for all the files listed in a text file named + flist using (this applies only to exuberant ctags) + + $ ctags -L flist + +4. How do I configure Vim to locate a tags file? + + You can set the 'tags' option in Vim to specify a particular tags file. + + set tags=/my/dir/tags + + Help keyword(s): 'tags', tags-option + +5. How do I configure Vim to use multiple tags files? + + The 'tags' option can specify more than one tags file. The tag filenames + are separated using either comma or spaces. + + set tags=/my/dir1/tags, /my/dir2/tags + +6. How do I configure Vim to locate a tags file in a directory tree? + + Note that the following will work only in Vim 6.0 and above. You can set + the 'tags' option to make Vim search for the tags file in a directory tree. + For example, if the 'tags' option is set like this: + + set tags=tags;/ + + Vim will search for the file named 'tags', starting with the current + directory and then going to the parent directory and then recursively to + the directory one level above, till it either locates the 'tags' file or + reaches the root '/' directory. + + Help keyword(s): file-searching + +7. How do I jump to a tag? + + There are several ways to jump to a tag location. + 1. You can use the 'tag' ex command. For example, + + :tag <tagname> + + will jump to the tag named <tagname>. + 2. You can position the cursor over a tag name and then press + Ctrl-]. + 3. You can visually select a text and then press Ctrl-] to + jump to the tag matching the selected text. + 4. You can click on the tag name using the left mouse button, + while pressing the <Ctrl> key. + 5. You can press the g key and then click on the tag name + using the left mouse button. + 6. You can use the 'stag' ex command, to open the tag in a new + window. For example, + + :stag func1 + + will open the func1 definition in a new window. + 7. You can position the cursor over a tag name and then press + Ctrl-W ]. This will open the tag location in a new window. + + Help keyword(s): :tag, Ctrl-], v_CTRL_], <C-LeftMouse>, + g<LeftMouse>, :stag, Ctrl-W_] + +8. How do I come back from a tag jump? + + There are several ways to come back to the old location from a tag jump. + 1. You can use the 'pop' ex command. 2. You can press Ctrl-t. + 3. You can click the right mouse button, while pressing the + <Ctrl> key. + 4. You can press the g key and then click the right mouse + button. + + Help keyword(s): :pop, Ctrl-T, <C-RightMouse>, g<RightMouse> + +9. How do I jump again to a previously jumped tag location? + + You can use the 'tag' ex command to jump to a previously jumped tag + location, which is stored in the tag stack. + + Help keyword(s): tag + +10. How do I list the contents of the tag stack? + + Vim remembers the location from which you jumped to a tag in the tag stack. + You can list the current tag stack using the 'tags' ex command. + + Help keyword(s): :tags, tagstack + +11. How do I jump to a particular tag match, if there are multiple + matching tags? + + In some situations, there can be more than one match for a tag. + For example, a C function or definition may be present in more than one + file in a source tree. There are several ways to jump to a specific + tag from a list of matching tags. + + 1. You can use the 'tselect' ex command to list all the tag + matches. For example, + + :tselect func1 + + will list all the locations where func1 is defined. You can then + enter the number of a tag match to jump to that location. + 2. You can position the cursor over the tag name and press g] + to get a list of matching tags. + 3. You can visually select a text and press g] to get a list + of matching tags. + 4. You can use the 'stselect' ex command. This will open the + selected tag from the tag list in a new window. + 5. You can position the cursor over the tag name and press + Ctrl-W g] to do a :stselect. + + Help keyword(s): tag-matchlist, :tselect, g], v_g], :stselect, + Ctrl-W_g] + +12. I want to jump to a tag, if there is only one matching tag, + otherwise a list of matching tags should be displayed. How do I do this? + + There are several ways to make Vim to jump to a tag directly, if there + is only one tag match, otherwise present a list of tag matches. + + 1. You can use the 'tjump' ex command. For example, + + :tjump func1 + + will jump to the definition func1, if it is defined only once. + If func1 is defined multiple times, a list of matching tags will + be presented. + 2. You can position the cursor over the tag and press g + Ctrl-]. + 3. You can visually select a text and press g Ctrl-] to jump + or list the matching tags. + 4. You can use the 'stjump' ex command. This will open the + matching or selected tag from the tag list in a new window. + 5. You can press Ctrl-W g Ctrl-] to do a :stjump. + + Help keyword(s): :tjump, g_Ctrl-], v_g_CTRL-], :stjump, + Ctrl-W_g_Ctrl-] + +13. How do browse through a list of multiple tag matches? + + If there are multiple tag matches, you can browse through all of them + using several of the Vim ex commands. + + 1. To go to the first tag in the list, use the 'tfirst' or + 'trewind' ex command. + 2. To go to the last tag in the list, use the 'tlast' ex command. + 3. To go to the next matching tag in the list, use the 'tnext' ex + command. + 4. To go to the previous matching tag in the list, use the + 'tprevious' or 'tNext' ex command. + + Help keyword(s): :tfirst, :trewind, :tlast, :tnext, :tprevious, + :tNext + +14. How do I preview a tag? + + You can use the preview window to preview a tag, without leaving the + original window. There are several ways to preview a tag: + + 1. You can use the 'ptag' ex command to open a tag in the + preview window. + 2. You can position the cursor on a tag name and press Ctrl-W + } to open the tag in the preview window. + 3. You can use the 'ptselect' ex command to do the equivalent + of the 'tselect' ex command in the preview window. + 4. You can use the 'ptjump' ex command to do the equivalent of + the 'tjump' ex command in the preview window. + 5. You can position the cursor on the tag and press Ctrl-W g} + to do a :ptjump on the tag. + + Help keyword(s): :preview-window, :ptag, Ctrl-W_}, :ptselect, + :ptjump, Ctrl-W_g} + +15. How do I browse through the tag list in a preview window? + + If there are multiple tag matches, you can browse through all of them + in the preview window using several of the Vim ex commands. + + 1. To go to the first tag in the list, use the 'ptfirst' or + 'ptrewind' ex command. + 2. To go to the last tag in the list, use the 'ptlast' ex command. + 3. To go to the next matching tag in the list, use the 'ptnext' ex + command. + 4. To go to the previous matching tag in the list, use the + 'ptprevious' or 'ptNext' ex command. + + Help keyword(s): :ptfirst, :ptrewind, :ptlast, :ptnext, + :ptprevious, :ptNext + +16. How do I start Vim to start editing a file at a given tag match? + + While starting Vim, you can use the command line option '-t' to supply + a tag name. Vim will directly jump to the supplied tag location. + + Help keyword(s): -t + +17. How do I list all the tags matching a search pattern? + + There are several ways to go through a list of all tags matching a pattern. + + 1. You can list all the tags matching a particular regular + expression pattern by prepending the tag name with the '/' + search character. For example, + + :tag /<pattern> :stag /<pattern> :ptag + /<pattern> :tselect /<pattern> :tjump + /<pattern> :ptselect /<pattern> :ptjump + /<pattern> + + 2. If you have the 'wildmenu' option set, then you can press + the <Tab> key to display a list of all the matching tags + in the status bar. You can use the arrow keys to move between + the tags and then use the <Enter> key to select a tag. + + 3. If you don't have the 'wildmenu' option set, you can still + use the <Tab> key to browse through the list of matching + tags. + + Help keyword(s): tag-regexp, wildmenu + +18. What options are available to control how Vim handles the tags + file? + + You can use the following options to control the handling of tags file + by Vim: + + 1. 'tagrelative' - Controls how the file names in the tags file + are treated. When on, the filenames are relative to + the directory where the tags file is present. + + 2. 'taglength' - Controls the number of significant characters + used for recognizing a tag. + + 3. 'tagbsearch' - Controls the method used to search the tags file + for a tag. If this option is on, binary search is + used to search the tags file. Otherwise, linear search + is used. + + 4. 'tagstack' - Controls how the tag stack is used. + + Help keyword(s): 'tagrelative', 'taglength', 'tagbsearch', + 'tagstack' + +19. Is it possible to highlight all the tags in the current file? + + Yes. Read the Vim online help on "tag-highlight". + +20. Is it possible to create a menu with all the tags in the current + file? + + Yes. It is possible to create a menu with all the tags in the current + file using a Vim script. Download the TagsMenu.vim script from the + following link: + + <A + HREF="http://members.home.net/jayglanville/tagsmenu/TagsMenu.html">http://members.home.net/jayglanville/tagsmenu/TagsMenu.html</A><BR> + +21. Is there a workaround to make the Ctrl-] key not to be treated as + the telnet escape character? + + The default escape characters for telnet in Unix systems is Ctrl-]. + While using Vim in a telnet session, if you use Ctrl-] to jump to a tag, + you will get the telnet prompt. There are two ways to avoid this problem: + + 1. Map the telnet escape character to some other character using + the "-e <escape character>" telnet command line option + + 2. Disable the telnet escape character using the "-E" telnet + command line option. + + Help keyword(s): telnet-CTRL-] + +</pre></tip> </html> <Tip category="KVim"> <html><center>How do I pipe +the output from ex commands into the text buffer?</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=95">http://vim.sf.net/tip_view.php?tip_id=95</A><BR> + +This is a *request* for a tip. I need to be able to pipe the output of a +:blah ex command into the vim text buffer for editing. I wanted to do this +many times for different reasons and could never find a way! + +I would just love to be able to do :hi --> textBuffer and examine the output +at my own leasure scrolling up and down and using vim search commands on it. +Same thing for :set all, and other things. Considering that cut and paste +is horrible in windows, I can't for example do :set guioptions? then cut +and paste! So I have to retype it, or cut and paste from the help manual. +I really want to be able to pipe the output of ex commands into the text +buffer. Can someone help me? + +</pre></tip> </html> <Tip category="KVim"> <html><center>Cooperation +of Gvim and AutoCad [MTEXT]</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=96">http://vim.sf.net/tip_view.php?tip_id=96</A><BR> + +You can - like me :o) - use gvim, like replacement of internal AutoCad +MTEXT editor. You need switch variable MTEXTED to "gvim" (or maybe fullpath, +something like "c:\vim\vim60aq\gvim" ), and to your _vimrc you can put line: + +autocmd BufRead,BufNewFile *.tmp source c:\vim\aacad.vim + +And when you edit MTEXT in acad, menu AutoCad will be for your use in gvim +(only in INSERT and VISUAL mode) + +[NOTE: Only I can't start gvim like gvim -y (for any other person, not so +accustomed vith gvim) or start gvim from gvim.lnk or gvim.bat (I'am using +windows95) and automatic skip to INSERT mode -latest word star, on end of +script- is without functionality(?) Maybe someone advise me?? ] + +Well, script aacad.vim is listed here: + +"VIM menu for AutoCad's MTEXT editation "brz; +mailto:brz@centrum.cz; 8. 8. 2001 " Version Mk.I +"-------------------------------------------------------------------------- + +imenu &AutoCad.Insert.Space \~ vmenu &AutoCad.Insert.Space +<Esc>`<i\~<Esc>% imenu &AutoCad.Insert.Backslash \\ +vmenu &AutoCad.Insert.Backslash <Esc>`<i\\<Esc>% imenu +&AutoCad.Insert.Brackets \{\}<Esc>F\i vmenu &AutoCad.Insert.Brackets +<Esc>`>a\}<Esc>`<i\{<Esc>% imenu +&AutoCad.Insert.Paragraph \P vmenu &AutoCad.Insert.Paragraph +<Esc>`>a\P<Esc>% + +imenu &AutoCad.-SEP1- : + +imenu &AutoCad.Colour.Red \C1; vmenu &AutoCad.Colour.Red +<Esc>`>a\C7;<Esc>`<i\C1;<Esc>% imenu +&AutoCad.Colour.Yellow \C2; vmenu &AutoCad.Colour.Yellow +<Esc>`>a\C7;<Esc>`<i\C2;<Esc>% imenu +&AutoCad.Colour.Green \C3; vmenu &AutoCad.Colour.Green +<Esc>`>a\C7;<Esc>`<i\C3;<Esc>% +imenu &AutoCad.Colour.Cyan \C4; vmenu &AutoCad.Colour.Cyan +<Esc>`>a\C7;<Esc>`<i\C4;<Esc>% +imenu &AutoCad.Colour.Blue \C5; vmenu &AutoCad.Colour.Blue +<Esc>`>a\C7;<Esc>`<i\C5;<Esc>% imenu +&AutoCad.Colour.Violet \C6; vmenu &AutoCad.Colour.Violet +<Esc>`>a\C7;<Esc>`<i\C6;<Esc>% +imenu &AutoCad.Colour.Black \C7; vmenu &AutoCad.Colour.Black +<Esc>`>a\C7;<Esc>`<i\C7;<Esc>% imenu +&AutoCad.Colour.D_Grey \C8; vmenu &AutoCad.Colour.D_Grey +<Esc>`>a\C7;<Esc>`<i\C8;<Esc>% imenu +&AutoCad.Colour.L_Grey \C9; vmenu &AutoCad.Colour.L_Grey +<Esc>`>a\C7;<Esc>`<i\C9;<Esc>% + +imenu &AutoCad.Font.Arial \fArial; vmenu &AutoCad.Font.Arial +<Esc>`<i\fArial;<Esc>% imenu &AutoCad.Font.Symbol \Fsymbol; +vmenu &AutoCad.Font.Symbol <Esc>`<i\Fsymbol;<Esc>% +imenu &AutoCad.Font.RomanC \Fromanc; imenu &AutoCad.Font.RomanC +<Esc>`<i\Fromanc;<Esc>% imenu &AutoCad.Font.RomanS \Fromans; +vmenu &AutoCad.Font.RomanS <Esc>`<i\Fromans;<Esc>% +imenu &AutoCad.Font.RomanD \Fromand; vmenu &AutoCad.Font.RomanD +<Esc>`<i\Fromand;<Esc>% imenu &AutoCad.Font.RomanT \Fromant; +vmenu &AutoCad.Font.RomanT <Esc>`<i\Fromant;<Esc>% + +imenu &AutoCad.Size.0_5x \H0.5x; vmenu &AutoCad.Size.0_5x +<Esc>`<i\H0.5x;<Esc>% imenu &AutoCad.Size.1_5x \H1.5x; vmenu +&AutoCad.Size.1_5x <Esc>`<i\H1.5x;<Esc>% imenu &AutoCad.Size.2x +\H2x; vmenu &AutoCad.Size.2x <Esc>`<i\H2x;<Esc>% +imenu &AutoCad.Size.3x \H3x; vmenu &AutoCad.Size.3x +<Esc>`<i\H3x;<Esc>% + +imenu &AutoCad.Effects.Set_Out_1_5 \T1.5; vmenu &AutoCad.Effects.Set_Out_1_5 +<Esc>`>a\T1;<Esc>`<i\T1.5;<Esc>% imenu +&AutoCad.Effects.Set_Out_2 \T2; vmenu &AutoCad.Effects.Set_Out_2 +<Esc>`>a\T1;<Esc>`<i\T2;<Esc>% + +imenu &AutoCad.Effects.-SEP3- : imenu +&AutoCad.Effects.Tilt_15deg \Q15; vmenu &AutoCad.Effects.Tilt_15deg +<Esc>`>a\Q0;<Esc>`<i\Q10;<Esc>% imenu +&AutoCad.Effects.Tilt_20deg \Q20; vmenu &AutoCad.Effects.Tilt_20deg +<Esc>`>a\Q0;<Esc>`<i\Q20;<Esc>% imenu +&AutoCad.Effects.Tilt_30deg \Q30; vmenu &AutoCad.Effects.Tilt_30deg +<Esc>`>a\Q0;<Esc>`<i\Q30;<Esc>% + +imenu &AutoCad.Effects.-SEP4- : imenu &AutoCad.Effects.Change_Width_0_5x +\W0.5; vmenu &AutoCad.Effects.Change_Width_0_5x +<Esc>`>a\W1;<Esc>`<i\W0.5;<Esc>% imenu +&AutoCad.Effects.Change_Width_2x \W2; vmenu &AutoCad.Effects.Change_Width_2x +<Esc>`>a\W1;<Esc>`<i\W2;<Esc>% + +imenu &AutoCad.Effects.-SEP5- : imenu &AutoCad.Effects.Justify_Down \A0; +vmenu &AutoCad.Effects.Justify_Down <Esc>`<i\A0;<Esc>% +imenu &AutoCad.Effects.Justify_Middle \A1; vmenu +&AutoCad.Effects.Justify_Middle <Esc>`<i\A1;<Esc>% +imenu &AutoCad.Effects.Justify_Up \A2; vmenu &AutoCad.Effects.Justify_Up +<Esc>`<i\A2;<Esc>% imenu &AutoCad.Effects.Overlined_Characters +\O\o<Esc>F\i vmenu &AutoCad.Effects.Overlined_Characters +<Esc>`>a\O<Esc>`<i\o<Esc>% imenu +&AutoCad.Effects.Underlined_Characters \L\l<Esc>F\i +vmenu &AutoCad.Effects.Underlined_Characters +<Esc>`>a\l<Esc>`<i\L<Esc>% imenu +&AutoCad.Effects.Index_Top \S^; + +imenu &AutoCad.-SEP6- : imenu &AutoCad.Help <CR><CR>***Quit +Editor: press Alt-F4 and 'No' ***<CR><CR> + +star + +</pre></tip> </html> <Tip category="KVim"> <html><center>How +do I add a current time string inside Vim?</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=97">http://vim.sf.net/tip_view.php?tip_id=97</A><BR> + +This is a *request* for a tip. Sometimes (eg. editing HTML pages) I need +to add a timestamp string to my editing buffer. On UNIX systems, I can use + :r!date +to get a localized date time string; but on Windows ('date' on Windows will +query the user to input new date) or other platforms which does not have +'date' command, how do I get a timestamp easily? + +</pre></tip> </html> <Tip category="KVim"> <html><center>Getting +vim help from mailing lists and newsgroups.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=98">http://vim.sf.net/tip_view.php?tip_id=98</A><BR> + +There have been a few "requests for tips" entered into the tips database +lately. If you have specific questions that aren't answered by the existing +tips, there are a couple of resources that may be more appropriate: + +The mailing list vim@vim.org is for vim users. If you send an email +to vim-help@vim.org, you'll get a message back telling you how +to subscribe, as well as how to request old messages and contact +the list maintainer. This mailing list is also archived at <A +HREF="http://groups.yahoo.com/group/vim.">http://groups.yahoo.com/group/vim.</A><BR> + +The newsgroup comp.editors discusses many different editors, but most of +the traffic is about vim. When posting, it is appreciated if you include +"vim" in the subject line. The comp.editors newsgroup is archived at <A +HREF="http://groups.google.com/groups?hl=en&safe=off&group=comp.editors.">http://groups.google.com/groups?hl=en&safe=off&group=comp.editors.</A><BR> + +Using the tips database for asking questions is not likely to work well. +For example, if you ask a question titled "Searching for strings in a file" +and I read this site and see that tip, I'm not going to read it if I already +know how to search for strings in a file. In comp.editors and vim@vim.org, +people expect to find questions from others and are therefore more likely +to see your questions. + +After finding the answer to your question, please consider whether it would +make an appropriate tip, and if so, add it to the tips database. + +</pre></tip> </html> <Tip category="KVim"> <html><center>How to +tell what syntax highlighting group *that* is!</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=99">http://vim.sf.net/tip_view.php?tip_id=99</A><BR> + +Here's a (what should be a one-line) map to help you tell just what syntax +highlighting groups the item under the cursor actually is: + +map <F10> :echo "hi<" +. synIDattr(synID(line("."),col("."),1),"name") . '> trans<' +. synIDattr(synID(line("."),col("."),0),"name") . "> lo<" +. synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR> + +Once known you can override the current highlighting with whatever you want. +If you're debugging a syntax highlighting file (a rare occupation), sometimes +you'll wish to know the entire chain of syntax highlighting. For that, +check out + +<A +HREF="http://www.erols.com/astronaut/vim/vimscript/hilinks.vim">http://www.erols.com/astronaut/vim/vimscript/hilinks.vim</A><BR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>Jump to +tag (e.g. help topic) with German keyboard (PC)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=100">http://vim.sf.net/tip_view.php?tip_id=100</A><BR> + +You're a newbie in vim and need some ":help"? Well, help.txt reads: + +"Jump to a subject: Position the cursor on a tag between |bars| and hit +CTRL-]." + +Unfortunately there is no "]" key on German keyboards. On Win32 try CTRL-+ +(Strg-+), on Linux console I use CTRL-AltGr-9 (Strg-AltGr-9). + +Kind regards + +</pre></tip> </html> <Tip category="KVim"> <html><center>Change automatically +to the directory the file in the current buffer is in</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=101">http://vim.sf.net/tip_view.php?tip_id=101</A><BR> + +To change automatically to the directory the file in the current buffer is +in add a line (below) to the file .vimrc . The file .vimrc should have +the following if-statement to control the autocmd feature: + + if has("autocmd") + + < ... lot of autocmd stuff ... > + + " Change to the directory the file in your current buffer is in autocmd + BufEnter * :cd %:p:h + + endif " has("autocmd") + +Add the line above the endif and restart vim/gvim. + +</pre></tip> </html> <Tip category="KVim"> <html><center>smart +mapping for tab completion</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=102">http://vim.sf.net/tip_view.php?tip_id=102</A><BR> + +I'm used to complete words with <tab>, however when editing source +I can't just map that to vim keyword completion because I sometime need to +insert real tabs, since it mostly happen when at the beginning of the line or +after a ; and before a one line comma (java, c++ or perl anyone...) I've come +to find the following really usefull This is how you can map the <tab> +key in insert mode while still being able to use it when at the start of +a line or when the preceding char is not a keyword character. in a script +file in a plugin directory or in your .vimrc file: first define a function +which returns a <tab> or a <C-N> depending on the context: + +function InsertTabWrapper() + let col = col('.') - 1 if !col || getline('.')[col - 1] !~ '\k' + return "\<tab>" + else + return "\<c-p>" + endif +endfunction + +then define the appropriate mapping: inoremap <tab> +<c-r>=InsertTabWrapper()<cr> + +the trick here is the use of the <c-r>= in insert mode to be able to +call your function without leaving insert mode. :help i_CTRL-R Benoit + +</pre></tip> </html> <Tip category="KVim"> <html><center>Move +to next/previous line with same indentation</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=103">http://vim.sf.net/tip_view.php?tip_id=103</A><BR> + +When working with Python and other languages which don't use braces, it's +useful to be able to jump to and from lines which have the same indentation +as the line you are currently on. + +nn <M-,> k:call search ("^". matchstr (getline (line (".")+ 1), +'\(\s*\)') ."\\S", 'b')<CR>^ nn <M-.> :call search ("^". matchstr +(getline (line (".")), '\(\s*\)') ."\\S")<CR>^ + +will map Alt-< and Alt-> in Normal mode to upward and downward searching +for lines with the same indent as the current line. + +</pre></tip> </html> <Tip category="KVim"> <html><center>using +vim to complement Perl's DBI::Shell</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=104">http://vim.sf.net/tip_view.php?tip_id=104</A><BR> + +DBI::Shell is a Perl module that is used as a shell interface to Perl's +popular DBI (database interface) package. Forget your favorite SQL navigation +gui and give this method a shot. This has only been tested in UNIX. + +1. run dbish (runs DBI::Shell; installed with DBI::Shell) and connect to any +database 2. in dbish, set /format box 3. enter your query 4. to execute query, +type "/ | vim -" + +This runs the query and pipes the output to the standard input of vim. Here +are some follow-up tips: -use gvim instead of vim so a new window will pop +up -set nowrap once in vim -make a syntax highlighting file for me! + +-Adam Monsen + +</pre></tip> </html> <Tip category="KVim"> +<html><center>combining move and scroll</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=105">http://vim.sf.net/tip_view.php?tip_id=105</A><BR> + +I sometimes found myself moving down a few lines with j, then scrolling +down about the same number of lines with <C-E> to put the cursor in +roughly the same place as it started. I decided I wanted to map <C-J> +(and <C-K>, respectively) to the move-and-scroll operation. First, I did + + :map <C-J> <C-E>j + +This was pretty good, but behaved funny at the beginning and end of files. +Then, I realized that <C-D> already combined move and scroll, so I +figured that giving <C-D> a count of 1 would do it: + + :map <C-J> 1<C-D> + +Unfortunately, this permanently attaches a count to <C-D> (ugh!), +so I have to undo that: + + :map <C-J> 1<C-D>:set scroll=0<CR> + +This has the drawback of not necessarily resetting scroll to its original +value, but since I never change scroll, it's good enough for me. It would be +nice if there were a version of <C-D> that did not have the side-affect +of changing scroll. + +Happy vimming, Andrew + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Supersimple one-line solution</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=106">http://vim.sf.net/tip_view.php?tip_id=106</A><BR> + +Hallo, next solution for _most_simple_ signature rotater: You can +only put one line to your .vimrc || _vimrc: map <Leader>ms :e +c:\sign.txt<CR>ggV/--<CR>k"*xG$a<C-R><C-O>*<Esc>:w<CR>:bd<CR>G$a<C-M><Esc>"*P + +Must exist file (from eg above) c:\sign.txt, with content: -- first signature +-- second signature -- third signature -- + +When You finished mail, only call shortcut \ms and 'first signature' will +be insert in your mail. In c:\sign.txt will be first signature pushed +to the end of this file. When You want use other signature, only press +'u' and \ms again (Or You can change \ms to e.g. <F12>, indeed. ) +You can change this and append one part like 'basic' from command and +append 'changing' part from .signature file, as you like... Ok, one +unpleasant thing is here: your signature must not contain '--' (signature +separator)... Anyhow, I find it useful brz* <brz@centrum.cz> <A +HREF="http://brz.d2.cz/">http://brz.d2.cz/</A><BR> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>convert enum to string table</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=107">http://vim.sf.net/tip_view.php?tip_id=107</A><BR> + +When testing your own C/C++ programs you sometimes wish to have a trace output, +which shows you, which enum value is used. You can do this by creating +a string table for that enum type, which contains the enum identifyer as +a string. e.g. printf ("%s", MyEnumStringTable [ MyEnumVal] ); + +You can create the complete string table by - marking the lines containing +the complete typedef enum - select menu C/C++.transform enum2Stringtab + +You can create string table entries by - marking the lines within the typedef +enum - select menu C/C++.transform enum2String + +This makes it easy to keep the enum (on changes) consistent to the string +table. + +Add the following lines to your _GVIMRC file: 31amenu C/C++.transform\ +enum2Stringtab :s#[ ]*\\(\\w\\+\\)#/* \\1 */ +"\\1"#<CR>o};<ESC>uOstatic const char* const Names[] = +{<ESC><CR>/sdfsdf<CR> 31vmenu C/C++.transform\ enum2Stringtab +:s#[ ]*\\(\\w\\+\\)#/* \\1 */ "\\1"#<CR>o};<ESC>uOstatic +const char* const Names[] = {<ESC><CR>/sdfsdf<CR> + +31amenu C/C++.transform\ enum2String :s#[ ]*\\(\\w\\+\\)#/* +\\1 */ "\\1"#<CR>o}<ESC>/sdfsdf<CR> 31vmenu +C/C++.transform\ enum2String :s#[ ]*\\(\\w\\+\\)#/* \\1 */ +"\\1"#<CR>o}<ESC>/sdfsdf<CR> + +hint: '/sdfsdf' is added for deactivating search highlighting, ok, you'll +sure find a better way to do this. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Toggle +a fold with a single keystroke</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=108">http://vim.sf.net/tip_view.php?tip_id=108</A><BR> + +When viewing/editing a folded file, it is often needed to inspect/close +some fold. To speed up these operation use the following (put in your +$HOME/.vimrc): + +" Toggle fold state between closed and opened. " " If there is no fold at +current line, just moves forward. " If it is present, reverse it's state. +fun! ToggleFold() + if foldlevel('.') == 0 + normal! l + else + if foldclosed('.') < 0 + . foldclose + else + . foldopen + endif + endif " Clear status line echo +endfun + +" Map this function to Space key. noremap <space> :call +ToggleFold()<CR> + +See :help folding for more information about folding. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>jump between files</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=109">http://vim.sf.net/tip_view.php?tip_id=109</A><BR> + +Often I know I'm likely to edit many files. I run 'vim *.pl' and get a whole +bunch of open files. + +To make jumping between files to a pleasure, I defined to mapss: + +map <f1> :previous<cr> map <f2> :next<cr> + +Press F1 to go back and F2 to go forward. + +-- Kirill + +</pre></tip> </html> <Tip category="KVim"> +<html><center>text->html table converter.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=110">http://vim.sf.net/tip_view.php?tip_id=110</A><BR> + +Below are two functions and a mapping which will convert lines of plain +text into HTML table code. For example, you have several lines like: +----------------------------------------------- 1 2 3 + +4 5 6 --------------------------------------------------- by visualizing +all the 7 lines and press <F5>, you can change the text into +<table><tr> + <td>1</td> <td>2</td> <td>3</td> +</tr><tr> + <td>4</td> <td>5</td> <td>6</td> +</tr></table> which will eventually render into a table. So the +rule is: Every line is a table item, every empty line means starting of a +new table row. + +"A text->html table code converter "By: Wenzhi Liang wzhliang@yahoo.com +"You can distribute/change this file freely as long as you keep the title +area. Thanks + +func Table() + let end=line("'>") let start=line("'<") let i=start + + wh i <= end + exe ":" . i let e=Empty() if e == 1 + exe "normal I</tr><tr>" + else + exe "normal I<td>A</td>>>" + endif let i=i+1 + endwh + + exe "normal o</tr></table><<" exe ":" . start exe + "normal O<table><tr><<" +endfunc + +vmap <F5> <ESC>:call Table()<CR> + +func Empty() + let line_nr= line (".") let a=getline ( line_nr ) let m=match(a, + "\\S") if m == -1 + return 1 + else + return 0 + endif +endfunc + +</pre></tip> </html> <Tip category="KVim"> <html><center>Printing with +syntax highlighting independent of your normal highlighting</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=111">http://vim.sf.net/tip_view.php?tip_id=111</A><BR> + +I have found it undesirable to use :hardcopy directly because it uses the +current syntax highlighting to determine how to print the text. For example, +I like to print comments in italics, but I don't like italic fonts on the +screen. This tip will show you how to set up a colorscheme for printing and +use it only when you print. + +I copied an existing colorscheme to ~/.vim/colors/print.vim, and changed +all the lines like this: + + highlight Normal ctermbg=DarkGrey ctermfg=White guifg=White guibg=grey20 +to this: + highlight clear Normal + +Then I set the syntax groups how I wanted them to be printed on the printer: + + highlight Comment term=italic cterm=italic gui=italic highlight + Constant term=bold cterm=bold gui=bold etc.... + +I then defined the following command in my .vimrc file: + +command! -nargs=* Hardcopy call DoMyPrint("<args>") + +And, finally, I defined this function in my .vimrc: + +function DoMyPrint(args) + let colorsave=g:colors_name color print exec "hardcopy ".a:args exec + 'color '.colorsave +endfunction + +After this is complete, you can do: + :Hardcopy > /tmp/out.ps +or just + :Hardcopy +(Note the capital H) + +</pre></tip> </html> <Tip category="KVim"> <html><center>Back +and forth between indented lines again</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=112">http://vim.sf.net/tip_view.php?tip_id=112</A><BR> + +Paul Wright posted a tip which explained how to jump back and forth between +lines with the same indentation level. I do this a lot, so I came up with +this slightly more comprehensive solution. + +The example mappings below work as follows: + +[l and ]l jump to the previous or the next line with the same indentation +level as the one you're currently on. + +[L and ]L jump to the previous or the next line with an indentation level +lower than the line you're currently on. + +These movements also work in visual mode and (only as of one of the 6.0 alpha +versions) in operator pending mode, meaning that you can do a d]l. The motion +is specified as being exclusive when in operator pending mode. + +When might you use this? If you're writing programs in Python, Haskell, +or editing XML files, they will be very useful. E.g. in XML you can jump to +the outer enclosing tag, or the next matching tag. I use it for practically +anything I edit, so it's not limited to this. + +" " NextIndent() " " Jump to the next or previous line that has the same level +or a lower " level of indentation than the current line. " " exclusive (bool): +true: Motion is exclusive " false: Motion is inclusive " +fwd (bool): true: Go to next line " false: Go to +previous line " lowerlevel (bool): true: Go to line with lower indentation +level " false: Go to line with the same indentation level +" skipblanks (bool): true: Skip blank lines " false: +Don't skip blank lines + +function! NextIndent(exclusive, fwd, lowerlevel, skipblanks) + let line = line('.') let column = col('.') let lastline = line('$') + let indent = indent(line) let stepvalue = a:fwd ? 1 : -1 + + while (line > 0 && line <= lastline) + let line = line + stepvalue if ( ! a:lowerlevel && + indent(line) == indent || + \ a:lowerlevel && indent(line) < indent) + if (! a:skipblanks || strlen(getline(line)) > 0) + if (a:exclusive) + let line = line - stepvalue + endif exe line exe "normal " column . "|" + return + endif + endif + endwhile +endfunc + +" Moving back and forth between lines of same or lower indentation. +nnoremap <silent> [l :call NextIndent(0, 0, 0, 1)<cr> +nnoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<cr> +nnoremap <silent> [L :call NextIndent(0, 0, 1, 1)<cr> +nnoremap <silent> ]L :call NextIndent(0, 1, 1, 1)<cr> vnoremap +<silent> [l <esc>:call NextIndent(0, 0, 0, 1)<cr>m'gv'' +vnoremap <silent> ]l <esc>:call NextIndent(0, 1, 0, +1)<cr>m'gv'' vnoremap <silent> [L <esc>:call NextIndent(0, 0, +1, 1)<cr>m'gv'' vnoremap <silent> ]L <esc>:call NextIndent(0, +1, 1, 1)<cr>m'gv'' onoremap <silent> [l :call NextIndent(0, 0, 0, +1)<cr> onoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<cr> +onoremap <silent> [L :call NextIndent(1, 0, 1, 1)<cr> onoremap +<silent> ]L :call NextIndent(1, 1, 1, 1)<cr> + +</pre></tip> </html> <Tip category="KVim"> <html><center>Translator +in vim (Windows solution)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=113">http://vim.sf.net/tip_view.php?tip_id=113</A><BR> + +Hallo, today I found script "translate.vim", but on Windows this will be +probably difficult to run it (maybe with Cygwin is it possible). I've simpler +solution of keymap for vim interlacing to dictionary: Must exist file with +vocabulary (e.g. "an-cs.txt"), which is called for word under cursor. In +'normal' is only displayed window with translations, in 'insert' is word +under cursor deleted and is insert selected form of word from translantion +window (select it by mouse and than press right button: It works fine on +W2k). Key _F12_ is looking for "word", shifted _S-F12_ is looking for +"pattern". For windows is needed agrep, which is localy placed on <A +HREF="http://www.tgries.de/agrep/index.html">http://www.tgries.de/agrep/index.html</A><BR> + +map <F12> b"*yw<Esc>:! c:/bin/agrep -wih +<C-R>* "c:/dict/an-cs.txt"<CR> imap <F12> +<Esc>b"*yw<Esc>:! c:/bin/agrep -wih <C-R>* +"c:/dict/an-cs.txt"<CR>dwi <C-R>* map <S-F12> +b"*yw<Esc>:! c:/bin/agrep -ih <C-R>* "c:/dict/an-cs.txt"<CR> +imap <S-F12> <Esc>b"*yw<Esc>:! c:/bin/agrep -ih <C-R>* +"c:/dict/an-cs.txt"<CR>dwi <C-R>* + +brz* <brz@centrum.cz> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Browsing by paragraph</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=114">http://vim.sf.net/tip_view.php?tip_id=114</A><BR> + +It can be done by reaching the blank lines in up and down directions just +by pressing + +{ ---- For going to the blank line above the paragraph } ---- For +going to the blank line below the paragraph + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Browsing by paragraph</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=115">http://vim.sf.net/tip_view.php?tip_id=115</A><BR> + +It can be done by reaching the blank lines in up and down directions just +by pressing + +{ ---- For going to the blank line above the paragraph } ---- For +going to the blank line below the paragraph + +</pre></tip> </html> <Tip category="KVim"> <html><center>Search all +occurances of the word under cursor in all the open files</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=116">http://vim.sf.net/tip_view.php?tip_id=116</A><BR> + +Sometimes it is useful to know all the occurances of the word under cursor in +all the open files. This can be done by pressing [I ( bracket and capital I ) +. it shows the results found in the command window. + +</pre></tip> </html> <Tip category="KVim"> <html><center>FAST +SEARCH ACROSS THE PROJECT</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=117">http://vim.sf.net/tip_view.php?tip_id=117</A><BR> + +Searching for a word across the project wastes most of the +developres time, which can be avoided by the use of GNU Id_utils +with VIM. The procedure needs to be followed is as follows: +download GNU idutils 3.2d (mkid,lid,fid,fnid,xtokid) from <A +HREF="http://www.mossbayeng.com/~ron/vim/builds.html">http://www.mossbayeng.com/~ron/vim/builds.html</A><BR> + +uncompress and store these files in the directory from where vim is running. + +goto the top level directory of the project, and run mkid, it will create ID +file in that directory (As it is time consuming process, so be patient). copy +this file ID to the directory from where vim is running. + +USAGE: + +Put these lines in your .vimrc: + + map _u :call ID_search()<Bar>execute "/\\<" . g:word + . "\\>"<CR> map _n :n<Bar>execute "/\\<" . g:word + . "\\>"<CR> + + function ID_search() + let g:word = expand("<cword>") let x = system("lid --key=none + ". g:word) let x = substitute(x, "\n", " ", "g") execute "next " . x + endfun + +To use it, place the cursor on a word, type "_u" and vim will load the file +that contains the word. Search for the next ocurance of the word in the +same file with "n". Go to the next file with "_n". + +The mapping of "_u" and "_n" can be done to some other key as per your +preference but I use ^K and ^L for this purpose. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Configuring +gVim as Internet Explorer 'View Source' editor</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=118">http://vim.sf.net/tip_view.php?tip_id=118</A><BR> + +Within the registry, you can specify the source editor to be used by Internet +Explorer when {View|Source} is selected. Unfortunately, you can't specify a +quoted filename argument here, i.e. "%1". The editor specified is supposed +to handle filenames which contain spaces. This will cause problems for +Vim because Vim treats each space as an argument separator. If an unquoted +filename contains spaces, Vim treats the filename as multiple arguments and +will open multiple files instead of one. To workaround this problem a quoted +filename has to be passed to Vim. This can be done by creating the following +Visual Basic Script file gVim.vbs: + +'--- gVim.vbs ----------------------------------------------------------------- +'function: Start gvim, combining multiple arguments to single file argument. +'changes: 20010905: Quoted 'oWShell.Run' filename argument, allowing spaces. +' 20010518: Created. 'author: Freddy Vulto <fvu@fvu.myweb.nl> + + ' Making variable declaration mandatory +option explicit + +dim oWShell, sArg, sFile + + ' Create script object +set oWShell = CreateObject("wscript.shell") + ' Loop through arguments +for each sArg in wscript.arguments + ' Add argument to filename + sFile = sFile & sArg & " " +next + ' Remove excess space +sFile = Trim(sFile) + ' Run Vim with file argument. Additional arguments: ' -R: View file + readonly ' -c "set syntax=html": Use HTML syntax-highlighting ' NOTE: + Use "-c ""set ft=html""" to make it work for Vim v6. +oWShell.Run _ + """D:\Programs\Vim\Vim58\gvim.exe """ & _ "-R """ & sFile & """ " & _ + "-c ""set syntax=html""" + + ' Destroy script object +set oWShell = NOTHING + +The source editor now can be specified by adding the following key to the +registry: + +HKEY_LOCAL_MACHINE |- Software + |- Microsoft + |- Internet Explorer + |- View Source Editor + |- Editor Name (Default) = D:\Programs\Vim\gvim.vbs + +Freddy Vulto <fvu@fvu.myweb.nl> <A +HREF="http://fvu.myweb.nl/Projects/Vim/Web/vim.htm">http://fvu.myweb.nl/Projects/Vim/Web/vim.htm</A><BR> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Explorer startup and shutdown</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=119">http://vim.sf.net/tip_view.php?tip_id=119</A><BR> + +I really like the new explorer window, but I wanted it to function a little +more seemlessly in the editor. The following code does two things. First, +the explorer is started when vim is started. I also noticed and fixed +that the explorers size is not equal to the window size, hence the strange +behavior when popping between two windows. The other major function of +the code is to close the explorer when it's the only window that's left. +I'd actually like to take this a step further and close the window if the +last _document_ window is closed. I'd prefer that multiple explorers or help +windows don't keep the application running - only having a file open keeps the +application running. But I didn't see an easy way to do this... anyone else? + +BTW, thank you Bram for the help figuring this out. + +Code (which currently lives in my _vimrc): + +" FILE BROWSER STARTUP func OpenFileWindow() + " :runtime plugin/*.vim " this would be useful if you were + calling this + " function from the .vimrc directly + let g:explDetailedList=1 " show size and date by default let + g:explVertical=1 " Split vertically let g:explStartRight=0 + " Put new explorer window to the left of the current window :Sexplore + set nonu set winwidth=15 " Make the width of the window match + the explorer setting "let g:explVertical=0 " Split vertically + doautocmd fileExplorer BufEnter " Forces the directory refresh to + occur :winc l " change to the document window +endfunc + +func CloseIfLast() + if exists("b:completePath") " this is how I determine that I'm + in an explorer window + let n = winnr() wincmd p if n == winnr() + quit " quit the window + endif wincmd p + endif +endfunc + +if has("autocmd") + if !exists("rudyautocommands") + let rudyautocommands = 1 autocmd VimEnter * call + OpenFileWindow() autocmd WinEnter * call CloseIfLast() + + endif +endif + +</pre></tip> </html> <Tip category="KVim"> <html><center>Compiling +Java with Sun JDK (javac) within VIM</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=120">http://vim.sf.net/tip_view.php?tip_id=120</A><BR> + +The $VIMRUNTIME/compiler has 'jikes.vim', but there's nothing for traditional +Sun JDK(javac), so I tried (Only tested on Win 2000): + +" Vim Compiler File javac.vim " Compiler: Sun/IBM JDK: Javac + +if exists("current_compiler") + finish +endif let current_compiler = "javac" + +" Javac defaults to printing output on stderr and no options can convert, +so we have to set 'shellpipe' setlocal shellpipe=2> " 2> works on Win +NT and UNIX setlocal makeprg=javac\ #<.java setlocal errorformat=%f:%l:%m +" Sorry I'm not familiar with 'errorformat', so I set it very simple. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Using +vim as a syntax-highlighting pager</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=121">http://vim.sf.net/tip_view.php?tip_id=121</A><BR> + +If you want to use Vim's syntax highlighting in a "more"-style pager, here's +one way to set it up: + +First, create a vimrc like the following -- I called mine ~/.vimrc.more + +---8<---cut here---8<--- " No compatibility -- necessary for mappings +to work. set nocompatible + +" Status line set laststatus=0 set cmdheight=1 set nomodifiable " +Only in version 6.0 set readonly + +" Syntax colouring -- lines taken from syntax.txt discussion on colour xterms. +" See ':help color-xterm'. Use appropriate lines for your own set-up. +if has("terminfo") + set t_Co=16 set t_Sf=[3%p1%dm set t_Sb=[4%p1%dm +else + set t_Co=16 set t_Sf=[3%dm set t_Sb=[4%dm +endif " My xterms have a navy-blue background, so I need this line too. +set background=dark " Turn syntax on syntax on + +" Key bindings. nmap b <C-B><C-G> nmap q :q<CR> " To +type the following line, type *two* C-V's followed by two spaces. This " +is how you map the spacebar. nmap ^V <C-F><C-G> ---8<---cut +here---8<--- + +Then, to use this .vimrc, add an alias. If you're using tcsh, the syntax +will be something like: + +alias vmore "vim -u ~/.vimrc.more" + +Then you can type "vmore [filename]" to view a file in this "pager". Spacebar +will move down, 'b' will move back up, and 'q' quits. You can add mappings +for other keys if you want to, also. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Skip +blank lines when folding text.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=122">http://vim.sf.net/tip_view.php?tip_id=122</A><BR> + +I love the text folding capabilities of vim. I didn't like that it would +display the first line of the range as the "title" for the fold. I like +to write my comments with the "/*" on a line by itself. So I wrote this +little function that will skip over anything that isn't a character, and +then display whatever it finds after that character. + +Just include this in your ~/.vimrc (or ~/.gvimrc): + +function GetFirstLineWithChars() + let line_num = 0 let charline = matchstr(getline(v:foldstart), + '[a-zA-Z][a-zA-Z ]*') while strlen(charline) == 0 + let line_num = line_num + 1 let charline = + matchstr(getline(v:foldstart + line_num), '[a-zA-Z][a-zA-Z ]*') + endw return charline +endfunction set +foldtext='+'.v:folddashes.substitute(GetFirstLineWithChars(),'\\\/\\\/\\\|\\*\\\|\\*\\\|{{{\\d\\=','','g') +set fillchars=fold: hi folded guibg=black guifg=yellow gui=bold + +And as an added bonus, for those new to text folding, add this to your .vimrc +file too: + +autocmd BufWinLeave *.* mkview autocmd BufWinEnter *.* silent loadview + +That way whatever folds you set won't get lost when you quit. I had that +happen after spending 15 minutes folding up a 3000+ line file. Happy vimming! + +</pre></tip> </html> <Tip category="KVim"> <html><center>use +functionality similar to the * search on multiple files</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=123">http://vim.sf.net/tip_view.php?tip_id=123</A><BR> + +The use of star as in vimtip#1 and vimtip#5 is great, here is how to use +this type of search accross a whole directory: Just add the mappings (or +choose different letter combinations): map gr :grep <cword> *<cr> +map gr :grep <cword> %:p:h/*<cr> map gR :grep \b<cword>\b +*<cr> map GR :grep \b<cword>\b %:p:h/*<cr> + +mapping one will search for the word under the cursor (like g*) in any of +the files in the current directory mapping two will search for the word +under the cursor (like g*) in any of the files in the same directory as the +current file mapping three will search for the word under the cursor by itself +(i.e. surrounded by word boundary like *) in any of the files in the current +directory mapping four will search for the word under the cursor by itself +(i.e. surrounded by word boundary like *) in any of the files in the same +directory as the current file + +Benoit + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Number a group of lines</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=124">http://vim.sf.net/tip_view.php?tip_id=124</A><BR> + +Below is a way to number a set of lines. Here is an exaple before and +after snapshot: + +apple bob pear tree + +1 apple 2 bob 3 pear 4 tree + +" Description: " This provides a command and a function. They both can be +called with or " without a range. In addition, they can be called with or +without " arguments. Without a range they operate on the current line. " " +There are two supported arguments. They are described below: " arg1 -> +the number to start at. The default is one. This will " number +your selected lines sequentially. The start can be a " number, +., $, or, 'x (like getline). " arg2 -> Text to append after numbers. +The default is a space. " " Examples: " To provide your functionality: +" :%Nlist 20 " :%call Nlist(20) " To make a list start at +1: " :'<,'>Nlist " :'<,'>call Nlist() " To +number the whole buffer (with it's actual line number): " :%Nlist " +:%call Nlist() " To number a subset of lines with their line number (and +put a '] ' in " front of every number): " :'<,'>Nlist . ]\ +" :'<,'>call Nlist(".", "] ") + +command! -nargs=* -range Nlist <line1>,<line2>call +Nlist(<f-args>) function! Nlist(...) range + if 2 == a:0 + let start = a:1 let append = a:2 + elseif 1 == a:0 + let start = a:1 let append = " " + else + let start = 1 let append = " " + endif + + " try to work like getline (i.e. allow the user to pass in . $ or 'x) + if 0 == (start + 0) + let start = line(start) + endif + + exe a:firstline . "," . a:lastline + . 's/^/\=line(".")-a:firstline+start.append/' +endfunction + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Auto commenting for "}"</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=125">http://vim.sf.net/tip_view.php?tip_id=125</A><BR> + +I always wanted a script that would auto-comment the end of a conditional +block. So, I wrote one. This function searches for the previous matching +"{", grabs the line, and inserts it as a comment after the "}". If there +is no previous matching "{", it inserts nothing. + +So... + + if (test){ + +will generate: + } // if (test) + +This is obviously not work if you use a different style. If you use + + if (test) { + +then substituting 'getline(".")', use 'getline(line(".") - 1)' should work. + +Put the following in your .vimrc: au BufNewFile,BufRead *.c,*.cc,*.C,*.h +imap } <ESC>:call CurlyBracket()<CR>a + +function CurlyBracket() + let l:my_linenum = line(".") iunmap } sil exe "normal i}" imap } + <ESC>:call CurlyBracket()<CR> let l:result1 = searchpair('{', + '', '}', 'bW') if (result1 > 0) + let l:my_string = substitute(getline("."), '^\s*\(.*\){', '\1', "") + sil exe ":" . l:my_linenum sil exe "normal a //" . l:my_string + endif +endfunction + +</pre></tip> </html> <Tip category="KVim"> <html><center>how do +I get rid of that bold stuff with my xterm?</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=126">http://vim.sf.net/tip_view.php?tip_id=126</A><BR> + +Having problems setting up your syntax highlighting because everything is +coming up in bold? + +You're probably using an 8 color xterm and setting up highlighting lines such +as hi Normal ... ctermfg=green . The solution: use numbers! 0=black, 1=red, +2=green, 3=yellow, 4=blue, 5=magenta, 6=cyan, and 7=white. Vim tries to use +"bright" colors when its given names (because Windoz machines prefer to use +dim text unless its been made bold). + +Read more about it under :help highlight-ctermfg . + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Preview HTML files quickly</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=127">http://vim.sf.net/tip_view.php?tip_id=127</A><BR> + +I've found while writing HTML files that it can become cumbersome when I have +to switch to a web browser, load my page, and move back to VIM regularly to +preview what I've written. I've come up with the following tricks. + +The first one requires that you have lynx (the text-based browser) installed +on your computer (available from <A HREF="http://lynx.isc.org/release/). +If your HTML page is primarily text, with few (if any) images, you can +set up the following function and mapping:">http://lynx.isc.org/release/). +If your HTML page is primarily text, with few (if any) images, you can set +up the following function and mapping:</A><BR> + + function PreviewHTML_TextOnly() + let l:fname = expand("%:p" ) new set buftype=nofile nonumber exe "%!lynx + " . l:fname . " -dump -nolist -underscore -width " . winwidth( 0 ) + endfunction + + map <Leader>pt :call PreviewHTML_TextOnly()<CR> + +This will open a new window and display your formatted HTML document in +that window. Note that bold-face, italics, links, etc. will be lost -- +all you will see is the text -- but the "-underscore" parameter to Lynx +causes any text that would have been bold, italicized, or underlined to be +displayed like _this_. + +The other trick requires that vim be running on your current machine, and that +you be running a GUI of some sort (X-Windows, Windows, etc.). You can cause +vim to invoke your favorite browser and have it display the file, like this: + function PreviewHTML_External() + exe "silent !mozilla -remote \"openurl(file://" . expand( "%:p" ) . ")\"" + endfunction + + map <Leader>pp :call PreviewHTML_External()<CR> +If you don't use mozilla, you will need to modify the function to use your +preferred browser. + +Happy vimming! + +</pre></tip> </html> <Tip category="KVim"> <html><center>grep, +diff, patch, idutils, etc. for Windows systems</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=128">http://vim.sf.net/tip_view.php?tip_id=128</A><BR> + + If you use Vim on Windows, and you wish you had some of those nifty + UNIX command-line tools, +but do not feel like installing all of Cygwin, you +can get many of the most-used tools from Ron Aaron's web site: <A +HREF="http://www.mossbayeng.com/~ron/vim/builds.html">http://www.mossbayeng.com/~ron/vim/builds.html</A><BR> +Since Ron is a big Vim fan (see <A +HREF="http://www.mossbayeng.com/~ron/vim/vimrant.html ) you can count +on">http://www.mossbayeng.com/~ron/vim/vimrant.html ) you can count on</A><BR> +these tools' working well with Vim. For some hints on how to use them, +read :help :grep :help lid inside Vim. + Happy Vimming! + +</pre></tip> </html> <Tip category="KVim"> <html><center>Removing +automatic comment leaders</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=129">http://vim.sf.net/tip_view.php?tip_id=129</A><BR> + + If you include the "r" flag in the 'formatoptions' option (:help 'fo' + , :help fo-table ) then the comment leader is inserted +automatically when you start a new line in a comment. For example, in TeX +the "%" character is the comment leader, and you might type + +% This is a tex file. % The comment leaders on all lines but the first +were generated automatically. % This is the last line of the comment, +but Vim will insert the comment leader on the next line. % + +You can get rid of the comment leader (along with anything you may already +have typed on the line) without affecting the indent, if any, by typing +"<C-U>" while in Insert mode. + + Related point: if you want to adjust the indent while in Insert mode, + you can use "<C-D>" (to Decrease the indent) +or "<C-T>" (to increase it). In the docs for Vim 6.0, this is described +in the users' manual, :help 30.4 . + +</pre></tip> </html> <Tip category="KVim"> +<html><center>disabling default ftplugins</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=130">http://vim.sf.net/tip_view.php?tip_id=130</A><BR> + + For an overview of ftplugins (filetype plugins) see + +:help ftplugins + +If you want to disable all ftplugins, or disable a particular default +ftplugin, see + +:help :filetype :help ftplugin-overrule + +If you have your own ftplugins, and you want to disable all the default +ones, then do NOT include a check for b:did_ftplugin in your ftplugin files, +and add the line + +:autocmd BufEnter * let b:did_ftplugin = 1 + +to your VIMRC file, BEFORE the ":filetype ftplugin on" line. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Scroll alternate window</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=131">http://vim.sf.net/tip_view.php?tip_id=131</A><BR> + +This mapping allow you to quickly scroll inactive window when displaying +several windows concurrently. + +nmap <silent> <M-Down> :call ScrollOtherWindow("down")<CR> +nmap <silent> <M-Up> :call ScrollOtherWindow("up")<CR> + +fun! ScrollOtherWindow(dir) + if a:dir == "down" + let move = "\<C-E>" + elseif a:dir == "up" + let move = "\<C-Y>" + endif exec "normal \<C-W>p" . move . "\<C-W>p" +endfun + +PS: Original idea and discussion of this tip appeared on vim@vim.org mailing +list, I'm just prettified it a little. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>window zooming convenience</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=132">http://vim.sf.net/tip_view.php?tip_id=132</A><BR> + +i frequently have multiple windows open in vim -- this reduces the number +of lines each window displays -- i almost always have my windows either all +the same size or the current one as big as possible. + +the following function can be toggled on or off by typing <Leader>max +(i can do this quite quickly); just change the mapping at the bottom to +something else if you prefer. + +this causes the current window to be as big as possible (moving into another +window causes that one to become big) and all the others get very small. +i actually use this ALL the time. turning it off (by typing the hotkey +sequence again) will cause all windows to have the same height. + +"toggles whether or not the current window is automatically zoomed +function! ToggleMaxWins () + if exists ('g:windowMax') + au! maxCurrWin exe "normal \<c-w>=" unlet g:windowMax + else + augroup maxCurrWin " au BufEnter * exe "normal + \<c-w>_\<c-w>\<bar>" " " only max it vertically + au! BufEnter * exe "normal \<c-w>_" augroup END do maxCurrWin + BufEnter let g:windowMax=1 + endif +endfunction map <Leader>max :call ToggleMaxWins ()<CR> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Windo and Bufdo</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=133">http://vim.sf.net/tip_view.php?tip_id=133</A><BR> + +i like bufdo and windo but i don't like the fact that the commands end in +a different window/buffer than from where i executed them. these versions +(starts with a capital letter) will restore the current window or buffer +when the command's done. + +for example, to turn on line numbers everywhere, i use :Windo set nu -- +:windo set nu does the trick also but leaves me in a different window than +where i started. + +" just like windo but restores the current window when it's done +function! WinDo(command) + let currwin=winnr() execute 'windo ' . a:command execute currwin . 'wincmd w' +endfunction com! -nargs=+ -complete=command Windo call WinDo(<q-args>) + +" just like bufdo but restores the current buffer when it's done +function! BufDo(command) + let currBuff=bufnr("%") execute 'bufdo ' . a:command execute 'buffer ' + . currBuff +endfunction com! -nargs=+ -complete=command Bufdo call BufDo(<q-args>) + +</pre></tip> </html> <Tip category="KVim"> +<html><center>View Source in IE6 using VIM</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=134">http://vim.sf.net/tip_view.php?tip_id=134</A><BR> + +You can change the "View Source" editor of IE6 by adding the following to +the Windows Registry. Change the path in case you installed VIM in another +location. + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source +Editor\Editor Name] @="C:\\vim\\vim60\\gvim.exe" + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Vim buffer FAQ</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=135">http://vim.sf.net/tip_view.php?tip_id=135</A><BR> + +Vim provides various commands and options to support editing multiple buffers. +This document covers some of the questions asked about using multiple buffers +with Vim. You can get more detailed information about Vim buffer support using +":help windows.txt" in Vim. You can also use the help keywords mentioned in +this document to read more about a particular command or option. To read more +about a particular command or option use, ":help <helpkeyword>" in Vim. + +1. What is a Vim buffer? + A buffer is a file loaded into memory for editing. All opened files + are associated with a buffer. There are also buffers not associated with + any file. + + Help keyword(s): windows-intro + +2. How do I identify a buffer? + Vim buffers are identified using a name and a number. The name of the + buffer is the name of the file associated with that buffer. The buffer + number is a unique sequential number assigned by Vim. This buffer number + will not change in a single Vim session. + + Help keyword(s): :buffers + +3. How do I create a buffer? + When you open a file using any of the Vim commands, a buffer is + automatically created. For example, if you use the ":edit file" command + to edit a file, a new buffer is automatically created. + +4. How do I add a new buffer for a file to the buffer list without opening + the file? You can add a new buffer for a file without opening it, using + the ":badd" ex command. For example, + + :badd f1.txt :badd f2.txt + + The above commands will add two new buffers for the files f1.txt and + f2.txt to the buffer list. + + Help keyword(s): :badd + +5. How do I get a list of all the existing buffers? + You can get a list of all the existing buffers using the ":buffers" or + ":ls" or ":files" ex command. This list is called the 'buffer list'. + + In Vim 6.0, to display all the buffers including unlisted buffers, use the + ":buffers!" or ":ls!" or ":files!" ex command. + + Help keyword(s): :buffers, :ls, :files + +6. How do I delete a buffer? + You can delete a buffer using the ":bdelete" ex command. You can use either + the buffer name or the buffer number to specify a buffer. For example, + + :bdelete f1.txt :bdelete 4 + + The above commands will delete the buffer named "f1.txt" and the fourth + buffer in the buffer list. The ":bdelete" command will remove the buffer + from the buffer list. + + In Vim 6.0, when a buffer is deleted, the buffer becomes an unlisted-buffer + and is no longer included in the buffer list. But the buffer name and other + information associated with the buffer is still remembered. To completely + delete the buffer, use the ":bwipeout" ex command. This command will remove + the buffer completely (i.e. the buffer will not become a unlisted buffer). + + Help keyword(s): :bdelete, :bwipeout + +7. How do I delete multiple buffers? + You can delete multiple buffers in several ways: + + 1. Pass a range argument to the ":bdelete" command. For example, + + :3,5bdelete + + This command will delete the buffers 3, 4 and 5. + 2. Pass multiple buffer names to the ":bdelete" command. For example, + + :bdelete buf1.txt buf2.c buf3.h + + This command will delete buf1.txt, buf2.c and buf3.h buffers. In this + example, after typing ":bdelete buf", you can press <Ctrl-A> + to expand all the buffer names starting with 'buf'. + + Help keyword(s): :bdelete, :bwipeout + +8. How do I remove a buffer from a window? + You can remove a buffer displayed in a window in several ways: + + 1. Close the window or edit another buffer/file in that window. 2. Use + the ":bunload" ex command. This command will remove the buffer + from the window and unload the buffer contents from memory. The buffer + will not be removed from the buffer list. + + Help keyword(s): :bunload + +9. How do I edit an existing buffer from the buffer list? + You can edit or jump to a buffer in the buffer list in several ways: + + 1. Use the ":buffer" ex command passing the name of an existing buffer + or the buffer number. Note that buffer name completion can be used + here by pressing the <Tab> key. + 2. You can enter the buffer number you want to jump/edit and press the + Ctrl-^ key. + 3. Use the ":sbuffer" ex command passing the name of the buffer or the + buffer number. Vim will split open a new window and open the specified + buffer in that window. + 4. You can enter the buffer number you want to jump/edit and press the + Ctrl-W ^ or Ctrl-W Ctrl-^ keys. This will open the specified buffer + in a new window. + + Help keyword(s): :buffer, :sbuffer, CTRL-W_^, CTRL-^ + +10. How do I browse through all the available buffers? + You can browse through the buffers in the buffer list in several ways: + + 1. To jump to the first buffer in the buffer list, use the ":bfirst" or + ":brewind" ex command. + 2. To jump to the first buffer in the buffer list in a new window, use + the ":sbfirst" or ":sbrewind" ex command. + 3. To edit the next buffer in the buffer list, use the ":bnext" ex + command. + 4. To open the next buffer in the buffer list in a new window, use the + ":sbnext" ex command. + 5. To edit the previous buffer in the buffer list, use the ":bprevious" + or ":bNext" ex command. + 6. To open the previous buffer in the buffer list in a new window, use + the ":sbprevious" or ":sbNext" ex command. + 7. To open the last buffer in the buffer list, use the ":blast" ex + command. + 8. To open the last buffer in the buffer list in a new window, use the + ":sblast" ex command. + + Help keyword(s): :bfirst, :brewind, :sbfirst, :sbrewind, :bnext, + :sbnext, :bprevious, :bNext, :sbprevious, :sbNext, + :blast, :sblast + +11. How do I open all the buffers in the buffer list? + You can open all the buffers present in the buffer list using the ":ball" + or ":sball" ex commands. + + Help keyword(s): :ball, :sball + +12. How do I open all the loaded buffers? + You can open all the loaded buffers in the buffer list using the ":unhide" + or ":sunhide" ex commands. Each buffer will be loaded in a separate + new window. + + Help keyword(s): :unhide, :sunhide + +13. How do I open the next modified buffer? + You can open the next or a specific modified buffer using the ":bmodified" + ex command. You can open the next or a specific modified buffer in a + new window using the ":sbmodified" ex command. + + Help keyword(s): :bmodified, :sbmodified + +14. I am using the GUI version of Vim (gvim), is there a simpler way for + using the buffers instead of the ex commands? Yes. In the GUI version of + Vim, you can use the 'Buffers' menu, which simplifies the use of buffers. + All the buffers in the buffer list are listed in this menu. You can + select a buffer name from this menu to edit the buffer. You can also + delete a buffer or browse the buffer list. + + Help keyword(s): buffers-menu + +15. Is there a Vim script that simplifies using buffers with Vim? + Yes. You can use the bufexplorer.vim script to simplify the process of + using buffers. You can download the bufexplorer script from: + + <A + HREF="http://lanzarotta.tripod.com/vim.html">http://lanzarotta.tripod.com/vim.html</A><BR> + +16. Is it possible to save and restore the buffer list across Vim sessions? + Yes. To save and restore the buffer list across Vim session, include the + '%' flag in the 'viminfo' option. Note that if Vim is invoked with a + filename argument, then the buffer list will not be restored from the + last session. To use buffer lists across sessions, invoke Vim without + passing filename arguments. + + Help keyword(s): 'viminfo', viminfo + +17. How do I remove all the entries from the buffer list? + You can remove all the entries in the buffer list by starting Vim with + a file argument. You can also manually remove all the buffers using the + ":bdelete" ex command. + +18. What is a hidden buffer? + A hidden buffer is a buffer with some unsaved modifications and is not + displayed in a window. Hidden buffers are useful, if you want to edit + multiple buffers without saving the modifications made to a buffer while + loading other buffers. + + Help keyword(s): :buffer-!, 'hidden', hidden-buffer, buffer-hidden + +19. How do I load buffers in a window, which currently has a buffer with + unsaved modifications? By setting the option 'hidden', you can load + buffers in a window that currently has a modified buffer. Vim will + remember your modifications to the buffer. When you quit Vim, you will be + asked to save the modified buffers. It is important to note that, if you + have the 'hidden' option set, and you quit Vim forcibly, for example using + ":quit!", then you will lose all your modifications to the hidden buffers. + + Help keyword(s): 'hidden' + +20. Is it possible to unload or delete a buffer when it becomes hidden? + The following works only in Vim 6.0 and above. By setting the 'bufhidden' + option to either 'hide' or 'unload' or 'delete', you can control what + happens to a buffer when it becomes hidden. When 'bufhidden' is set to + 'delete', the buffer is deleted when it becomes hidden. When 'bufhidden' + is set to 'unload', the buffer is unloaded when it becomes hidden. + When 'bufhidden' is set to 'hide', the buffer is hidden. + + Help keyword(s): 'bufhidden' + +21. How do I execute a command on all the buffers in the buffer list? + In Vim 6.0, you can use the ":bufdo" ex command to execute an ex command + on all the buffers in the buffer list. + + Help keyword(s): :bufdo + +22. When I open an existing buffer from the buffer list, if the buffer is + already displayed in one of the existing windows, I want Vim to jump to + that window instead of creating a new window for this buffer. How do I + do this? When opening a buffer using one of the split open buffer commands + (:sbuffer, :sbnext), Vim will open the specified buffer in a new window. + If the buffer is already opened in one of the existing windows, then + you will have two windows containing the same buffer. You can change + this behavior by setting the 'switchbuf' option to 'useopen'. With this + setting, if a buffer is already opened in one of the windows, Vim will + jump to that window, instead of creating a new window. + + Help keyword(s): 'switchbuf' + +23. What information is stored as part of a buffer? + Every buffer in the buffer list contains information about the last + cursor position, marks, jump list, etc. + +24. What is the difference between deleting a buffer and unloading a + buffer? When a buffer is unloaded, it is not removed from the buffer list. + Only the file contents associated with the buffer are removed from memory. + When a buffer is deleted, it is unloaded and removed from the buffer list. + In Vim 6, a deleted buffer becomes an 'unlisted' buffer. + + Help keyword(s): :bunload, :bdelete, :bwipeout, unlisted-buffer + +25. Is it possible to configure Vim, by setting some option, to re-use the + number of a deleted buffer for a new buffer? No. Vim will not re-use the + buffer number of a deleted buffer for a new buffer. Vim will always assign + the next sequential number for a new buffer. The buffer number assignment + is implemented this way, so that you can always jump to a buffer using the + same buffer number. One method to achieve buffer number reordering is to + restart Vim. If you restart Vim, it will re-assign numbers sequentially + to all the buffers in the buffer list (assuming you have properly set + 'viminfo' to save and restore the buffer list across vim sessions). + + Help keyword(s): :buffers + +26. What options do I need to set for a scratch (temporary) buffer? + The following works only in Vim 6.0 and above. You can set the the + following options to create a scratch (temporary) buffer: + + :set buftype=nofile :set bufhidden=hide :setlocal noswapfile + + This will create a buffer which is not associated with a file, which + does not have a associated swap file and will be hidden when removed + from a window. + + Help keyword(s): special-buffers, 'buftype' + +27. How do I prevent a buffer from being added to the buffer list? + The following works only in Vim 6.0 and above. You can prevent a buffer + from being added to the buffer list by resetting the 'buflisted' option. + + :set nobuflisted + + Help keyword(s): 'buflisted' + +28. How do I determine whether a buffer is modified or not? + There are several ways to find out whether a buffer is modified or not. + The simplest way is to look at the status line or the title bar. If the + displayed string contains a '+' character, then the buffer is modified. + Another way is to check whether the 'modified' option is set or not. + If 'modified' is set, then the buffer is modified. To check the value + of modified, use + + :set modified? + + You can also explicitly set the 'modified' option to mark the buffer as + modified like this: + + :set modified + + Help keyword(s): 'modified' + +29. How can I prevent modifications to a buffer? + The following works only in Vim 6.0 and above. You can prevent any + modification to a buffer by re-setting the 'modifiable' option. To reset + this option, use + + :set nomodifiable + + To again allow modifications to the buffer, use: + + :set modifiable + + Help keyword(s): 'modifiable' + +30. How do I set options specific to the current buffer? + The following works only in Vim 6.0 and above. You can set Vim options + which are specific to a buffer using the "setlocal" command. For example, + + :setlocal textwidth=70 + + This will set the 'textwidth' option to 70 only for the current buffer. + All other buffers will have the default or the previous 'textwidth' value. + + Help keyword(s): 'setlocal', local-options + +31. How do I define mappings specific to the current buffer? + The following works only in Vim 6.0 and above. You can define mappings + specific to the current buffer by using the keyword "<buffer>" + in the map command. For example, + + :map <buffer> ,w /[.,;]<CR> + + Help keyword(s): :map-local + +32. How do I define abbreviations specific to the current buffer? + The following works only in Vim 6.0 and above. You can define + abbreviations specific to the current buffer by using the keyword + "<buffer>" in the :abbreviate command. For example, + + :abb <buffer> FF for (i = 0; i < ; ++i) + + Help keyword(s): :abbreviate-local + +</pre></tip> </html> <Tip category="KVim"> <html><center>Remapping +Alt, Ctrl and Caps in Win2k</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=136">http://vim.sf.net/tip_view.php?tip_id=136</A><BR> + +Since I installed Win2K on my laptop, I had been unable to locate a utilitie +that would simply enable me to remap my Crtl Alt and Caps the way I think they +should be and the way they were until MS kill all competition in computing, +that is Crtl on the left of the letter A, Alt to the left bottom of the +letter Z and Caps approximately until the C. + +After some research, I came across a tip posted here by juano@mindspring.com. I +tried to make sense of it and then downloaded the MS scan keys map at the +URL he mentionned. + +Extrapolating his tip, I wrote this ASCI file that I named keys2000.reg : + +Regedit4 [HKey_Local_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard +Layout] "Scancode +Map"=hex:00,00,00,00,00,00,00,00,04,00,00,00,3A,00,38,00,38,00,1D,00,1D,00,3A,00,00,00,00 + +Once you have saved this file, left click on it from Explorer and answer +yes to the prompt "do you want to enter this into the registry". + +Reboot and you are done. + +A few explanations :04 stands for 3 remappings (Caps lock to Control, Control +to Alt and Alt to Caps Lock) plus the closing one which is always required +(1 remapping would require 02, 2 would require 03, and so on). 3A,00,38 +remaps Caps to Left Alt, 38,00,1D remaps Left Alt to Left Ctrl and 1D,00,3A +remaps Left Ctrl to Caps Lock since 3A=Caps, 1D=Left Ctrl and 38=Left Alt. + +Based on Juano tip and on this one, I believe a lot of remapping can be done +as long as you keep the separators 00 and remember to add one to the number +of remappings. What I do not know is how far you can extend this instruction +without getting into trouble with the registry. At worst, if you keyboard does +not behave as expected, go into the registry and delete this instruction (be +careful here since it is easy to confuse this instruction with the Keyboard +LayoutS (S for emphasis) which must not be deleted. + +Again, thanks to Juano@mindspring.com who got me going and suggested I +post my tip. Took me some time to retrieve the VIM Url but fortunately, +I had printed his tip. + +Regards + +</pre></tip> </html> <Tip category="KVim"> +<html><center>automatically wrap left and right</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=137">http://vim.sf.net/tip_view.php?tip_id=137</A><BR> + +I hate it when I hit left (or h) and my screen flickers. I want it to go up +to the next line. Ditto fir right (or l). Below are two functions / mappings +to help with that. I'm pretty sure that if you remove the <silent>, +then it will work in 5.x... + +nnoremap <silent> <Left> :call WrapLeft()<cr> nnoremap +<silent> <Right> :call WrapRight()<cr> + +nnoremap <silent> h :call WrapLeft()<cr> nnoremap +<silent> l :call WrapRight()<cr> + +function! WrapLeft() + let col = col(".") + + if 1 == col + " don't wrap if we're on the first line if 1 == line(".") + return + endif normal! k$ + else + normal! h + endif +endfunction + +function! WrapRight() + let col = col(".") if 1 != col("$") + let col = col + 1 + endif + + if col("$") == col + " don't wrap if we're on the last line if line("$") == line(".") + return + endif normal! j1| + else + normal! l + endif +endfunction + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Getting name of the function</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=138">http://vim.sf.net/tip_view.php?tip_id=138</A><BR> + +Hi All, + +While browsing code one always needs to know which function you are currently +looking. Getting the name is very painful when the functions are lengthy +and you are currently browsing NOT near to the start of the function. You +can get the function's name by using this simple mapping. + +Just place this in your .vimrc. + +map _F ma[[k"xyy`a:echo @x<CR> + +now _F will display which function you are currently in. + +Enjoy the power of Vim -Nitin Raut + +PS: The working is as follows, mark the current line with a, jump to the +previous '{' in the first column, go one line up, yank the line in register +x, return to the mark a, echo the value of register x, which is the wanted +function name. + +</pre></tip> </html> <Tip category="KVim"> <html><center>=, +LaTeX tables, declarations, etc</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=139">http://vim.sf.net/tip_view.php?tip_id=139</A><BR> + +Check out + +<A +HREF="http://www.erols.com/astronaut/vim/textab.html">http://www.erols.com/astronaut/vim/textab.html</A><BR> + +and see some examples of text alignment (its hopeless to do it here with +proportional fonts). You'll be able to download textab source, a Windows-based +textab executable, and a scriptfile containing a convenient interface +(ttalign.vim). The textab program coupled with <ttalign.vim> lets you: + +1. align C language statements on their = += -= /= etc symbols 2. align C +language declararations: separate columns for types, *[, variable + names, initializations (=), and comments (// or /* .. */) +3. align C/C++ language comments (//, /* .. */) 4. align C/C++ language +(ansi) function argument lists 5. align LaTeX tables on their && separators +6. align HTML tables with </TD><TD> separators 7. align on +several characters: < ? : | @ ; (or modify them to handle whatever + alignment characters you want) + +</pre></tip> </html> <Tip category="KVim"> <html><center>tip +using embedded perl interpreter</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=140">http://vim.sf.net/tip_view.php?tip_id=140</A><BR> + +When writing scripts using the embedded interpreter available if vim has the ++perl ore +perl/dyn on gives you access to this powerfull and FAST scripting +language (especially fast compared to vim scripts) there are some gotchas. + +First: never embed complex perl command in the body of a vim function this +will be recompiled and evaled each time for a tremendous loss of time.instead +to it like this + +perl << EOF sub mySub { + #some usefull perl stuff +} EOF + +function! MyFunction perl mySub "an argument", "another" endfunction + +to pass computed argument to your perl sub use the vim exec command +function! MyFunction exec "perl mySub " . aLocalVar . ", " b:aBufferLocalVar +endfunction + +It may be very hard to debug your perl sub since the output of the perl +compiler is somehow lost in the middle of nowhere and the debugger is not +available. When a compilation error occurs in your sub definition you'll get +an error message when you try to call it saying that the sub does not exists. +One thing which I have found very usefull is to write a fake VIM module with +stub methods which will allow you to use the command line perl interpretor +to at least compile your program. You could make your stub smart enough to +fake a vim and use the debugger. Here is a sample for such a fake module +defining just those method which I was using. + +package VIM; use diagnostics; use strict; sub VIM::Eval { + $_ = shift; + + print "Eval $_\n"; + + { + return + '^(?!!)([^\t]*)\t[^\t]*\t(.*);"\t([^\t]*)\tline:(\d*).*$' + if (/g:TagsBase_pattern/); return $ARGV[0] if + (/b:fileName/); return '$3' if (/g:TagsBase_typePar/); + return '$1' if (/g:TagsBase_namePar/); return '$4' if + (/g:TagsBase_linePar/); return 'Ta&gs' if (/s:menu_name/); + return $ARGV[1] if (/g:TagsBase_groupByType/); + die "unknown eval $_"; + } +} sub VIM::Msg { + my $msg = shift; print "MSG $msg\n"; +} sub VIM::DoCommand { + my $package; my $filename; my $line; + ($package, $filename, $line) = caller; + + my $command = shift; print "at $filename $line\n"; print "DoCommand + $command\n"; +} 1; + +Then you can copy other your perl code in a separate file and add a use VIM; +at the top and your set to debug. + +Good Vimming good perling. Benoit PS: this tips are probably true for other +scripting languages + +</pre></tip> </html> <Tip category="KVim"> <html><center>Add +your function heading with a keystroke</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=141">http://vim.sf.net/tip_view.php?tip_id=141</A><BR> + +Below is a tip that the C/C++ Newbies may find interesting and handy to use. +The following code will add a function heading and position your cursor just +after Description so that one can document as one proceeds with code. + +function FileHeading() + let s:line=line(".") call + setline(s:line,"/***************************************************") + call append(s:line,"* Description - ") call append(s:line+1,"* + Author - Mohit Kalra") call append(s:line+2,"* Date + - ".strftime("%b %d %Y")) call append(s:line+3,"* + *************************************************/") unlet s:line +endfunction + +imap <F4> <esc>mz:execute FileHeading()<RET>`zjA + +Where <esc> stands for ^V+ESC and <RET> for ^V+ENTER + +</pre></tip> </html> <Tip category="KVim"> <html><center>Automatic +function end commenting for C++ and Java</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=142">http://vim.sf.net/tip_view.php?tip_id=142</A><BR> + +Some people have a habit of adding the function name as a comment to the +end of that function, if it is long, so that he/she knows which function the +'}' ends. Here's a way to automate the process. + +Use the following abbreviation: iab }// } // END: +<esc>10h%$?\w\+\s*(<cr>"xy/\s*(<cr>/{<cr>:nohl<cr>%$"xpa + +If you now end the function with '}//', the follwoing string will be +automatically generated: '} //END: functionname' + +</pre></tip> </html> <Tip category="KVim"> <html><center>Use +of Vim folds for javadocs</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=143">http://vim.sf.net/tip_view.php?tip_id=143</A><BR> + +Hi, + +The fold-method marker can be effectively use to set the folds in your +Java source. Define some marker and place it inside HTML comments <!-- +xx -->. This way, it does not affect the Javadocs generated without the +necessity of a seprate comment line. e.g. + +/** + * <!-- zz.FOLDSTART class AbcClass --> * The class description. + * ... */ +public class AbcClass { + + /** + * <!-- method zz.FOLDSTART someMethod() --> * Method description. + */ + public void someMethod(); + + ... + +} /* zz.END: AbcClass */ + +/* Put this at the end of your file */ /* vim:fdm=marker +fmr=zz.FOLDSTART,zz.END fdl=2 fdc=2: */ + +Now, the files will be opened with the methods neatly folded. You can use +"zR" to open all folds (or click on the "+" at the left column). + +Sameer. + +</pre></tip> </html> <Tip category="KVim"> <html><center>recording +keystrokes by "q" for repested jobs</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=144">http://vim.sf.net/tip_view.php?tip_id=144</A><BR> + +The most useful feature that I find in VIM is the "recording" feature (:help +recording). I have used this to automatically insert function headers, +re-indent lines, and convert some 34 source files into HTML. + +This feature is most useful when you want to do some repeated jobs, which +you cant do easily using ".". You can set about writing a function, define +a mapping, etc, but then these things might take time. By recording, you +can try out and find the actual keystrokes that does the job. + +To start recording, press "q" in normal mode followed by any of "0-9a-z". +This will start recording the keystrokes to the register you choose. You can +also see the word "recording" in the status(?) line. You can start the key +sequences that you want to record. You can go to insert mode and type if +you want. + +To stop recording, press "q" in the normal mode. + +To playback your keystrokes, press "@" followed by the character you choose. +Pressing "@@" will repeat the same again. + +Sameer. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Changing +DOS style end of line to UNIX, or vise-versa</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=145">http://vim.sf.net/tip_view.php?tip_id=145</A><BR> + +Those of us doomed to work in both the Unix and Windows world have many times +encountered files that were create/editted on systems other that the one +we are on at the time of our edits. We can easily correct the dreaded '^M' +at the end of our Unix lines, or make files have more than one line in DOS by: + +To change from <CR><LF> (DOS) to just <LF> (Unix): :set +fileformat=unix :w + +Or to change back the other way: :set fileformat=dos :w + +It also works for Apple land: :set fileformat=mac :w + +And to tell the difference: set statusline=%<%f%h%m%r%=%{&ff}\ %l,%c%V\ %P + ^^^^^ This shows what the + current file's format is. + +Happy Vimming! + +</pre></tip> </html> <Tip category="KVim"> <html><center>opening +multiple files from a single command-line</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=146">http://vim.sf.net/tip_view.php?tip_id=146</A><BR> + +i use the :split command a lot -- both to open a second window containing +the currently edited file and to edit a new file altogether (with the :split +<filename> option). however, i also like to be able to edit more than +one file and calling :sp multiple times is inconvenient. so, i created the +following command, function and abbreviation: + +function! Sp(...) + if(a:0 == 0) + sp + else + let i = a:0 while(i > 0) + execute 'let file = a:' . i execute 'sp ' . file + + let i = i - 1 + endwhile + endif +endfunction com! -nargs=* -complete=file Sp call Sp(<f-args>) cab sp Sp + +this retains the behaviour of :sp in that i can still type :sp (the +abbreviation takes care of that). :Sp takes any number of files and opens +them all up, one after the other. + +the things i have noticed are that this causes 'sp' to be expanded to 'Sp' +everywhere, even in search patterns. also, prepending 'vert' doesn't work. +if there is interest, i'll do that. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>How to write a plugin</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=147">http://vim.sf.net/tip_view.php?tip_id=147</A><BR> + +This tip gives a skeleton for writing a plugin; Vim's help files have plenty +of details (:he plugin, :he write-plugin, :he plugin-details). + +# +------------------------------------------------------------------------------ +# Exit when your app has already been loaded (or "compatible" mode set) +if exists("loaded_YourAppName") || &cp + finish +endif + +# Public Interface: # AppFunction: is a function you expect your users to +call # PickAMap: some sequence of characters that will run your AppFunction # +Repeat these three lines as needed for multiple functions which will # be used +to provide an interface for the user if !hasmapto('<Plug>AppFunction') + map <unique> <Leader>PickAMap <Plug>AppFunction +endif + +# Global Maps: # map <silent> <unique> +<script> <Plug>AppFunction \ :set lz<CR>:call +<SID>AppFunc<CR>:set nolz<CR> + +# +------------------------------------------------------------------------------ + +# AppFunction: this function is available vi the <Plug>/<script> +interface above fu! <SID>AppFunction() ..whatever.. + +# your script function can set up maps to internal functions +nmap <silent> <left> :set lz<CR>:silent! call +<SID>AppFunction2<CR>:set nolz<CR> + +# your app can call functions in its own script and not worry about +name # clashes by preceding those function names with <SID> call +<SID>InternalAppFunction(...) + +# or you could call it with call s:InternalAppFunction(...) endf # +------------------------------------------------------------------------------ + +# InternalAppFunction: this function cannot be called from outside the # +script, and its name won't clash with whatever else the user has loaded +fu! <SID>InternalAppFunction(...) ..whatever.. endf + +# +------------------------------------------------------------------------------ + +Plugins are intended to be "drop into <.vim/plugin>" and work. +The problem that the <Plug>, <SID>, etc stuff is intended to +resolve: what to do about functions that have the same names in different +plugins, and what to do about maps that use the same sequence of characters? +The first problem is solved with <SID> (a script identifier number) +that vim assigns: program with it and your users will be happier when your +stuff works with all their other stuff. The second problem: what to about +those maps is addressed with <Plug>, <unique>, etc. Basically +the idea is: let the user know that there are clashes and don't overwrite +previously existing maps. Use the user's preferred map-introducer sequence +(I like the backslash, but there are many keyboards which make producing +backslashes unpleasant, and those users usually prefer something else). + +What I like to do is to have a pair of start/stop maps to reduce my impact +on the namespace. When the starting map is used, it kicks off a starting +function that introduces all the maps needed. When the stopping map is +used, it not only removes the maps the starter made but restores any maps +the user had had that would have clashed. I also use the start/stop pair +of functions to set and restore options that cause my scripts difficulties. + +Check out DrawIt.vim's SaveMap() function for a way to save user maps. +Restoring maps with it is easy: + +if b:restoremap != "" + exe b:restoremap unlet b:restoremap +endif + +So you can see it sets up a string variable with all the maps that the user +had that would have clashed with my application. + +One final thing: if your application needs to share information between +its various functions, see if you can use s:varname (a variable that only +your script's functions can access) or b:varname (a variable that anything +associated with the buffer your application is running with can access) +instead of using global variables. + +Good luck and happy Vimming! + +</pre></tip> </html> <Tip category="KVim"> <html><center>Make +great use of those homemade menus</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=148">http://vim.sf.net/tip_view.php?tip_id=148</A><BR> + +Accidently discovered that using <alt><Menu Hotletter><cr> +(e.g <alt>b<cr> - for the buffer menu) causes the menu to break +out in a seperate window. Selecting the menu with the mouse and then hitting +enter does not seem to do it. + +I will have to learn to add hotletters to my menus now so that the mouse +can take a break. + +I am a total newbie with vim, but constantly amazed.... + +</pre></tip> </html> <Tip category="KVim"> <html><center>Automatically +update your diff upon writing.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=149">http://vim.sf.net/tip_view.php?tip_id=149</A><BR> + +When trying to reconcile differences between files, and using the new 'diff' +functionality in Vim 6.0 you may want to automatically update the differences +as you are working along. A convienent time is when you write out either of +the files you are diff'ing. This autocmd will take care of doing that for you. + +" If doing a diff. Upon writing changes to file, automatically update the + " differences au BufWritePost * if &diff == + 1 au BufWritePost * :diffupdate au BufWritePost + * endif + +</pre></tip> </html> <Tip category="KVim"> <html><center>Generating +a column of increasing numbers</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=150">http://vim.sf.net/tip_view.php?tip_id=150</A><BR> + +You can use the "Visual Incrementing" script from + + <A + HREF="http://www.erols.com/astronaut/vim/index.html#VimFuncs">http://www.erols.com/astronaut/vim/index.html#VimFuncs</A><BR> + +to convert a block of numbers selected via ctrl-v (visual block) into a +column of increasing integers. Select the column, press :I<CR>, and +the first line's number will be used as a starting value. Subsequent lines's +numbers will be incremented by one. + +If the ctrl-v block is "ragged right", which can happen when "$" is used to +select the right hand side, the block will have spaces appended as needed +to straighten it out. If the strlen of the count exceeds the visual-block +allotment of spaces, then additional spaces will be inserted. + +Example: Put cursor on topmost zero, select column with ctrl-v, then :I + + vector[0]= 1; vector[0]= 1; vector[0]= 1; vector[1]= 1; + vector[0]= 1; --> vector[2]= 1; vector[0]= 1; vector[3]= 1; + vector[0]= 1; vector[4]= 1; + +This script works with both vim 5.7 (:so visincr.vim) or vim 6.0 (source it +as for vim 5.7 or drop it into the .vim/plugin directory). + +</pre></tip> </html> <Tip category="KVim"> +<html><center>an ascii table</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=151">http://vim.sf.net/tip_view.php?tip_id=151</A><BR> + +There is an ascii table in the vim-help files, but it's hard to find. Thus, +I shall give a pointer to it: + +:help digraph-table + +</pre></tip> </html> <Tip category="KVim"> <html><center>Dutch, +English, German, Hungarian, and Yiddish</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=152">http://vim.sf.net/tip_view.php?tip_id=152</A><BR> + +Under <A +HREF="http://www.erols.com/astronaut/vim/index.html#vimlinks_scripts">http://www.erols.com/astronaut/vim/index.html#vimlinks_scripts</A><BR> +are links to spelling checkers for Dutch, English, German, Hungarian, +and Yiddish, all based on the original engspchk.vim. The spelling checker +provides as-you-type spell checking; with vim6.0 it will avoid checking on +partially typed words. + +Provided are several maps: + + \et : add word under cursor into database for just this file \es : save + word under cursor into database (permanently) \en : move cursor to the + next spelling error \ep : move cursor to the previous spelling error + \ea : look for alternative spellings of word under cursor + +To use \ea you will need agrep: + + agrep source: <A + HREF="ftp://sunsite.unc.edu/pub/Linux/utils/text/agrep-2.04.tar.Z">ftp://sunsite.unc.edu/pub/Linux/utils/text/agrep-2.04.tar.Z</A><BR> + agrep Win exe: <A + HREF="http://www.tgries.de/agrep">http://www.tgries.de/agrep</A><BR> + +To use the spell checkers just source it in: + + ex. so engspchk.vim + +To read more about it see + + <A + HREF="http://www.erols.com/astronaut/vim/index.html#Spelling">http://www.erols.com/astronaut/vim/index.html#Spelling</A><BR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>Making +Parenthesis And Brackets Handling Easier</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=153">http://vim.sf.net/tip_view.php?tip_id=153</A><BR> + +1) ++++++++++++++++++++++++++ "Automatic" bracket setting ++++++++++++++++++++++++++++++ 2) +++++++++++++ Further improvement of +parenthesis/bracket expanding +++++++++++++++++ 3) ++++++++++++++++++++++++++++ +"Late" bracketing of text +++++++++++++++++++++++++++++ 4) ++++++++++++++++++++++++++++++ Conclusion ++++++++++++++++++++++++++++++++++++++ +++++ + +======================================================================================= + +1) ++++++++++++++++++++++++++ "Automatic" bracket setting ++++++++++++++++++++++++++++++ + +To automatically insert a closing parenthesis when typing an opening +parenthesis you can insert the following simple mapping to your vimrc: + + :inoremap ( ()<ESC>i + +This ends up with the cursor between the opening and the closing parenthesis +in insert mode. + +You can apply this and the following tips, of course, with the kind of +parenthesis/bracket character you want to, i.e. (, {, [, < ..... and, +pretty useful as well, quotation marks ",',.... (to be continued) + +2) +++++++++++++++ Further improvement of parenthesis/bracket expanding +++++++++++++++++++ + +I you are ready with filling the parenthesis/brackets, you likely want to +"escape" from the brackets again to continue coding. To make this pretty +comfortable, I invented the following kind of mappings, which get out of +the last expanded parenthesis/bracket, regardless of the actual type of it, +and enter append mode again. I mapped this kind of "getaway" with CTRL_j, +you may use your favorite keystroke with it. + + ... + :inoremap ( ()<ESC>:let leavechar=")"<CR>i :inoremap [ + []<ESC>:let leavechar="]"<CR>i + ... + :imap <C-j> <ESC>:exec "normal f" . leavechar<CR>a + +Explanation: The variable "leavechar" contents the actual char which is to +"escape" from. + +3) ++++++++++++++++++++++++++++ "Late" bracketing of text ++++++++++++++++++++++++++++++ + +Occasionally I later want already written text parts to put in parenthesis. + +I use the following macro, which brackets previously visually selected text. +I mapped it with _(. + + :vnoremap _( <ESC>`>a)<ESC>`<i(<ESC> + +Furthermore, a sort of mapping for bracketing a *single word* is conceivable. +Because this is not as general like the kind of visual mode mapping, I use +this kind of "word bracketing" only for surrounding the word right behind +the cursor in insert mode with **. I use the following macro to "emphasize" +the word i just typed, for newsgroup articles. + + :imap _* <Esc>bi*<Esc>ea*<Space> + +4) ++++++++++++++++++++++++++++++ Conclusion +++++++++++++++++++++++++++++++++++++++++++ + +Since I use these macros, I never caused a syntax error because of missing +brackets, and furthermore I can quickly insert parenthesis and qutotes into +code- and non-code files. + + JH 04.11.2001 + +</pre></tip> </html> <Tip category="KVim"> <html><center>Mappings +to facilitate the creation of text</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=154">http://vim.sf.net/tip_view.php?tip_id=154</A><BR> + +" " Mappings to facilitate the creation of text " " Author: Suresh Govindachar +sgovindachar@yahoo.com " Date: November 5, 2001 " " While typing text to +create a document, I often end up hitting " <Esc>, issuing some commands +(with or without ":") and getting back " to typing by issuing a command such +as "i", "O", "s" etc. " " I looked into using "set insertmode" to speed +up such actions, but " found that too confusing. " " I have come up with +a set of mappings that have speeded up my process " of creating documents. +I have saved these mappings in a file, named " FullScreenVI.vim, in vim's +plugin directory. " " Perhaps you will find these mappings helpful too. +" " Please send me feedback. " + +"To allow overriding the Alt key set winaltkeys=no "To enable viewing messages +from commands issued using the mappings presented here set cmdheight=2 + +"The fundamental mapping that makes full-screen editing possible imap +<A-o> <C-o> imap <A-;> <C-o>: + +"Basic motions imap <A-h> <Left> imap <A-j> <Down> +imap <A-k> <Up> imap <A-l> <Right> imap <A-f> +<PageDown> imap <A-b> <PageUp> imap <A-^> +<Home> imap <A-$> <End> + +"Numbers for repeats imap <A-1> <C-o>1 imap <A-2> +<C-o>2 imap <A-3> <C-o>3 imap <A-4> <C-o>4 +imap <A-5> <C-o>5 imap <A-6> <C-o>6 imap <A-7> +<C-o>7 imap <A-8> <C-o>8 imap <A-9> <C-o>9 + +"Basic searches imap <A-/> <C-o>/ imap <A-*> <C-o>* +imap <A-#> <C-o># imap <A-n> <C-o>n imap <A-N> +<C-o>N + +"Deleting imap <A-x> <C-o>x imap <A-d> <C-o>d imap +<A-D> <C-o>D + +"Yanking and putting imap <A-y> <C-o>y imap <A-Y> +<C-o>Y imap <A-p> <C-o>p imap <A-P> <C-o>P + +"Common prefixes: marking, matching etc. imap <A-~> <C-o>~ +imap <A-m> <C-o>m imap <A-`> <C-o>` imap <A-"> +<C-o>" imap <A-%> <C-o>% imap <A-h> <C-o>:h +imap <A-s> <C-o>:s + +"Interacting with the 'outside' imap <A-!> <C-o>:! imap +<A-w> <C-o>:w<CR> imap <A-e> <C-o>:e + +"Other commands imap <A-u> <C-o>u imap <A-.> <C-o>. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Decompile +Java .class files automatically</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=155">http://vim.sf.net/tip_view.php?tip_id=155</A><BR> + +Here's a plugin to automatically decompile Java .class files as they're +read in. Tweak the javap flags for what you want to see. I didn't post +this as a script because it's too simple and it's really more useful for +demonstrating how to read decompilable files (or other binary files that +can be converted to text). + +function s:ReadClass(dir, classname) + execute "cd " . a:dir execute "0read !javap -c " . a:classname 1 setlocal + readonly setlocal nomodified +endfunction + +autocmd BufReadCmd *.class + \ call <SID>ReadClass(expand("<afile>:p:h"), + expand("<afile>:t:r")) + +</pre></tip> </html> <Tip category="KVim"> <html><center>describe +<table name> from vim</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=156">http://vim.sf.net/tip_view.php?tip_id=156</A><BR> + +i had some trouble with the sqlplus scripts (probably my fault). but it +seemed a little heavy for what i need, usually all i want is a listing of +the columns for a given table while i'm whipping on some sql inside vim. + +so i wrote a bash script (describe)... + +~~~~~~~~~~~~~~~begin describe script #!/usr/bin/bash + +f=aTempFile.sql u=<uName> p=<pWord> d=<dBase> + +echo "/* describe for $1" echo "describe $1;" > $f; echo "quit;" +>> $f; + +sqlplus -S $u/$p@$d @$f rm -f $f; echo " end describe for $1 */" +~~~~~~~~~~~~~~~end describe script + +your path needs to include the script (as well as sqlplus), then from vim +you can just type.... + +:r !describe <tableName> + +and you get a listing of the table columns slammed into wherever your cursor +was, complete with java/c comments + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Incredible new functionality</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=157">http://vim.sf.net/tip_view.php?tip_id=157</A><BR> + +if you get away from vim and get any other editor that was built *after* +1970.... + +</pre></tip> </html> <Tip category="KVim"> <html><center>Using +Computer Modern TT as gvim font (Win32)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=158">http://vim.sf.net/tip_view.php?tip_id=158</A><BR> + +If you really like the Computer Modern typewriter font (as seen in most TeX +distributions) you can use it as the font in gvim! (looks excellent with +font smoothing turned on) + +First, get hold of the free Blue Sky Type 1 PS versions of the CM fonts from +your local CTAN mirror. Unpack to a suitable directory. + +Next locate the cmtt8.pfb file and open it (in Vim, naturally ;) - find the +line saying dup 32 /visiblespace put + +and change it to dup 32 /space put + +that is, inserting enough spaces to keep the file size exactly the same +(IMPORTANT!) + +Save the file in Mac format (:set fileformat=mac). + +Now install the cmtt.pfm file - in Win9x/NT4, you'll need Adobe Type Manager +(free download), but in Win2k, you can just drop the .pfm file into the +Fonts folder. + +Now in your _gvimrc: set guifont=CMTT8:h11:cSYMBOL + +(use whatever height you like instead of h11) + +..and enjoy! It's the first scalable font I can bear to edit code in... %-) + +</pre></tip> </html> <Tip category="KVim"> <html><center>Keystroke +Saving Substituting and Searching</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=159">http://vim.sf.net/tip_view.php?tip_id=159</A><BR> + +1) ++++++++++++++ Saving Keystrokes for common Searching +and Substituting +++++++++++ --- a) Searching b) Substituting +--------------------------------------------------- 2) ++++ Searching for +resp. Substituting of the current word under the cursor ++++++ --- a) Searching +b) Substituting --------------------------------------------------- +3) ++ Searching and Substituting for an arbitrary visually +selected part of text ++++ --- a) Searching b) Substituting +--------------------------------------------------- +4) ++++++++++++++++++++++++++++++++ Conclusion ++++++++++++++++++++++++++++++++++++++ + +===================================================================================== + +1) ++++++++++++++ Saving Keystrokes for common Substituting and Searching ++++++++++++ + +a) Searching ............ Sorry, there is not much that can be saved for +common Searching. It's just hitting /mypattern<RETURN> + +b) Substituting ......... I think, common substitution requires pretty many +keystrokes. So I use the following macro with my favorite substitution options: + +:map <F4> :%s//gc<Left><Left><Left> + +This ends up with the cursor after the first '/' in the +commandline. To complete it, you only have to enter -> +myoldpattern/mynewpattern<RETURN> + +Remark: I mapped it to <F4> (cause of tribute to the <F4> of +the good old Norton Commander editor). You may map it where you want to. + +2) ++++ Searching for resp. Substituting of the current word under the +cursor ++++++ + +a) Searching ............ If you don't know how to look for the next +occurence of the word under the cursor, you should *now* type :help * or +:help star or refer to the tips vimtip #1 or vimtip #5 ((Tip within tip: +To make your pattern more visible, look for :help hls)) + +b) Substituting ......... The following macro extends the one above with +automatically inserting the current word under the cursor into the from - +pattern of the :s command. + +:map <S-F4> +:%s/<C-r><C-w>//gc<Left><Left><Left> + +To complete it, just enter -> mynewpattern<RETURN> + +I use this i.e. for reliable and quickly renaming a variable in the entire +buffer. I mapped it to Shift-<F4>. You may map it to the keystroke +you want. + +Explanation: CTRL-v+CTRL-w expands to the word under the cursor. + +3) ++ Searching and Substituting for an arbitrary visually selected part of +text ++++ + +If you want to look or substitute (for) an *arbritary* pattern (which +already exists at least once in your text), the following 2 mappings do it +for you. The advantage is that you dont have to type again or cut & paste +the appropriate text but only have to visually select it. + +a) Searching ........... + +:vmap / y:execute "/".escape(@",'[]/\.*')<CR> + +This immediately finds to the next occurence of the previously visually +selected text. + +b) Substituting ......... + +:vmap <F4> y:execute +"%s/".escape(@",'[]/\')."//gc"<Left><Left><Left><Left> + +Again, as in the mapping in chapter 2), you just have to complete it by +entering -> mynewpattern<RETURN> + +Explanation/Discussion: What both Substituting and Searching in this way +generally does is: - *y*anking the selected text - Inserting the visually +selected via adressing the '"' register with '@"' as a + parameter of the escape() function going finally into the 'myoldpattern' + part. The trickery problem is, if you have characters in your myoldpattern, + which are regular expression chars, they are recognized and threated + accordingly. That is most likely not what you wanted. To escape them, these + chars have to be declared by the second parameter of the excape() function, + which then escapes them with a backslash. The few characters above work + for me. If you run into problems, you should check for additional regexp + chars in your text, and try to escape them by adding them to the escape() + function parameter. + +4) ++++++++++++++++++++++++++++++++ Conclusion ++++++++++++++++++++++++++++++++++++++ + +With the appropriate mappings in your vimrc you can save keystrokes when +Searching or Substituting and avoid typing errors. That way, you can take +lunch sooner + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Dutch spelling checker</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=161">http://vim.sf.net/tip_view.php?tip_id=161</A><BR> + +Download at <A +HREF="http://www.thomer.com/thomer/vi/nlspchk.vim.gz.">http://www.thomer.com/thomer/vi/nlspchk.vim.gz.</A><BR> + +This sciript is based on Charles E. Campbell's English spelling checker script +for ViM (<A HREF="http://users.erols.com/astronaut/vim/) and Piet Tutelaers' +Dutch word list (http://www.ntg.nl/spell-nl-v5b/) using Thomas Khler's +script (http://jeanluc-picard.de/vim/gerspchk/create). In other words, I +didn't do much.">http://users.erols.com/astronaut/vim/) and Piet Tutelaers' +Dutch word list (http://www.ntg.nl/spell-nl-v5b/) using Thomas Khler's +script (http://jeanluc-picard.de/vim/gerspchk/create). In other words, +I didn't do much.</A><BR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>write +plugin with explorer like interfaces</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=162">http://vim.sf.net/tip_view.php?tip_id=162</A><BR> + +Several plugins use a text base interface based on a special buffer, this +is the case of the standard explorer plugin, several bufexplorer plugins, +the option buffer and others... Here is a quick guide in how to do this + +Writing a special buf script + | using a special buffer is a common technic when writing + Vim scripts, it is used by | explorer, bufexplorer, + DirDiff... | I'm currently writing one for TagsBase.vim | <A + HREF="http://vim.sourceforge.net/scripts/script.php?script_id=100 + ">http://vim.sourceforge.net/scripts/script.php?script_id=100 </A><BR> + | and I'll use this document to take notes on how to do it. | + +Setting up the buffer + Opening the window TODO + + Using a setup function + Principle + | we can use a specific function to open and setup + the special buffer. s:SetupBuf() + Setup Function advantage + | since the command will be defined in the main + script you | can use script local functions + Using a special filetype + Principle + | we can also use a new filetype and distribute a + syntax and an ftplugin for this | filetype, the only + thing needed in this case is to set the | filetype + after creating the buffer + Filetype advantage + | better separations of different parts of your + script. If | the main function of your plugin is + not to have this | special buffer then it is nice + to avoid clutering it. + Things which needs to be done to setup the buffer + The buffer should not be listed and does not correspond to + a file + * setlocal buftype=nofile - options always local + to buffer * set nobuflisted * set bufhidden=delete * + set nomodifiable + Setup the syntax for this buffer + | see :help syntax | This is usually done in two + steps, first describe the | syntax groups using :syn + commands then setup the | hilighting using :hi def + link commands. Usually it is | best to link the + newly defined groups to predefine ones in | order + to make the coloring work fine with colorschemes. + | You'll find the list of predefined group by doing: + | :help group-name + Setup the special mappings + | since we have chosen to use the set nomodifiable + option | our buffer will never be in insert mode. All + our mapping | are in Normal, Visual or operator + pending, they should | therefore use the map, nmap, + vmap and omap mapping command | plus the associated + 'nore' version. I usually find it | better to use the + 'nore' version to avoid surprises due to | mapping + in the user configuration. | | We also want our + mappings to be local to the special | buffer so all + the commands will use the <buffer> modifier. + | | Finally we want our mappings not to polute the + status bar | so we use the <silent> modifier | + | Putting all this together we end up with mapping + commands | which look like: | noremap <buffer> + <silent> {lhs} {rhs} + Setup the special command + | we will then setup special commands for this buffer. + Like | for the mapping there are some precautions to + take: | we don't want an error message if the command + is defined | twice so we use the command! variant. | + We want a command local to our buffer wo we use the | + -buffer attribute. The rests of the command attributes + | and options depend on the actual command. | So + our commands look like: | command! -buffer {attr} + {cmd} {rep} | where attr is optional. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Toggle Search Highlighting</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=163">http://vim.sf.net/tip_view.php?tip_id=163</A><BR> + +" Map H to toggle search highlighting map H :let &hlsearch = +!&hlsearch<CR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>Make +non-ASCII characters displayed on console</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=164">http://vim.sf.net/tip_view.php?tip_id=164</A><BR> + +I had a problem with VIM on the FreeBSD console: it didn't display characters +like German umlauts correctly, but escaped them with a tilde. The solution +is to teach VIM about printable characters. I use the following on my .vimrc: + +set isprint=@,128-255 + +</pre></tip> </html> <Tip category="KVim"> <html><center>Deleting +a buffer without closing the window</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=165">http://vim.sf.net/tip_view.php?tip_id=165</A><BR> + +I'm not sure if this functionality is already within Vim, but I sometimes I +find it useful to keep a split window from closing when deleting a buffer. +This has already been discussed on the vim@vim.org mailing list. However, +I feel this solution is a little easier to use. + +" Put this into .vimrc or make it a plugin. " Mapping :Bclose to some +keystroke would probably be more useful. " I like the way buflisted() +behaves, but some may like the behavior " of other buffer testing functions. + +command! Bclose call <SID>BufcloseCloseIt() + +function! <SID>BufcloseCloseIt() + let l:currentBufNum = bufnr("%") let l:alternateBufNum = bufnr("#") + + if buflisted(l:alternateBufNum) + buffer # + else + bnext + endif + + if bufnr("%") == l:currentBufNum + new + endif + + if buflisted(l:currentBufNum) + execute("bdelete ".l:currentBufNum) + endif +endfunction + +</pre></tip> </html> <Tip category="KVim"> <html><center>Mapping +caps lock to esc in XWindows</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=166">http://vim.sf.net/tip_view.php?tip_id=166</A><BR> + +(This originally appeared on the vim mailing list as post by Adam Monsen <A +HREF="http://groups.yahoo.com/group/vim/message/19856)">http://groups.yahoo.com/group/vim/message/19856)</A><BR> + +If you want to completely swap caps lock and escape, you have to replace +the "Lock" on caps lock. Drop this file in your home dir:<br> +-----------start------------<br> ! Swap caps lock and escape<br> +remove Lock = Caps_Lock<br> keysym Escape = Caps_Lock<br> +keysym Caps_Lock = Escape<br> add Lock = Caps_Lock<br> +------------end-------------<br> and call it ".speedswapper". Then +open a terminal and type<br> $ xmodmap .speedswapper<br> +and you'll be twice as efficient in vim. Who needs caps lock anyway? The +swapping lasts for the duration of the X session, so you can put it in a +.xinitrc or similar startup file. As far as other people using my laptop, +I'd rather they didn't! Using a Dvorak layout might protect me even more... :) + +</pre></tip> </html> <Tip category="KVim"> <html><center>Using +vim as a man-page viewer under Unix</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=167">http://vim.sf.net/tip_view.php?tip_id=167</A><BR> + +To use vim as a man-page viewer involves setting an environment variable: + + sh, ksh: export MANPAGER="col -b | view -c 'set ft=man nomod nolist' + -" csh : setenv MANPAGER "col -b | view -c 'set ft=man nomod nolist' -" + +Put one of the above two lines into your <.profile> or <.login> +file as appropriate for your shell. + +The man pages will then be displayed with vim called as "view" and +will use the <man.vim> syntax highlighting. I myself use some +additional highlighting which is enabled by putting the following file into +<.vim/after/syntax/man.vim>. I usually use the <astronaut> +colorscheme (also available from this archive); those who use bright +backgrounds may find the colors selected for manSubSectionStart and +manSubSection something they'll want to change: + + --------------------------------------------------------------------- +" DrChip's additional <man.vim> stuff + +syn match manSectionHeading "^\s\+[0-9]\+\.[0-9.]*\s\+[A-Z].*$" +contains=manSectionNumber syn match manSectionNumber +"^\s\+[0-9]\+\.[0-9]*" contained syn region manDQString +start='[^a-zA-Z"]"[^", )]'lc=1 end='"' contains=manSQString +syn region manSQString start="[ \t]'[^', )]"lc=1 end="'" +syn region manSQString start="^'[^', )]"lc=1 end="'" +syn region manBQString start="[^a-zA-Z`]`[^`, )]"lc=1 end="[`']" +syn region manBQSQString start="``[^),']" end="''" +syn match manBulletZone transparent "^\s\+o\s" contains=manBullet +syn case match syn keyword manBullet contained o syn match manBullet +contained "\[+*]" syn match manSubSectionStart "^\*" skipwhite +nextgroup=manSubSection syn match manSubSection ".*$" contained + +hi link manSectionNumber Number hi link manDQString String hi +link manSQString String hi link manBQString String hi +link manBQSQString String hi link manBullet Special hi +manSubSectionStart term=NONE cterm=NONE gui=NONE ctermfg=black +ctermbg=black guifg=navyblue guibg=navyblue hi manSubSection +term=underline cterm=underline gui=underline ctermfg=green guifg=green set ts=8 + --------------------------------------------------------------------- + + +</pre></tip> </html> <Tip category="KVim"> <html><center>Viewing +the actual XPM data in GVIM</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=168">http://vim.sf.net/tip_view.php?tip_id=168</A><BR> + +GVIM has an excellent syntax highlighting for XPM images, but sometimes +it's useful to view the actual data. This can be achieved by searching for +everything, type in "/." and all characters will be highlighted and therefore +the old colouring is lost. To regain the normal highlighting you can search +for a non-existent sequence, like "/foo". + +</pre></tip> </html> <Tip category="KVim"> <html><center><Tab> += <C-I> and <Esc> = <C-[></center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=169">http://vim.sf.net/tip_view.php?tip_id=169</A><BR> + + An FAQ on the vim users' mailing list is whether <Tab> and + <C-I> +can be mapped to different things. The answer is no. As I understand it, +this is a low level issue: <Tab> and <C-I> are different names +for the same ASCII code, and there is no way for vim to tell them apart. +Similarly, <Esc> and <C-[> are the same thing. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Repeating +a sequence of commands without defining a macro</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=170">http://vim.sf.net/tip_view.php?tip_id=170</A><BR> + +Imagine. + +You have just finished a complicated modification of a file, involving +numerous replace commands :%s/xxx/yyyy/g, and other ex commands. + +Then you realize, you have done it a little bit wrong, and you have to begin +all the operation again, just to change one replace string, or do one more +operation "somewhere 10 commands ago". + +Or you realize, you will have to do the same stuff tomorrow with another file. + +or you realize, you want to perform the same sequence of commands, you have +typed a few days ago + +You should have made it a macro (normal command q), but you haven't. + +Nothing is lost yet. + +You go to the command line (by typing :) and press Ctrl+F. (Ctrl+F in other +modes scrolls the screen) + +You get a temporary window, listing the history of command line. +It is possible to yank appropriate lines here, make a new file called +$VIMRUNTIME/macros/something.vim put those lines here, edit them and save + +see :help cedit + +Then you can call the macro using :source something.vim + +You might want to set variable 'history' to a higher number then default in +your vimrc file like :set history=300 see :help history :help vimrc + +</pre></tip> </html> <Tip category="KVim"> <html><center>Do +you know the "g/" and "g?" commands?</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=171">http://vim.sf.net/tip_view.php?tip_id=171</A><BR> + +Directly from the Vim Todo list: + +7 For Visual mode: Command to do a search for the string in the marked area. + Only when less than two lines. Use "g/" and "g?". + +In other words, a way to search for visually selected text !! :-) + +"==== vsearch.vim ==== + +" Visual mode search + +vmap g/ :call VsearchPatternSave()<cr>/<c-r>/<cr> vmap +g? :call VsearchPatternSave()<cr>?<c-r>/<cr> + +function! VsearchPatternSave() + let l:temp = @@ normal gvy let @/ = substitute(escape(@@, '/\'), "\n", + "\\\\n", "g") let @@ = l:temp unlet l:temp +endfunction + +"==== END ==== + +Normally, this file should reside in the plugins directory and be +automatically sourced. If not, you must manually source this file using +':source vsearch.vim'. + +In Visual mode, highlight the text for searching. Then you can use the +default visual key mappings + +g/ - search forwards g? - search backwards + +Visual searches behave like normal searches. The 'n' and 'N' commands +work as they should, and the search history correctly records each search. +Multi-line searches behave as they should (this corrects the 'yank-only' +method mentioned in the Vim help files). Block visual searches do not +work yet. Hopefully, someone can figure out a way to do this easily. + +I've only tested this on Win2000 and Redhat Linux 7.1. I'm not really clear +on how the carriage returns are dealt with on other systems. + +Anyway, enjoy! + +</pre></tip> </html> <Tip category="KVim"> <html><center>Using +Ispell on a highlighted region</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=172">http://vim.sf.net/tip_view.php?tip_id=172</A><BR> + +Suppose you would like to use Ispell to check a word or region that you've +visually highlighted. The following macro will do the job. Just type +Shift-Insert while in visual mode. + +vnoremap <S-Insert> <C-C>`<v`>s<Space><Esc>mq:e +ispell.tmp<CR>i<C-R>"<Esc>:w<CR>:! xterm +-bg ivory -fn 10x20 -e ispell %<CR><CR>:e +%<CR><CR>ggVG<Esc>`<v`>s<Esc>:bwipeout!<CR>:!rm +ispell.tmp*<CR>`q"_s<C-R>"<Esc> + +This is based on Chip Campbell's macro which uses Ispell on the whole file +(in normal mode). + +noremap <S-Insert> :w<CR>:! xterm -bg ivory -fn 10x20 -e ispell +%<CR><Space>:e %<CR><Space> + +Carl Mueller + +</pre></tip> </html> <Tip category="KVim"> <html><center>Switch +between splits very fast (for multi-file editing)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=173">http://vim.sf.net/tip_view.php?tip_id=173</A><BR> + +I am a Web developer and I use Vim as my primary editor. + +Most programming projects (and Web programming projects, in particular) +are spread out over multiple files, which you often want to have open +concurrently. If you don't already know, Vim supports this very well! Just use: + +:sp name-of-another-file-to-edit + +My problems were that (1) it took too long to move between files, and (2) +the files were taking up too much room on the screen. + +(1) In order to move to the file in the split above my current window, I was +typing Ctrl-W, Up (move up a window) Ctrl-W, _ (maximize the menu). That's +four keystrokes (more if you count Ctrl and Shift), and they are all over +the keyboard. To help avoid this problem, I created this mapping in my .vimrc: + +map <C-J> <C-W>j<C-W>_ map <C-K> +<C-W>k<C-W>_ + +Now I can hold down Ctrl and move between windows with the standard Vim +movement keys. Much, much quicker! + +(2) By default, Vim displays the current line of each minimized file, which +(to me) isn't much help and takes up too much screen real estate. I use this +line in my .vimrc: + +set wmh=0 + +This sets the minimum window height to 0, so you can stack many more files +before things get crowded. Vim will only display the filename. + +Hope this helps those of you who are working on projects with large numbers +of files you're constantly flipping through. Happy Vimming! + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Footnotes</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=174">http://vim.sf.net/tip_view.php?tip_id=174</A><BR> + +ab (1 +[1]<esc>:/^--\s/-1/<cr>o<insert><cr>Footnotes:<cr>----------<cr>[1] +ab (2 [2]<esc>:/^Footnotes\:/+2/<cr>o<insert>[2] +ab (3 [3]<esc>:/^Footnotes\:/+3/<cr>o<insert>[3] ab +(4 [4]<esc>:/^Footnotes\:/+4/<cr>o<insert>[4] ab (5 +[5]<esc>:/^Footnotes\:/+5/<cr>o<insert>[5] + +</pre></tip> </html> <Tip category="KVim"> <html><center>how to make +VIM as ur default editor even without root ac.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=175">http://vim.sf.net/tip_view.php?tip_id=175</A><BR> + +hi, if u have installed vim in your home directory somewhere and u don't have a +root account, and you want to make VIM the default editor for anything u do. +i.e if ur using SQLplus and want to edit a sql command. normally typing +edit brings up the vi editor and not vim editor. to solve this problem. +define these three variables in your .profile VIM=<base directory where +vim executable is placed> VIMRUNTIME=<base direcoty where vim runtimes +are kept> EDITOR=$VIM/vim + +note if u have installed vim with another name, say vim.exe then change +EDITOR=$VIM/vim to EDITOR=$VIM/vim.exe + +source the .profile and viola. next time u start an editor from any program +u have the vim editor. + +Njoy. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Autocheckout from perforce</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=176">http://vim.sf.net/tip_view.php?tip_id=176</A><BR> + +The following code automatically checks out files from perforce when the +user modifies them. It first confirms the check-out with the user. + +(Perforce is a commercial version control system. I imagine this could be +modified for RCS, CVS, etc., but I don't use those.) + +I'm a vim newbie -- I've used vi since 1984, but just started with vim a couple +days ago. Color me impressed! Please excuse any stupidity in the code.. + +Note that this function needs the "P4HOME" environment variable to be set. +I could extract it by invoking "p4 client", but I don't want to invoke p4 +every time I start vim. So I assume the user sets it in the environment. + +" Set a buffer-local variable to the perforce path, if this file is under +the perforce root. function IsUnderPerforce() + if exists("$P4HOME") + if expand("%:p") =~ ("^" . $P4HOME) + let b:p4path = substitute(expand("%:p"), $P4HOME, "//depot", "") + endif + endif +endfunction " Confirm with the user, then checkout a file from perforce. +function P4Checkout() + if exists("b:p4path") + if (confirm("Checkout from Perforce?", "&Yes\n&No", 1) == 1) + call system("p4 edit " . b:p4path . " > /dev/null") if + v:shell_error == 0 + set noreadonly + endif + endif + endif +endfunction + +if !exists("au_p4_cmd") + let au_p4_cmd=1 + + au BufEnter * call IsUnderPerforce() au FileChangedRO * call P4Checkout() +endif + +</pre></tip> </html> <Tip category="KVim"> <html><center>Highlight +matching brackets as one moves in normal mode (plugin)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=177">http://vim.sf.net/tip_view.php?tip_id=177</A><BR> + +Check out <A HREF="http://www.erols.com/astronaut/vim/index.html#VimFuncs +for">http://www.erols.com/astronaut/vim/index.html#VimFuncs for</A><BR> +a plugin script which highlights matching brackets. The script has two +always-on maps: + \[i : start [HiMtchBrkt] mode \[s : stop [HiMtchBrkt] mode +The plugin will save all user maps and options that the plugin uses and will +restore them when the mode is stopped. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Making +a "derived" colorscheme without copy & paste</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=178">http://vim.sf.net/tip_view.php?tip_id=178</A><BR> + +Suppose there's a colorscheme that you're pretty fond of, but hate one or +two particular aspects about. For example, I love the "blue" colorscheme +that ships with vim, but I find it's colors for the non-active status line +to be unreadable. Here's how to create a colorscheme which extends "blue" +without copying it to a new file and editing it. + +In my ~/.vim/colors, I created a "my-blue.vim" file with these contents: + +"these lines are suggested to be at the top of every colorscheme hi clear +if exists("syntax_on") + syntax reset +endif + +"Load the 'base' colorscheme - the one you want to alter runtime +colors/blue.vim + +"Override the name of the base colorscheme with the name of this custom one +let g:colors_name = "my-blue" + +"Clear the colors for any items that you don't like hi clear StatusLine hi +clear StatusLineNC + +"Set up your new & improved colors hi StatusLine guifg=black guibg=white hi +StatusLineNC guifg=LightCyan guibg=blue gui=bold + +That's all there is to it. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Simplify help buffer navigation</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=179">http://vim.sf.net/tip_view.php?tip_id=179</A><BR> + +Vim is distributed with comprehensive help system, which has basic hyperlink +support - you can press <C-]> over |some subject| or 'some option' +to read more about particular term. + +The following mappings simplify help buffer navigation: pressing s(or S) +will find next(previous) subject from cursor position pressing o(or O) will +find next(previous) option from cursor position pressing Enter will jump to +subject under cursor pressing Backspace will return from the last jump + +Put them into help filetype plugin (like ~/.vim/ftplugin/help.vim on UNIX). + +nmap <buffer> <CR> <C-]> nmap <buffer> <BS> +<C-T> nmap <buffer> o /'[a-z]\{2,\}'<CR> nmap <buffer> +O ?'[a-z]\{2,\}'<CR> nmap <buffer> s /\|\S\+\|<CR> nmap +<buffer> S ?\|\S\+\|<CR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>Reload +your filetype/syntax plugin</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=180">http://vim.sf.net/tip_view.php?tip_id=180</A><BR> + +Ever tried to write/debug your own filetype/syntax plugin? + +It's an iterative process which involves editing plugin code and testing it +on some sample file. To see changes you made in your plugin simply do :e +on sample file. This will force Vim to reload all buffer-specific files, +including your plugin. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>get the vim patched source</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=181">http://vim.sf.net/tip_view.php?tip_id=181</A><BR> + +Hi, there has been a number of person (including) asking in the vim list how +to keep up with Bram's incredible bug correction and patch writing skills, but +there is a great way to do this! Use the cvs source which is available at <A +HREF="http://sourceforge.net/cvs/?group_id=8">http://sourceforge.net/cvs/?group_id=8</A><BR> +it is kept up to date and its a lot easier than applying all the patch +in order. Benoit + +</pre></tip> </html> <Tip category="KVim"> <html><center>Keep +your cursor centered vertically on the screen</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=182">http://vim.sf.net/tip_view.php?tip_id=182</A><BR> + +i hope i don't hear a collective 'DUH!' from around the world but i just +did this and i think it's kinda cool. + +in your .vimrc add... + +map j jzz map k kzz + +so whenever you go up or down, vim does that and then re-centers. obviously it +doesn't work when you page up/ down. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Select +a buffer from those matching a pattern</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=183">http://vim.sf.net/tip_view.php?tip_id=183</A><BR> + +The :bu command will take a pattern as an argument and jump to the matching +buffer. However, it's not very helpful if there is more than one buffer +matching the pattern. In that case, it will jump to the first match, which +may not be what you want. The following function and user-command will +print a list of the matching buffers in the command-line area, and allow +you to select one of the matching buffers by number. + +"Select from buffers matching a certain pattern "the 'pattern' argument +shouldn't be prepended with a slash + +function! BufSel(pattern) + let bufcount = bufnr("$") let currbufnr = 1 while currbufnr <= bufcount + if(bufexists(currbufnr)) + let currbufname = bufname(currbufnr) if(match(currbufname, a:pattern) + > -1) + echo currbufnr . ": ". bufname(currbufnr) + endif + endif let currbufnr = currbufnr + 1 + endwhile let desiredbufnr = input("Enter buffer number: ") + if(strlen(desiredbufnr) != 0) + exe ":bu ". desiredbufnr + endif +endfunction + +"Bind the BufSel() function to a user-command command! -nargs=1 Bs :call +BufSel("<args>") + +</pre></tip> </html> <Tip category="KVim"> <html><center>How +to obscure text instantaneously</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=184">http://vim.sf.net/tip_view.php?tip_id=184</A><BR> + +Hi, Lets say your writing some imp. doc. and your colleague comes along. you +don't wan't him to see what you are typing. so u start fumbling to type +:wq! or switch with Alt-TAB. etc. but wouldn't it be nice to just obsucre the +text temporarily, so that u don't have to quit or swith to another application +using Alt-tab. (and if u don;t have any other window open u can;t even use +alt-tab) well rot-13 comes to help. vim has a built in rot-13 encoder. + +jut put the follwoing in your .vimrc + +map <F3> ggVGg? + +so next time some body comes along just press <F3> and all the buffer +will be rot-13 encoded. to decode just press <f3> again. Njoy + +</pre></tip> </html> <Tip category="KVim"> <html><center>Make vim the +editor for files with unregistered extensions in Windows</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=185">http://vim.sf.net/tip_view.php?tip_id=185</A><BR> + +Normally in Windows, if you try to "launch" a file whose extension is not +registered with the system, the OS will prompt you for what editor you would +like to use to open the file. A much more appealing solution, in my mind, +is to make vim the default editor for any unregistered extension. + +To set vim up as the default editor for unregistered extensions, follow +these steps: 1. Copy the following into a file named unregistered.reg +-------------begin unregistered.reg----------------- REGEDIT4 +[HKEY_CLASSES_ROOT\Unknown\shell\Open\Command] @="d:\\program +files\\vim\\vim60\\gvim.exe \"%1\"" -------------end +unregistered.reg----------------- + +2. Import unregistered into your registry. This can be done in vim by +executing the following :!regedit "unregistered.reg" + +Disclaimer: This has been tested only on NT4. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Making search powerful</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=186">http://vim.sf.net/tip_view.php?tip_id=186</A><BR> + +My tip is just a bunch of mappings that can be used while searching. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Making search powerful</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=187">http://vim.sf.net/tip_view.php?tip_id=187</A><BR> + +(Sorry, I think I accidentally added an incomplete tip) + +My tip is just a bunch of mappings that can be used while searching. +What it does? + o. Extend your current search. (kinda emacs search where you can search + each occurences + one by one and go back to the cursor position. + o. Scroll/position during mapping. o. Other miscellaneous stuffs ;) read on + +How to use? + o. copy and paste the mappings into a file o. open vim (like vim .profile) + o. :so <saved-file> o. start using the mappings + +Note: + In case these mappings dont work run like, 'vim -u NONE -U NONE -c + "so the-saved-file.vim"' + + Some of my mappings override the default vim bindings. (like Ctrl-A, + Ctrl-Q). I selected those because, I feel by taking those I can do all + the search stuff with my left hand. + + One thing I did not like with this is, I usually miss the "search hit + bottom" message. I could have handled that by complicating the current + mappings, but I preferred to make it simple + +Mappings Used / => regular forward search start ? => +regular backward search start Rest of the mappings are used during search +Ctrl-A => search again forward (In normal mode, search forward with +the word under cursor) Ctrl-Q => search again backward (in normal mode, +search backward with the word under cursor) Ctrl-X => restore cursor (use +at any point of time/during-any-operation mentioned during searching) Ctrl-F +=> search with the word under cursor Ctrl-G => incrementally add the +letters following the search pattern (in current line) Ctrl-T Ctrl-T => +search for the exact Ctrl-T Ctrl-Y => search partial (just strips \< +and \>) Ctrl-E => scroll up during searching Ctrl-Y => scroll down +during searching Ctrl-Z Ctrl-Z => position the cursor to mid of screen +(like zz in normal) Ctrl-Z Ctrl-A => position the cursor to top of screen +(like zt in normal) Ctrl-Z Ctrl-X => position the cursor to bottom of +screen (like zb in normal) + +Misc: Ctrl-K during search save the current matching line Ctrl-K in normal +mode pastes the saved line + +C mappings Ctrl-V Ctrl-G search for the global variable of the search +pattern/word under cursor Ctrl-V Ctrl-H search for the local variable of +the search pattern/word under cursor + +" --- cut n paste from here to end of document --- se nocp incsearch " core +mappings noremap / mg/ noremap ? mg? ounmap / ounmap ? noremap <C-A> +mg"gyiw/<C-R>g cnoremap <C-A> <CR>/<Up> cnoremap +<C-X> <CR>`g cnoremap <C-Q> <CR>?<Up> + +" extending current search mappings cnoremap <C-F> +<CR>yiw<BS>/<C-R>" cnoremap <C-G> +<CR>y/<Up>/e+1<CR><BS>/<C-R>=escape(@",'.*\/?')<CR> + +" miscellaneous: copy current line during search and later paste in NORMAL +mode cnoremap <C-K> <CR>"hyy?<Up><CR>/<Up> +noremap <C-K> "hp + +" exact/partial search mappings cnoremap <C-T><C-T> +<Home>\<<C-End>\> cnoremap <C-T><C-Y> +<Home><Del><Del><End><Del><Del> + +" C global/local variable search mappings noremap <C-V><C-G> +mgyiw<CR>gg/\<<C-R>"\> noremap <C-V><C-H> +mgyiw?^{<CR>/\<<C-R>"\> cnoremap <C-V><C-G> +<CR>yiwgg/\<<C-R>"\> cnoremap <C-V><C-H> +<CR>yiw?^{<CR>/\<<C-R>"\> + +" positioning/scrolling during search mappings cnoremap <C-E> +<CR>mt<C-E>`t<BS>/<Up> cnoremap <C-Y> +<CR><C-Y><BS>/<Up> cnoremap <C-Z><C-A> +<CR>zt<BS>/<Up> cnoremap <C-Z><C-X> +<CR>zb<BS>/<Up> cnoremap <C-Z><C-Z> +<CR>zz<BS>/<Up> + +" VISUAL mappings vnoremap / ymg/<C-R>=escape(@",'.*\/?')<CR> +vnoremap ? ymg?<C-R>=escape(@",'.*\/?')<CR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>Searching +for more than one word at the same time.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=188">http://vim.sf.net/tip_view.php?tip_id=188</A><BR> + +Did you know that with VIM u can search for more than one word with a single +command. say you want to search all occurances of "bill" or "ted", or "harry" +in a text. in normal mode do the following. /\(bill\)\|\(ted\)\|\(harry\) +<Enter> + +this will match all instances of either "bill", or "ted", or "harry" in your +text. the key is the \(\) and \| operators. \(\) group characters in a word +and \| is for ORing. + +this is so cool u can even use it for replacing text. to replace all +instances of "bill" or "ted" or "harry" with "greg" do the following +:%s/\(bill\)\|\(ted\)\|\(harry\)/greg/g <enter> (note :- if u have +set the option "gdefault" u don't need the "g" at the end of the above command) + +I don't know of any other editor which can do this, with so much ease. +Rock on VIM Njoy + +</pre></tip> </html> <Tip category="KVim"> <html><center>Make +Ctrl-Backspace delete previous word (like GTK inputs)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=189">http://vim.sf.net/tip_view.php?tip_id=189</A><BR> + +Stuff this into your ~/.gvimrc and then you'll be able to type +Control-Backspace to delete the previous word. I had gotten so used to +C-BS working a certain way in all my editors with a ceezy input area (like +mozilla/galeon, gabber, etc...), that I wanted the same behaviour when I +used gvim. + +" map control-backspace to delete the previous word :imap <C-BS> +<Esc>vBc + +Simple, I know, but reasonably useful. + +--Robert + +</pre></tip> </html> <Tip category="KVim"> <html><center>XP > +I-Explorer > HTML Editor < REG files</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=190">http://vim.sf.net/tip_view.php?tip_id=190</A><BR> + +The issue is permitting other programs, besides NOTEPAD, be the HTML editor +under Internet Explorer. (Adding "Edit" as a New Action in the publicly +exposed Files Types for HTM/L does NOT do the job.) + +Given below are two REG files for vim. Just cut 'em up where indicated. +They have been tested under Windows XP. + +-------------------------------------------------------CUT HERE--------------- +Windows Registry Editor Version 5.00 + +; GOAL: Set gvim as HTML editor in Internet Explorer 6.0 ; Vim version : +6.0 ; Windows version: XP ; EASY USAGE: name this file iex-vim60.reg and +double click on it ; Hard Usage: IMPORT this file using REGEDIT.EXE found +in c:\WINDOWS ; Last modified date : Dec 16, 2001 + +; gvim is expected in "C:\Program Files\Vim\vim60\gvim.exe" ; Be sure to +also reset Explorer>Tools>Internet Options>Programs + +; Microsoft documentation ; <A +HREF="http://msdn.microsoft.com/workshop/browser/configuration/clientreg/clientregistrylayout.asp">http://msdn.microsoft.com/workshop/browser/configuration/clientreg/clientregistrylayout.asp</A><BR> + +; Add Vim in the list of supported HTML editors +[HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim] + +[HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim\shell] + +[HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim\shell\edit] + +[HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim\shell\edit\command] @="\"C:\\Program +Files\\Vim\\vim60\\gvim.exe\" \"%1\"" + +; Do NOT add to .html, registry for .htm type suffices +;[HKEY_CLASSES_ROOT\.html\OpenWithList\Vim] + +;[HKEY_CLASSES_ROOT\.html\OpenWithList\Vim\shell] + +;[HKEY_CLASSES_ROOT\.html\OpenWithList\Vim\shell\edit] + +;[HKEY_CLASSES_ROOT\.html\OpenWithList\Vim\shell\edit\command] +;@="\"C:\\Program Files\\Vim\\vim60\\gvim.exe\" \"%1\"" + +; OPTIONAL: Within Internet Explorer "View Source" with gvim +; but prefer to use Edit button (got to add this) on Toolbar +;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor] + +;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source +Editor\Editor Name] ;@="C:\\Program Files\\Vim\\vim60\\gvim.exe" + +; ============================================= EOF + +-------------------------------------------------------CUT HERE--------------- +Windows Registry Editor Version 5.00 + +; GOAL: UNINSTALL gvim as HTML editor in Internet Explorer 6.0 ; Vim version : +6.0 ; Windows version: XP ; EASY USAGE: name this file iex-vim60-uninstall.reg +and double click on it ; Hard Usage: IMPORT this file using REGEDIT.EXE +found in c:\WINDOWS ; Last modified date : Dec 16, 2001 + +; gvim is expected in "C:\Program Files\Vim\vim60\gvim.exe" ; Be sure to +also reset Explorer>Tools>Internet Options>Programs + +; Microsoft documentation ; <A +HREF="http://msdn.microsoft.com/workshop/browser/configuration/clientreg/clientregistrylayout.asp">http://msdn.microsoft.com/workshop/browser/configuration/clientreg/clientregistrylayout.asp</A><BR> + +[-HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim] + +[-HKEY_CLASSES_ROOT\.html\OpenWithList\Vim] + +[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor] + +; ============================================= EOF +-------------------------------------------------------CUT HERE--------------- + +Happy Vimming... + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Transposing</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=191">http://vim.sf.net/tip_view.php?tip_id=191</A><BR> + +You can easily move lines with these maps using <C-Up> and <C-Down> +(only in GUI version :( ) (Works in normal, insert, and visual mode, but +you can't add a count to them) " Transposing lines nmap <C-Down> +:<C-u>move .+1<CR> nmap <C-Up> :<C-u>move .-2<CR> + +imap <C-Down> <C-o>:<C-u>move .+1<CR> imap <C-Up> +<C-o>:<C-u>move .-2<CR> + +vmap <C-Down> :move '>+1<CR>gv vmap <C-Up> :move +'<-2<CR>gv + +" Transpose chars (like Ctrl-T in emacs, shell...) imap <C-F> +<Esc>Xpa + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Latex Help for VIM</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=192">http://vim.sf.net/tip_view.php?tip_id=192</A><BR> + +LaTeX Help for aucTeX `translated' as vim help file. + +Installing + +:help add-local-help + +</pre></tip> </html> <Tip category="KVim"> <html><center>Insert +the current filename at cursor postion.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=193">http://vim.sf.net/tip_view.php?tip_id=193</A><BR> + +I found this one good for when I was starting to learn Java, it simply inserts +the current filename, at the cursor position, when you are in insert mode. +Honestly, its a mish-mash of some other tips I found here, but I thought it +might be useful. + +imap \fn <C-R>=expand("%:t:r")<CR> + +Enjoy! + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Inserting text in multiple lines</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=194">http://vim.sf.net/tip_view.php?tip_id=194</A><BR> + +Do you know the I key in visual-block mode? + +Suppose you have let a=2 let b=3 let c=4 + +You want to make these variables script-wise. Then you move to over a, hit +<C-v>, press jj and now press I. You will be in insert mode before a +Now enter s:<Esc>, and when you press <Esc>, b and c will have +the s: prefix too. See |v_b_I| + +Happy vimming! Gergely Kontra + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Switching between files</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=195">http://vim.sf.net/tip_view.php?tip_id=195</A><BR> + +When you edit multiple files, you often need to change windows. You can set +up vim in windows and gvim to switch between windows with the commonly used +Ctrl-Tab and Ctrl-Shift-Tab The mappings nmap <C-Tab> <C-w>w +nmap <C-S-Tab><C-w>W (They wrap around) See also |Ctrl-w| + +</pre></tip> </html> <Tip category="KVim"> <html><center>FileName +Completion in Shell Scripts</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=196">http://vim.sf.net/tip_view.php?tip_id=196</A><BR> + +In shell scripts, you often define environment variables for diff directory +names. i.e. JAVA_HOME=/opt/java/jdk1.4 PATH=/usr/local/bin:/bin.... + +Normally typing Ctrl-X Ctrl-F is used to complete FileName under cursor. +But this does not work if used on lines given above. This is because vim +treats "=" sign as a valid filename character. Since the actual possibility +of "=" being in any filename is very less, this char can be removed from +the list of valid filename char. + +set isfname-== + +putting the above line in .vimrc will remove "=" from the list of valid +filename chars. thus u can easyly complete filenames using <Ctrl-X> +<Ctrl-F> Njoy + +</pre></tip> </html> <Tip category="KVim"> <html><center>Open +file in already running vim from elsewhere</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=197">http://vim.sf.net/tip_view.php?tip_id=197</A><BR> + +If you want edit new file, and you want do it in alrady running vim, +instead of launching another instance, you may use --remote argument: + +gvim first_file gvim --remote +split first_file + +:he --remote It requires X windows (but works in terminal version of vim +there too) or MS windows and built-in client-server mechanism. If there are +several instances of vim already running, you may choose to which you talk +using --servername :help --servername + +</pre></tip> </html> <Tip category="KVim"> <html><center>Pasting +code with syntax coloring in emails</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=198">http://vim.sf.net/tip_view.php?tip_id=198</A><BR> + +When sending code snippets or diffs to your colleagues either for code review +or for something else as email, how nice and clear it will be if you can +paste it with the Vim syntax highlighting? I am sure they will be impressed +and feel much easier to read the code. It is also very easy and fast (once +you practice it) to do this. + +This probably works only on windows and requires you to use Internet Explorer +and an email client that understand RTF content coming from clipboard, such +as Outlook or Outlook Express. At least that would make the process faster. I +haven't tried on any other combination though. This is what you need to do: + +- Open the file containing the code/code snippet/diff etc. in gvim. If you +use dark background for GVim (like me), then I would suggest you to change +your color scheme temporarily to something else that has a white background +or just use the "-U NONE" as below: + + gvim -U NONE <file> + +- Convert the file into HTML by using the following command at the colon +prompt as below: + + :runtime syntax/2html.vim + +- The above step will open a new window with the HTML content in it. You might +want to just save it with the suggested name or write into a temporary file as: + + :w! c:/tmp/t.html + +- Open the IE browser window and open the above temp file "c:/tmp/t.html". +- Now you select all (press ^A) and copy it (^C). - You are ready to paste +it with syntax coloring in any application that accepts RTF content from +clipboard, including Outlook or Outlook Express mail composing window. + +</pre></tip> </html> <Tip category="KVim"> <html><center>maximize +window and return to previous split structure</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=199">http://vim.sf.net/tip_view.php?tip_id=199</A><BR> + +Say you have layed out a complex window split structure, and want to +temporarily open 1 window with max dimensions, but don't want to lose your +split structure. The following function and mappings let you toggle between +the split windows and on window maximized. The mappings prevent the default +behavior of calling :only and losing your finely tuned splits. + +Put this bit in your vimrc file, change mappings if you don't want to override +the defaults: + +nnoremap <C-W>O :call MaximizeToggle ()<CR> nnoremap <C-W>o +:call MaximizeToggle ()<CR> nnoremap <C-W><C-O> :call +MaximizeToggle ()<CR> + +function! MaximizeToggle() + if exists("s:maximize_session") + source s:maximize_session call delete(s:maximize_session) + unlet s:maximize_session let &hidden=s:maximize_hidden_save + unlet s:maximize_hidden_save + else + let s:maximize_hidden_save = &hidden let s:maximize_session = + tempname() set hidden mksession! s:maximize_session only + endif +endfunction + +</pre></tip> </html> <Tip category="KVim"> <html><center>Bouncing +Parentheses (during insertion)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=200">http://vim.sf.net/tip_view.php?tip_id=200</A><BR> + +When one is inserting parentheses some folks like to see the cursor bounce +off the matching parenthesis. To do that, put the following map into your +<.vimrc> file: + + inoremap ) )<c-o>%<c-o>:sleep + 500m<CR><c-o>%<c-o>a + +Adjust the time delay (its 500 milliseconds above) to suit your needs. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>The meaning of life</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=201">http://vim.sf.net/tip_view.php?tip_id=201</A><BR> + +Use this tip if you need to discover the meaning of life, the universe +and everything. + +Simply do: :h 42 + +</pre></tip> </html> <Tip category="KVim"> +<html><center>debugging window autocommands</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=202">http://vim.sf.net/tip_view.php?tip_id=202</A><BR> + +Don't know how people debug autocommands, but I just found out that you can +debug (at least) those that result due to window close by just doing a debug +quit, i.e., + +:debug quit + +Vim will let you step into the autocommands. Try it to believe. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Make make more helpful</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=203">http://vim.sf.net/tip_view.php?tip_id=203</A><BR> + +I find this a very useful command to use. Add the below 4 lines to your vimrc. +Then instead of "make" use "Make". + +" Command Make will call make and then cwindow which " opens a 3 line error +window if any errors are found. " if no errors, it closes any open cwindow. +:command -nargs=* Make make <args> | cwindow 3 + +</pre></tip> </html> <Tip category="KVim"> <html><center>Some +mappings for using cscope with vim.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=204">http://vim.sf.net/tip_view.php?tip_id=204</A><BR> + +These mappings can make using cscope a fun. You can copy the word under the +cursor in one window, and search for it from other window. + +" Copy and paste the word under cursor map <silent> <C-Space> +:let@m=expand("<cword>")<CR> + +" Use the C-Space word as the search criterion map <C-F6> :cscope +find s <C-R>=@m<CR><CR> map <C-F5> :cscope find +c <C-R>=@m<CR><CR> map <C-F7> :cscope find g +<C-R>=@m<CR><CR> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Computing a sum of numbers in vim</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=205">http://vim.sf.net/tip_view.php?tip_id=205</A><BR> + +"Sometimes you need to sum a some numbers in vim. There *are* some plugins +"that can do the job. But what if the numbers are not in a columns or are on +"the same line or are sacttered all across the file? You might also need to +"sum all the numbers in file that look like '1234$', or '54565 Eu' ignoring +others. " "There is a very simple trick, using (my favourite) command ":s " +"First you define following function + +:let g:S=0 "In global variable S we later find the result + +:function! Sum(number) "The function is defined with a '!', + "so it does not complain during debugging + "when you are redefining the function + :let g:S=g:S+a:number "we accumulate the result in global variable + S :return a:number "function returns the argument, so after a :s + "command the text remains the same +:endfunction + +"you can do issue those few commands from a command line, "or create a small +file and put it into your plugin directory, "or write those few commands +into a file end issue a command :so % + +"how to use this little function: "let's suppose you have a simple +column of numbers like " "10 "20 "30 " "you issue command like: :let S=0 +:%s/[0-9]\+/\=Sum(submatch(0))/ "the command finds the first number on the +line and adds it to the S " "the result is displayed :echo $S + +"!!!! don't forget to do :let g:S=0 "before use. + +"you can also use \zs and \ze atoms in a regular expression to "delimit the +number, so submatch(0) returns only a number and "the text remains unchanged +after 'substitute' + +"for starter on the wonderfull world of regular expressions see: :help +usr_27.txt + +"for the definition of the search pattern see :help :s :help pattern + +"for replacement strings begining with \= and special function submatch(0)see +:help sub-replace-special + +"for the *ultimate* guide through the world of regular expressions see book: +"Mastering Regular Expressions "Powerful Techniques for Perl and Other Tools +"by Jeffrey E.F. Friedl "from O'REILLY + +"the book does not write about vim, yet here you can learn that ":s command +is the most powerfull command you can find in a text editor. "(with the +possible exception of :global command) + +</pre></tip> </html> <Tip category="KVim"> <html><center>Highlight +doubled word errors in text</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=206">http://vim.sf.net/tip_view.php?tip_id=206</A><BR> + +An error I sometimes make while working on a LaTeX file is the repetition of +a word as in "the the". Most often, such doubled words come about through +a careless edit. Doubled words are hard to spot when the first word of the +doubled pair is the last word on one line, and the second word of the pair +is the the first word on the next line. There is an example of such an error +in the last sentence. Vim's syntax mechanism can be used to highlight doubled +words as an error. + +To obtain this highlighting for TeX and LaTeX files, place the following +two lines: + + syn match texDoubleWord "\c\<\(\a\+\)\_s\+\1\>" hi def link + texDoubleWord Error + +in a file called tex.vim in the directory that shows up last in your +runtimepath (:set runtimepath? to check). This will often be either +~/.vim/after/syntax/tex.vim or $VIM/vimfiles/after/syntax/tex.vim + +The same effect can be obtained for files of a different filetype, say html, +by putting the same lines in a file called html.vim in the same location. + +For more on the runtimepath, :he runtimepath. For more on syntax highlighting, +:he syntax + +</pre></tip> </html> <Tip category="KVim"> <html><center>editing +databases with Vim/Perl/DBI</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=207">http://vim.sf.net/tip_view.php?tip_id=207</A><BR> + +Perl's Data-Base-Independent (DBI) module provides programming language +level access to a lot of databases. + +Vim hosts an embedded Perl interpreter. So it is only a matter of some key +strokes to interactively issue DB commands from within Vim or to search, +edit, and replace database contents including retrieval and storage. Of course +"create table" scripts can be worked upon in Vim as well as storing recurring +patterns in Vim functions or Perl modules. + +Prerequisites: Vim needs to be compiled with Perl support enabled. See the +|if_perl.txt| manual page! The CPAN module DBI as well as an appropriate +database driver has to be installed with Perl in order to execute these +Vim commands: + +" connect to perl's dbi module: :perl use dbi; + +" connect to the database: :perl $dbh = dbi->connect( +"DBI:mysql:$DBNAME:$HOST",$USER,$PASSWORD, + { raiseerror => 1}); + +" perform a simple query: :perl $result = $dbh->selectall_arrayref("show +tables;"); + +" insert the list of tables into the current buffer's top: :perl +$curbuf->Append(0, map($_->[0], @{$result})); + +In MySql the command "show tables;" results in a list of table names. Inserted +into a Vim buffer this results in one line per table. + +You can find more on my web page <A +HREF="http://members.chello.at/intelliware/dbEdit">http://members.chello.at/intelliware/dbEdit</A><BR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>Alter +the display of buffers in the buffers menu</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=208">http://vim.sf.net/tip_view.php?tip_id=208</A><BR> + +If you use the buffers menu, here's where you can change how the buffernames +are displayed: + +menu.vim, function s:BMMunge + +OLD: let name2 = name2 . ' (' . a:bnum . ')' + +displays: + + .vimrc (1) menu.vim (2) + +NEW: let name2 = '&' . a:bnum . '. ' . name2 + +displays + + 1. .vimrc 2. menu.vim +(with the 1 and the 2 underlined) + +which is more useful, because you can (almost) always pick the buffer you +want with one keystroke, the buffernumber, until you get to buffer 10 anyway. + +Roger + +</pre></tip> </html> <Tip category="KVim"> +<html><center>backtracking your movements in a file</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=209">http://vim.sf.net/tip_view.php?tip_id=209</A><BR> + +If you are jumping from one line to another a lot. You may find the "Ctrl-o" +command handy. Usually u can set markers in a buffer to keep track of your +movements. but Ctrl-o makes it even easier. it takes you back sequentially +to all your previous cursor locations in a buffer. just press ctrl-o in +normal mode and u will go to your last cursor position. + +Njoy + +</pre></tip> </html> <Tip category="KVim"> +<html><center>compiling the actual file with gcc</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=210">http://vim.sf.net/tip_view.php?tip_id=210</A><BR> + +if you use set makeprg=gcc\ -o\ %<\ % in your .vimrc, and your actual +file is file.c, then :make will compile file.c with the output file. (gcc +file.c -o file). + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Rotate color themes</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=211">http://vim.sf.net/tip_view.php?tip_id=211</A><BR> + +This tip is for those who like to change their vim color themes pretty often. +I like different themes just for a change in my work environment. To achieve +this just add the following to your .vimrc or _vimrc file. + +let themeindex=0 function! RotateColorTheme() + let y = -1 while y == -1 + let colorstring = + "#blue.vim#elflord.vim#evening.vim#koehler.vim#murphy.vim#pablo.vim#ron.vim#" + let x = match(colorstring,"#",g:themeindex) let y = + match(colorstring,"#",x+1) let g:themeindex = x+1 ":echo x + y g:themeindex if y == -1 + let g:themeindex = 0 + else + let themestring = strpart(colorstring,x+1,y-x-1) + echo("Setting Theme to-> ".themestring) return + ":so $VIMRUNTIME/colors/".themestring + endif + endwhile +endfunction + +Change the value of colorstring above by changing the line let colorstring = +"#blue.vim#elflord.vim#evening.vim#koehler.vim#murphy.vim#pablo.vim#ron.vim#" +You can add your favorite color themes in this string so that you can rotate +between them. Just make sure that any string that you add is in between the # +as shown above. Just follow the format above and things will work. + +Then assign a key to roate the theme. map <F8> :execute +RotateColorTheme() + +Dunno if there are better ways to do the same. I just did a "help eval" +and wrote the above. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Setting +file attributes without reloading a buffer</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=212">http://vim.sf.net/tip_view.php?tip_id=212</A><BR> + +While creating scripts and others executable files with Vim it is needed to +set UNIX executable bit on the file. You can do this from inside Vim with +:!chmod a+x %. The % represents current buffer's filename. The problem is +that Vim will notice attribute changes and prompt you to reload a file. If +you do this, your undo history for the file will be lost. + +The following function facilitate changing executable attributes without +reloading a buffer. Thanks to Bram for the algorithm for this function. + +fun! SetExecutableBit() + let fname = expand("%:p") :checktime exec "au FileChangedShell + " . fname . " :echo" :silent !chmod a+x % :checktime exec + "au! FileChangedShell " . fname +endfun + +" Create an EX command that will call the function. command -nargs=0 Xbit +call SetExecutableBit() + +Now you can type :Xbit to make the file executable! + +</pre></tip> </html> <Tip category="KVim"> +<html><center>delet all lines containt TXT</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=213">http://vim.sf.net/tip_view.php?tip_id=213</A><BR> + +I needed this one when I was editing an ldif file: + +I needed to delete all lines containing "profile": + +:g/profile/d + +very handydandy + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Current buffer based menus</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=214">http://vim.sf.net/tip_view.php?tip_id=214</A><BR> + +If you have different menus for different filetypes, and you want to have +only the menu relevant to current buffer displayed, you can use this approach: + +in .vimrc: au BufEnter * if exists('b:BuffEnter')|exec b:BuffEnter|endif au +BufLeave * if exists('b:BuffEnter')|exec b:BuffLeave|endif + +In appropriate ftplugin/?.vim, there are assigned commands to create or +destroy the menus - here typed in directly, may be of course call to a +menu-generating function or whatever. + +let b:BuffEnter='amenu C.added ...' let b:BuffLeave='unmenu! C|unmenu C' + +</pre></tip> </html> <Tip category="KVim"> <html><center>Edit +configuration files for a filetype</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=215">http://vim.sf.net/tip_view.php?tip_id=215</A><BR> + +When you open a file, vim may load several scripts to customize itself for +editing the file type the file is associated with (for example a file "test.c" +is associated with the filetype "c"). Such configurations include the setting +of syntax highlighting colors (:help syntax) and support for indentation +(:help filetype-indent-on). When you start to override these files for +yourself, it can sometimes be confusing, which file sets a specific option. +The following function can be used, to edit the configuration files which +are associated with a specific filename. It open a buffer for all files which +get loaded. If I invoke it with ':call Edit_ft_conf("test.c")', for example, +I end up with the following buffers / windows: + 1 a "[No File]" line 1 2 a "test.c" + line 1 3 a= "/usr/local/share/vim/vim60/syntax/c.vim" + line 1 4 a "~/.vim/after/syntax/c.vim" line 1 5 #a= + "/usr/local/share/vim/vim60/indent/c.vim" line 1 6 %a= + "/usr/local/share/vim/vim60/ftplugin/c.vim" line 1 + +Here comes the function: + +" Edit filetype configuration files " Usage: ':call Edit_ft_conf("file")' +" Purpose: open all scripts which get loaded implicitly by opening "file" " +(syntax highlighting, indentation, filetype plugins, ..) " The order of +windows reflects the order of script loading (but "file" is " the topmost +window) fun! Edit_ft_conf(name) + " we may not do this with a loaded file, since this won't trigger the + " configuration file loading as desired. " try calling with 'call + Edit_ft_conf("nonexistingfile.<EXT>")' if this " gives you troubles + if bufexists(a:name) && bufloaded(a:name) + echo "!Attention: buffer for " . a:name . " is loaded, unload first." + return + endif " split-open the file with verbose set, grab the output into a + register " (without clobbering) let safereg = @u redir @u " redirect + command output to register @u exec "silent 2verbose split " . a:name + " verbose level 2 suffices to catch all scripts which get opened + redir END " Parse register @u, looking for smth like: + 'sourcing"/usr/local/share/vim/vim60/syntax/c.vim"' let pos = 0 let + regexp = 'sourcing "[^"]\+"' while match(@u,regexp,pos) >= 0 + let file = matchstr(@u,regexp,pos) let pos = matchend (@u,regexp,pos) + let file = strpart(file,10,strlen(file)-11) exec "silent below split + " . file + endwhile " restore the register let @u = safereg +endfun + +</pre></tip> </html> <Tip category="KVim"> <html><center>calculate +equations from within vim</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=216">http://vim.sf.net/tip_view.php?tip_id=216</A><BR> + +The following map and function calculates equations using the program 'bc' +(found on most linux systems, available for most systems). Visually select the +equation you want to calculate, then hit ;bc - if the selection ends with an +'=' sign, the answer will be appended after the equal, otherwise, the answer +is echoed as a message. The code to put in a vimrc and source is at the end. + +Equations can span multiple lines, and the full bc syntax is probably +supported. Additionally, sin (), cos (), etc, are transformed into the +names used by bc (s () c (), etc). + +Here are some example lines: + +2 * sqrt (2) = + +3 * (2 - 1) + 4.0 ^ 6 = + +4 / 3 = + +3 + + 4 - + 2 * (1 / (3 + 2)) = + +define rad (x) { + return (x / 180) * 4 * atan (1) +} cos (rad (45)) = + +Select each of these in turn (continguous non-blank lines, and hit ;bc for +each), and this is what you get: 2 * sqrt (2) = 2.82842712474619009760 + +3 * (2 - 1) + 4.0 ^ 6 = 4099.000000 + +4 / 3 = 1.33333333333333333333 + +3 + + 4 - + 2 * (1 / (3 + 2)) = 6.60000000000000000000 + +define rad (x) { + return (x / 180) * 4 * atan (1) +} cos (rad (45)) = .70710678118654752440 + +Fun, no? Here is the code you need to put in your vimrc file: + +vnoremap ;bc "ey:call CalcBC()<CR> function! CalcBC() + let has_equal = 0 + + " remove newlines and trailing spaces let @e = substitute (@e, "\n", + "", "g") let @e = substitute (@e, '\s*$', "", "g") + + " if we end with an equal, strip, and remember for output if @e =~ "=$" + let @e = substitute (@e, '=$', "", "") let has_equal = 1 + endif + + " sub common func names for bc equivalent let @e = substitute (@e, + '\csin\s*(', "s (", "") let @e = substitute (@e, '\ccos\s*(', "c + (", "") let @e = substitute (@e, '\catan\s*(', "a (", "") let @e = + substitute (@e, "\cln\s*(", "l (", "") + + " escape chars for shell let @e = escape (@e, '*()') + + " run bc, strip newline let answer = substitute (system ("echo " + . @e . " \| bc -l"), "\n", "", "") + + " append answer or echo if has_equal == 1 + normal `> exec "normal a" . answer + else + echo "answer = " . answer + endif +endfunction + +</pre></tip> </html> <Tip category="KVim"> <html><center>Translate +&#nnn; in html source to readable ascii</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=217">http://vim.sf.net/tip_view.php?tip_id=217</A><BR> + +I found a website *cough*Tivoli.com*cough* that likes to obfuscate some of +its help file web pages using &#nnn; instead of normal ascii. If you load +the source with Vim (in Opera you can just designate Vim as your source +viewing program), you can :so the following code to make it readable. + +let n = 32 while n < 127 + if n == 38 + silent! exec '%s/&/\&/g' + elseif n == 47 + silent! exec '%s///\//g' + else + silent! exec '%s/&#' . n . ';/' . nr2char(n) . '/g' + endif let n = n + 1 +endwhile + +Disclaimer: I hacked this together in about 10 minutes (or possibly longer :). +It worked suitably for the website I wrote it for (or possibly "against" :). +Your Milage May Vary. + +See :help eval, :help silent, :help exec, :help :s + +</pre></tip> </html> <Tip category="KVim"> <html><center>Check +for comments, independent of the filetype</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=218">http://vim.sf.net/tip_view.php?tip_id=218</A><BR> + +For some scripts it might be useful to detect, whether a specific position +in a buffer is inside of a comment or not. Syntax highlighting can save us +the work for parsing the comments ourselves. + +The command + :echo synIDattr(synIDtrans(synID(line("."), col("."), 0)), "name") +echoes the group used for *highlighting* the character at the current +cursor position, see ':help synIDtrans()'. It will usually be "Comment" +if the cursor is inside of a comment, so + synIDattr(synIDtrans(synID(line("."), col("."), 0)), "name") == "Comment" +detects, independent of the filetype (which have their own group 'names' +for comments), if the cursor is inside a comment or not. The expression + synIDattr(synIDtrans(synID(line("."), col("."), 0)), "name") =~ + 'Comment\|Constant\|PreProc' +will detect additionally, if the cursor is inside of a string or some +preprocessor statement. + +</pre></tip> </html> <Tip category="KVim"> <html><center>make +from command line, open vim on errors</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=219">http://vim.sf.net/tip_view.php?tip_id=219</A><BR> + +A simple alias (*csh) or shell function (bash) will let you run make from your +shell, then automatically open vim or gvim on the errors (if there were any): + +csh or tcsh: + +alias Make 'make \!* |& tee make.errors || gvim -q make.errors -c :copen' + +bash: + +Make () { command make "$@" |& tee make.errors || gvim -q make.errors -c +:copen ; } + +If you use vanilla sh or ksh or even cmd.exe, you can probably do the same - +add a not if you have ideas. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Match every word except 'foo'</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=220">http://vim.sf.net/tip_view.php?tip_id=220</A><BR> + +This is a regular expression that matches all words except 'foo' +\v<(foo>)@!\k+> + +\v Very magic < Start-of-word (Foo>) The +atom 'Foo' followed by end-of-word @! Match (with zero length) +when the previous atom doesn't match. \k+ Match one or more +Keywords > Match end-of-word. + +This is a kool example of using \@! in the middle of a regexp. The non-magic +version is: \<\(foo\>\)\@!\k\+\> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>indenting "throws" in java</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=221">http://vim.sf.net/tip_view.php?tip_id=221</A><BR> + +I want to indent java files like this: + + int x(int y, int z) + throws Exception + { + [...] return something; + } + +By default vim will properly indent "throws" line, but following "{" will +not be deindented back to the method declaration. + +The following indentexpr does the trick: let +&indentexpr='getline(v:lnum)=~"^\\s*{" && getline(v:lnum-1)=~"^\\s*throws\\s" +? cindent(v:lnum)-&sw : cindent(v:lnum)' + +It just checks that the current line starts with "{" and the previous line +starts with "throws" and if that is the case, it subtracts one shiftwidth +from the number returned by cindent. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Building vim with color on HP-UX</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=222">http://vim.sf.net/tip_view.php?tip_id=222</A><BR> + +Following the normal steps of running "./configure" and "make" to build vim +on an HP-UX 10.20 will result in vim being linked with the termlib library. +This library does not support certain termcap capability codes, such as the +"Co" code used to query the number of colors supported by the terminal. +Consequently, vim will not display colors when used with a color terminal +such as a color xterm. + +One solution to this is to run the configure script with the +"--with-tlib=curses" option, like this: + + ./configure --with-tlib=curses + +This will cause vim to be linked with the HP-UX curses library, which does +support the color termcap capability codes. + +Note that the xterm that comes standard with HP-UX 10.20 does not display color +character attributes. To see colors when running vim in a terminal window, +you will also need to install a color terminal emulator such as a recent xterm. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Reverse Selected Text</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=223">http://vim.sf.net/tip_view.php?tip_id=223</A><BR> + +Suppose you want to reverse some text - I don't know why you would want to - +maybe you're dyslexic. Anyway, I had a need, so this mapping will reverse +visually selected text. Put the mapping in your vimrc or otherwise source +it, then visually select the word or words, and hit ;rv - really only works +with selections on one line: + +vnoremap ;rv c<C-O>:set revins<cr><C-R>"<esc>:set +norevins<cr> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Shifting blocks visually</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=224">http://vim.sf.net/tip_view.php?tip_id=224</A><BR> + +I use the < and > commands on blocks a lot, and it has always annoyed me +that if you want to shift more than one 'shiftwidth', you have count how many +'shiftwidth's you want to enter the '[count]>', or restore the selection +with "gv". So I've cooked up two mappings that come in very handy: + +:vnoremap < <gv :vnoremap > >gv + +These mappings will reselect the block after shifting, so you'll just have +to select a block, press < or > as many times as you like, and press +<ESC> when you're done to unselect the block. + +I know it's not rocket science, but it sure has helped me a lot. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>vim can interact with xdvi</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=225">http://vim.sf.net/tip_view.php?tip_id=225</A><BR> + + vim can interact with the tricks that the latest xdvi does: + + * If one clicks at some place in xdvi, vim automatically jumps to the + corresponding line in the LaTeX source file ("reverse search") + * Also, from inside vim, one can jump to the corresponding line in xdvi + which becomes highlighted ("forward search"). + + Here is how to do it: + + * Reverse search: + We start a vim server by: vim --servername xdvi We start xdvi(k) on + file.dvi by: + xdvik -editor "vim --servername xdvi --remote +%l %f" file.dvi + At the desired location in xdvi, we press: <ctrl><left_mouse> + Then, vim will jump to the corresponding line in the source file. + + * Forward search: + Inside vim, we type, for example, _g which is the following mapping: + (the following should be a single line) + + map _g :execute "!xdvik -name xdvi -sourceposition " + . line(".") . expand("%") . " " . expand("%:r") . ".dvi" + <cr><cr> + + [the command to go to the point of xdvi that corresponds to line, eg, 77 + of the source file is (no space after 77) + xdvik -name xdvi -sourceposition 77file.tex file.dvi ] + + For the above to work one needs: 1) A recent version of xdvi or xdvik + (>22.39 I think) 2) The package srcltx.sty and \usepackage{srcltx} + (which should be + commented out when one finishes and is ready for printing etc). + 3) Our version of vim should have been compiled with +clientserver + (however, my vim doesn't have it and still works, so try it before + Bram finds out what is happening and fixes it) + +</pre></tip> </html> <Tip category="KVim"> <html><center>Edit +file under cursor after a horizontal split</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=226">http://vim.sf.net/tip_view.php?tip_id=226</A><BR> + +I use the command 'gf' quite often. But with this command the current buffer +is hidden. To avoid that I use the following mapping : + +map gw <Esc>:sp %<CR> gf + +With this mapping the file under the cursor is opened after a horizontal split. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Power of :g</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=227">http://vim.sf.net/tip_view.php?tip_id=227</A><BR> + +:g is something very old and which is very powerful. I just wanted to +illustrate the use of it with some examples. Hope, it will be useful for +someone. + +Brief explanation for ":g" ------------------------- Syntax is: + :[range]:g/<pattern>/[cmd] +You can think the working as, for the range (default whole file), execute +the colon command(ex) "cmd" for the lines matching <pattern>. Also, +for all lines that matched the pattern, "." is set to that particular line +(for certain commands if line is not specified "." (current line) is assumed). + +Some examples ------------- Display context (5 lines) for all occurences of +a pattern + :g/<pattern>/z#.5 :g/<pattern>/z#.5|echo "==========" << + same as first, but with some beautification >> +Delete all lines matching a pattern + :g/<pattern>/d +Delete all blank lines (just an example for above) + :g/^\s*$/d +Double space the file + :g/^/pu =\"\n\" :g/^/pu _ << the above one also works >> +Copy all lines matching a pattern to end of file + :g/<pattern>/t$ +Yank all lines matching a pattern to register 'a' + 0"ay0:g/<pattern>/y A +Increment the number items from current line to end-of-document by one + :.,$g/^\d/exe "normal! \<c-a>" +Comment (C) lines containing "DEBUG" statements + g/^\s*DEBUG/exe "norm! I/* \<Esc>A */\<Esc>" +A Reverse lookup for records (eg: An address book, with Name on start-of-line +and fields after a space) + :g/<patern>?^\w?p "if only name is interested + :g/<patern>/ka|?^\w?p|'ap "if name and the lookup-line + is interested :g/<patern>/?^\w?|+,/^[^ ]/-1p "if entire record + is interested +Reverse a file (just to show the power of 'g') + :g/^/m0 + +Foot note 1: use :v to negate the search pattern Foot note 2: Some explanation +of commonly used commands with :g + :2,8co15 => Copy lines 2 through 8 after line 15 :4,15t$ => Copy + linesa 4 through 15 towards end of document (t == co) + :-t$ => Copy previous line to end of document + :m0 => Move current line to the top of the document +:.,+3m$-1 => Move current line through cur-line+3 to the last but one line + of the document +Foot note 3: Commands used with :g are ex commands, so a help search should + be, + :help :<help-topic> eg. :help :k + +</pre></tip> </html> <Tip category="KVim"> <html><center>Deleting +nested reply threads in emails</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=228">http://vim.sf.net/tip_view.php?tip_id=228</A><BR> + +I find the following setting useful when replying to email threads that have +lots of lines like the following: > blah > > blah > > > blah + +autocmd FileType mail map <F8> :%g/^> >/d<CR> + +When replying to a mail and you want to remove everything except what the +person you are directly replying to wrote just press F8. From the example +above, you would just be left with > blah + +What it does is simply match any line starting with > > and deletes it. +It's not perfect as sigs and other debris may remain but it takes a lot +of the grunt work out of replying to mails. The autocmd only maps F8 when +using mails, this is handy if you use F8 for other things as I do. + +:help autocmd :help map :help :g + +</pre></tip> </html> <Tip category="KVim"> <html><center>First +thing to try before asking help</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=229">http://vim.sf.net/tip_view.php?tip_id=229</A><BR> + +I've seen several questions asked in the reflector which is available in the +help files. Yeah, I know the help is huge. But, you can try this command +to show a list of related topics you are trying: + :he <topic><c-d> +It is "some topic" followed by the key sequence Ctrl-D. For eg: + :he xterm<c-d> +will show all the help topics matching xterm. Then you can do +completion/copy-n-paste the topic you are searching. Of course you can cycle +through all the topics through repeated <TABS>, but if the number of +hits are huge, it is cumbersome. + +Enjoy vimming beginners!!! -Arun + +</pre></tip> </html> <Tip category="KVim"> <html><center>copy +current file to another location from within vim</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=230">http://vim.sf.net/tip_view.php?tip_id=230</A><BR> + +I work on jsp pages in my source tree but I have to copy the jsp files over +to the tomcat directory in order to view my changes.The following mapping +will copy the file being edited to another location. + +command Cpage silent !cp '%:p' "c:/Progra~1/Tomcat/webapps/console/pages/%" + +Explanation: + +% refers to the current buffer %:p refers to the path to the file silent +suppresses the command prompt window. + +Usage: + +:Cpage + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Localized color schemes</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=231">http://vim.sf.net/tip_view.php?tip_id=231</A><BR> + +i frequently like to edit multiple files in the same vim session. however, +if i come into vim from another window i frequently hit 'i' and start typing +in whatever buffer is currently being used -- this is often the wrong one +(requires <esc>, undo, go the other buffer and . to redo). + +one way to work around this for me is to use a different color scheme +depending on what file i'm working on: + +au BufEnter * if (exists("b:colors_name")) | let b:current_colors=colors_name +| execute "colorscheme " . b:colors_name | endif + +au BufLeave * if (exists("b:current_colors")) | execute "colorscheme " +. b:current_colors | endif + +if you define b:colors_name with a particular color scheme name, then the +above autocommands will switch to that colorscheme when you enter that window +and will return to the original color upon departure. + +inside ftplugin/java.vim, for example, i might have b:colors_name set to +'morning', causing all java files to have a distinguishing color scheme. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Search +JDK help for keyword at cursor</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=232">http://vim.sf.net/tip_view.php?tip_id=232</A><BR> + + If you are using the Win32 version of Vim you can use this tip to search + the Jdk help for the keyword under the cursor. +You need the winhlp32 version of the Jdk docs from this URL - <A +HREF="http://www.confluent.fr/javadoc/indexe.html.">http://www.confluent.fr/javadoc/indexe.html.</A><BR> +It is a 16mb D/L and approx 85mb unzipped! + +I added a command to the popup menu :amenu PopUp.JavaHelp :!start winhlp32 +-k <cword> F:\jdk\winhelp\JDK13.HLP <CR + +And also made a keymapping map J :!start winhlp32 -k <cword> +F:\jdk\winhelp\JDK13.HLP <CR> + +Trivial yes, but I find it quite useful. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Some +tips for using Vim to write Lisp code</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=233">http://vim.sf.net/tip_view.php?tip_id=233</A><BR> + +For some tips on how to use Vim for writing Lisp code, see <A +HREF="http://www.lisp-p.org/i000/15-vim.">http://www.lisp-p.org/i000/15-vim.</A><BR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>Vi(M) +Command Line tips & tricks</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=234">http://vim.sf.net/tip_view.php?tip_id=234</A><BR> + +Hi VIMMERs + +These tips save me wearing out my delicate little fingers with unnecessary +keystrokes. They assume Unix, but I also use them on a Windows Unix Shell +(MKS) as well + +# When I know the file i want to edit is the most recent file in a directory + +alias -x vew='vi `l\s -t * | head -1 `' + +#When I know the file I want to edit contains a unique keyword #this is +actually in a little shell script call ed vg where the keyword is passed as +parameter $1 #/bin/sh #name vg vi.exe $(grep -isl $1 *) & + +# some variations alias -x vp='vi `l\s -t *.@(pl|cgi)| head -1 `' + +#execute the most recent script (I call this from within VIM with a mapped +button) alias -x xew='`l\s -t *.pl | head -1 `' + +Cheers zzapper + +</pre></tip> </html> <Tip category="KVim"> <html><center>Toggle +highlight word under cursor, to find cursor.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=235">http://vim.sf.net/tip_view.php?tip_id=235</A><BR> + +When the screen has scrolled such as during a search, it may be difficult to +find the cursor. :help %# explains the pattern one can use to highlight the +word around the cursor, which gives a bigger target to look for on the screen. +I have this in my .vimrc: + +function VIMRCWhere() + if !exists("s:highlightcursor") + match Todo /\k*\%#\k*/ let s:highlightcursor=1 + else + match None unlet s:highlightcursor + endif +endfunction map <C-K> :call VIMRCWhere()<CR> + +This means that in "normal" mode ctrl-k will toggle the highlight. Todo is +a hightlight group whch is particularly easy to see. For further information +see ":help s:", ":help match", ":help exists()" and ":help funtion". + +</pre></tip> </html> <Tip category="KVim"> <html><center>Menu +for inserting special characters</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=236">http://vim.sf.net/tip_view.php?tip_id=236</A><BR> + +First, thanks for the script printascii.vim. + +When looking at the ascii table, I found some characters I'd like to have +inserted when editing. Add the following lines in your _gvimrc and you +can select them via menu. (change the names of the menu if you don't have +German installed or don't like my titles). I also made some abbreviations +to get separation lines in documentation or code files, e.g. abb dotlin +^M +abb cdotlin +/**/^M +abb fdotlin +^M +abb cfdotlin +/**/^M abb +dlin =======================================================================^M +abb cdlin +/*===================================================================*/^M abb +lin -----------------------------------------------------------------------^M +abb clin +/*-------------------------------------------------------------------*/^M abb +ulin _______________________________________________________________________^M +abb culin +/*___________________________________________________________________*/^M abb +Ulin ^M +abb cUlin +/**/^M + +(you have to substitute ^M with CTRL_V CTRL_M or delete it) + +20imenu Editieren.Sonderzeichen.open\ angle\ +<C-R>=nr2char(171)<CR> 20nmenu Editieren.Sonderzeichen.open\ +angle\ a<C-R>=nr2char(171)<CR><ESC> +20imenu Editieren.Sonderzeichen.close\ angle\ +<C-R>=nr2char(187)<CR> 20nmenu Editieren.Sonderzeichen.close\ +angle\ a<C-R>=nr2char(187)<CR><ESC> +20imenu Editieren.Sonderzeichen.start\ mark\ +<C-R>=nr2char(132)<CR> 20nmenu Editieren.Sonderzeichen.start\ +mark\ a<C-R>=nr2char(132)<CR><ESC> +20imenu Editieren.Sonderzeichen.end\ mark\ \ +<C-R>=nr2char(148)<CR> 20nmenu Editieren.Sonderzeichen.end\ +mark\ \ a<C-R>=nr2char(148)<CR><ESC> +20imenu Editieren.Sonderzeichen.fat\ dot\ \ +<C-R>=nr2char(149)<CR> 20nmenu Editieren.Sonderzeichen.fat\ +dot\ \ a<C-R>=nr2char(149)<CR><ESC> +20imenu Editieren.Sonderzeichen.etc\ \ \ +<C-R>=nr2char(133)<CR> 20nmenu Editieren.Sonderzeichen.etc\ +\ \ a<C-R>=nr2char(133)<CR><ESC> +20imenu Editieren.Sonderzeichen.!underscore\ \ +<C-R>=nr2char(175)<CR> 20nmenu Editieren.Sonderzeichen.!underscore\ +\ a<C-R>=nr2char(175)<CR><ESC> +20imenu Editieren.Sonderzeichen.copyright\ \ +<C-R>=nr2char(169)<CR> 20nmenu Editieren.Sonderzeichen.copyright\ +\ a<C-R>=nr2char(169)<CR><ESC> +20imenu Editieren.Sonderzeichen.paragraph\ \ +<C-R>=nr2char(167)<CR> 20nmenu Editieren.Sonderzeichen.paragraph\ +\ a<C-R>=nr2char(167)<CR><ESC> +20imenu Editieren.Sonderzeichen.noitamalcxe\ +<C-R>=nr2char(161)<CR> 20nmenu Editieren.Sonderzeichen.noitamalcxe\ + a<C-R>=nr2char(161)<CR><ESC> + +</pre></tip> </html> <Tip category="KVim"> <html><center>If +you prefer vertical splits</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=237">http://vim.sf.net/tip_view.php?tip_id=237</A><BR> + +This is just in case there's somebody else who likes to work in a maximized +vim window on a high resolution desktop. If you follow good coding practice +and make sure your programs use only 80 characters in each row, have you +noticed how much space lies unused on the right? + +I find that the following settings keep me from ever seeing another horizontal +split, unless I specifically ask for it. + +cabbrev split vsplit cabbrev hsplit split cabbrev sta vertical sta cabbrev +help vertical help cabbrev new vnew cabbrev right botright + +; A more heavyweight solution for ^W^] function! ToggleSplit (dir) + let currFname = bufname ("%") let old = winnr () + + " Window navigation to ensure the correct window is 'last'. if (a:dir == + "u") + wincmd k let back="j" + elseif (a:dir == "d") + wincmd j let back="k" + elseif (a:dir == "l") + wincmd h let back="l" + elseif (a:dir == "r") + wincmd l let back="h" + endif + + if (winnr () == old) + echo "Ouch" return + endif + + exec "wincmd " . back + + quit + + if (back == "j" || back == "k") + let orientation = "vsplit" + else + let orientation = "split" + endif + + if (back == "j" || back == "l") + let dir = "below" + else + let dir = "above" + endif + + exec dir . " " . orientation " " . currFname +endfunction noremap ^W^] ^W^]:silent call ToggleSplit ("d")<CR> + +; Optional. set splitright ; In which case the above mapping becomes: noremap +^W^] :set splitbelow<CR>^W^]:silent call ToggleSplit ("u")<CR>:set +nosplitbelow<CR> ; Or you could just set splitbelow ; :-) + +; Very elegant and almost perfect, but it screws up if you want to run a +command with ranges :-) ;noremap : :vertical<Space> + +; EOF + +</pre></tip> </html> <Tip category="KVim"> <html><center>Very +basic session persistence</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=238">http://vim.sf.net/tip_view.php?tip_id=238</A><BR> + +I use the following code in my plugins dir to ease session persistance. If +I want my session to persist I use :mks! and then whenever I open the +Session.vim file, my session is restored. If I am working from a restored +session and I close VIM, the session is saved automatically. Drawback is +that it makes editing the Session.vim file a bit cumbersome ;) + + au BufRead Session.vim so % au VimLeave * call SaveCurrentSession() + + function! SaveCurrentSession() + if v:this_session != "" + exe "mksession! " . v:this_session + endif + endfunction + +</pre></tip> </html> <Tip category="KVim"> +<html><center>map shift-up and shift-down</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=239">http://vim.sf.net/tip_view.php?tip_id=239</A><BR> + +You can make Vim scroll the text using the shifted up/down arrows, sort +of like your browser (except with shifted keys :), by mapping Shift-Up to +Ctrl-Y and Shift-Down to Ctrl-E. + + map <s-Down> <C-E> map <s-Up> <C-Y> + +Shift-Down will then scroll down (like moving a scroll-bar down, or like +moving a cursor at the bottom of a window down), and Shift-Up will then +scroll up (like moving a scroll-bar up, etc). + +If you'd rather think about the text moving down/up instead of the cursor +moving up/down, you can of course swap the mappings. + +If you normally use j and k for cursor movement, and rarely use the arrow +keys, you can map the arrow keys directly, in which case I'd probably map +the shifted arrow keys back to cursor movement: + + map <down> <c-e> map <up> <c-y> map <s-down> + j map <s-up> k + +See :help ctrl-e, :help ctrl-y, and :help key-mapping. + +See also :help i_ctrl-o and :help map-modes for how to set up these mappings +for use in other modes (like insert mode :). + +(Vim by default maps s-Down and s-Up to Ctrl-F and Ctrl-B, for both normal and +visual mode. Keep this in mind if you change some of the above mappings to +"nmap", 'cause you'll probably also want to look in to "vmap".) + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Hideall for Vim</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=240">http://vim.sf.net/tip_view.php?tip_id=240</A><BR> + +Xemacs has a hide all function which can make all the function in your C file a +fold and close them. And here is something small to achieve similiar under Vim. + +func! HideAll() + syn region myFold start="{" end="}" transparent fold syn sync fromstart + set foldnestmax=1 set foldmethod=syntax +endfunc + +amenu Whatever.Hide\ all :call HideAll()<CR> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>"Hide" Folding Markers</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=241">http://vim.sf.net/tip_view.php?tip_id=241</A><BR> + +I wanted to start using folding without having to get used to seeing the +(default) markers, a.k.a {{{ and }}}. So, here are 2 autocmd's that will +make them fade to black....bg=black fg=black + +au BufRead,BufNewfile * syn match fmrkr '"*{{{\|"*}}}' | + \ syn cluster vimCommentGroup contains=fmrkr | + \ hi fmrkr term=NONE guibg=black guifg=black \ + ctermbg=black ctermfg=black + +au BufRead,BufNewfile * syn match fmrkr '"*{{{\|"*}}}' + \ containedin=vimLineComment contained | + \ hi fmrkr term=NONE guibg=black guifg=black \ + ctermbg=black ctermfg=black + +They both accomplish the same thing, but with different methods, so simply pick +one and see those annoying (at least to me) markers fade away. I just tried +it out with vim files, but you can easily modify it for any other filetypes. + +Thanks to Colin's lead with ':help c-syntax' for the 1st au. Thanks to +Benji's lead with ':help containedin' for the 2nd au. Understanding most +of the syntax.txt document file would also be helpful. + +To figure out what highlighting group the Marker is in, I would suggest +using Chip's vimtip#99. + +Happy Vimming! + +</pre></tip> </html> <Tip category="KVim"> +<html><center>The power of "\_" in reg-ex</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=242">http://vim.sf.net/tip_view.php?tip_id=242</A><BR> + +One of the most uncelebrated feature of vim 6.0 is the ability to span a +search across multiple lines. + +\_^ maps a begining of line anywhere in search pattern. \_$ ---"----- end +----------------------"-------------------------. \_s ---"------ space +------------"------------------------- . + +e.g /{\_s will map all white spaces and new-line chars after a "{" + +The \_ can be appended to other objects as well. such as \_U, \_L, \_. (this +one's risky) . + +See :help pattern for more details. Njoy + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Develop vim modules on Win</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=243">http://vim.sf.net/tip_view.php?tip_id=243</A><BR> + +We're trying to develop txt2pdf.vim <A +HREF="http://vim.sourceforge.net/scripts/script.php?script_id=283 on +Win.">http://vim.sourceforge.net/scripts/script.php?script_id=283 +on Win.</A><BR> It's a very simple module to save the +current file and convert it to PDF using our txt2pdf tool <A +HREF="http://www.sanface.com/txt2pdf.html">http://www.sanface.com/txt2pdf.html</A><BR> +On our Windows 2000 we've developed it. It works good. Today we've tested +the module on Linux. Surprise: it doesn't work. Default Win Vim configure +save on Win text in Win way: EOL \r\n. A Vim module made in this way can't +work on Linux (probably on every Unix OS). If you want to make a Vim module +on Win and you want it can work also on Unix (we hope the same rula can work +also on different OS) you've to save the Vim module with Unix EOL (\n). + +Please send us (sanface@sanface.com) your notes about other OS (e.g. OpenVMS). + +</pre></tip> </html> <Tip category="KVim"> <html><center>Ask +vim where an option was set.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=244">http://vim.sf.net/tip_view.php?tip_id=244</A><BR> + + When things go wrong, it is sometimes hard to figure out why. + For example, +an option might be set in the system vimrc file, in a personal vimrc file, +in a plugin (global or local), or interactively. Vim will tell you where +the current value was set if you ask: + +:verbose set history? + +will tell you the current value of the 'history' option, and where it was set. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Working +with Unicode (platform-independent)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=245">http://vim.sf.net/tip_view.php?tip_id=245</A><BR> + +Here are the main options you will want to set if you want to work with +Unicode files in (g)vim (see at bottom what help tags to look for) + +if has("multi_byte") + set encoding=utf-8 " how vim shall represent + characters internally setglobal fileencoding=utf-8 " empty is + also OK (defaults to same as 'encoding'). Or you may want to set one + of the ucs encodings (which + " may use less disk + space if you use + only "alphabetic" + scripts such as + Latin, Greek, + Cyrillic, Hebrew + or Arabic, and " + not "ideographic" + scripts like + Chinese, Japanese + or Korean. With + the ucs encodings + it is usually better + set bomb " to also set 'bomb' + on ('byte-order-mark" option, irrelevant for utf-8 but not for + ucs) set termencoding=iso-8859-15 " or whatever is appropriate + to your locale (iso-8859-15 is Latin1 + Euro currency sign) set + fileencodings=ucs-bom,iso-8859-15,iso-8859-3,utf-8 + " or whatever is appropriate to the kinds of files you want to + edit " 'fileencodings' defines the heuristic to set 'fillencoding' + (local to buffer) when reading an existing file. The first one that + matches will be used. " ucs-bom is "ucs with byte-order-mark"; + it must not come after ucs-8 if you want it to be used +else + echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte" +endif + +In "replace" mode, one utf character (one or more data bytes) replaces one +utf character (which need not use the same number of bytes) In "normal" mode, +ga shows the character under the cursor as text, decimal, octal and hex; g8 +shows which byte(s) is/are used to represent it In "insert" or "replace" mode, + - any character defined on your keyboard can be entered the usual way (even + with dead keys if you have them, e.g. ) - any character which + has a "digraph" (there are a huge lot of them, see :dig after setting + enc=utf-8) can be entered with a Ctrl-K prefix - any utf character at + all can be entered with a Ctrl-V prefix, either <Ctrl-V> u aaaa + or <Ctrl-V> U bbbbbbbb, with 0 <= aaaa <= FFFF, or 0 <= + bbbbbbbb <= 7FFFFFFF + +Unicode can be used to create html "body text", at least for Netscape 6 and +probably for IE; but on my machine it doesn't display properly as "title text" +(i.e., between <title></title> tags in the <head> part). + +Gvim will display it properly if you have the fonts for it, provided that +you set 'guifont' to some fixed-width font which has the glyphs you want +to use (Courier New is OK for French, German, Greek, Russian and more, +but I'm not sure about Hebrew or Arabic; its glyphs are of a more "fixed" +width than those of, e.g. Lucida Console: the latter can be annoying if you +need bold Cyrillic writing). + +see: + +:h utf8 :h 'enc' :h 'fenc' :h 'fencs' :h 'tenc' :h 'bomb' :h 'guifont' +:h ga :h g8 :h i_Ctrl-V_digit + +Happy Vimming ! Tony. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Working +with Unicode (the same, rewritten for legibility)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=246">http://vim.sf.net/tip_view.php?tip_id=246</A><BR> + +1. Where to look for help ------------------------- :h utf8 :h encoding-values +:h 'enc' :h 'fenc' :h 'fencs' :h 'tenc' :h 'bomb' :h 'guifont' :h ga :h g8 +:h :dig :h i_Ctrl-V_digit :h has() + +2. What to do (These are *examples*. Modify them to suit your work +environment.) ------------- if has("multi_byte") + set encoding=utf-8 setglobal fileencoding=utf-8 + set bomb set termencoding=iso-8859-15 set + fileencodings=ucs-bom,iso-8859-15,iso-8859-3,utf-8 +else + echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte" +endif + +3. What the above does ---------------------- * has("multi_byte") checks if +you have the right options compiled-in. If you haven't got what it takes, +it's no use trying to use Unicode. + +* 'encoding' sets how vim shall represent characters internally. Utf-8 is +necessary for most flavors of Unicode. + +* 'fileencoding' sets the encoding for a particular file (local to buffer); +:setglobal sets the default value. An empty value can also be used: it defaults +to same as 'encoding'. Or you may want to set one of the ucs encodings, It +might make the same disk file bigger or smaller depending on your particular +mix of characters. Also, IIUC, utf-8 is always big-endian (high bit first) +while ucs can be big-endian or little-endian, so if you use it, you will +probably need to set 'bomb" (see below). + +* 'bomb' (boolean): if set, vim will put a "byte order mark" at the start +of ucs files. This option is irrelevant for most non-ucs files (utf-8, +iso-8859, etc.) + +* 'termencoding' defines how your keyboard encodes what you type. The value +you put there will depend on your locale: iso-8859-15 is Latin1 + Euro currency +sign, but you may want something else for, say, an Eastern European keyboard. + +* 'fileencodings' defines the heuristic to set 'fileencoding' (local to buffer) +when reading an existing file. The first one that matches will be used (and, +IIUC, if there is no match, Vim falls back on Latin1). Ucs-bom is "ucs with +byte-order-mark"; it must not come after utf-8 if you want it to be used. + +4. Additional remarks --------------------- * In "replace" mode, one utf +character (one or more data bytes) replaces one utf character (which need +not use the same number of bytes) + +* In "normal" mode, ga shows the character under the cursor as text, decimal, +octal and hex; g8 shows which byte(s) is/are used to represent it. + +* In "insert" or "replace" mode, + - any character defined on your keyboard can be entered the usual way + (even with dead keys if you have them, e.g. French circumflex, German + umlaut, etc.); - any character which has a "digraph" (there are a huge lot + of them, see :dig after setting enc=utf-8) can be entered with a Ctrl-K + prefix; - any utf character at all can be entered with a Ctrl-V prefix, + either <Ctrl-V> u aaaa or <Ctrl-V> U bbbbbbbb, with 0 <= + aaaa <= FFFF, or 0 <= bbbbbbbb <= 7FFFFFFF. + +* Unicode can be used to create html "body text", at least for Netscape 6 and +probably for IE; but on my machine it doesn't display properly as "title text" +(i.e., between <title></title> tags in the <head> part). + +* Gvim will display it properly if you have the fonts for it, provided +that you set 'guifont' to some fixed-width font which has the glyphs you +want to use (Courier New is OK for French, German, Greek, Russian and more, +but I'm not sure about Hebrew or Arabic; its glyphs are of a more "fixed" +width than those of, e.g. Lucida Console: the latter can be awkward if you +need bold Cyrillic writing). + +Happy Vimming ! Tony. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Preexisting code indentation</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=247">http://vim.sf.net/tip_view.php?tip_id=247</A><BR> + +Using tabs as elementary unit in your code indentation has two advantages: +first, you may modify 'tabstop' and immediately all the indentations depths +are modified according to it; second, your file will be smaller. + +But how can we change some already-written code in order to convert spaces +to tabs. Very simple! Suppose your old code has an indentation unit of +2 spaces :ret! 2 :x will replace every 2-spaces to one tab, independently +from your current tabstop value, and will save the modified file. Then, +if you open again the file with tabstop=2, the file will look as before but +it will be smaller. If you open the file with tabstop=4, the code vill have +a more indented look, and so on... + +Cheers! + +</pre></tip> </html> <Tip category="KVim"> <html><center>Auto-save +the current buffer periodically.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=248">http://vim.sf.net/tip_view.php?tip_id=248</A><BR> + +I have no idea if this was implemented in vim 5.3 or not, but you can +definitely do the following kludge in 6.x by using CursorHold and +localtime: + +- When you start reading a file, set a buffer variable to the current + time: + + au BufRead,BufNewFile * let b:start_time=localtime() + +- Set a CursorHold event to check to see if enough time has elapsed + since the last save and save if not: + + au CursorHold * call UpdateFile() + +- Define a function to save the file if needed: + + " only write if needed and update the start time after the save + function! UpdateFile() + if ((localtime() - b:start_time) >= 60) + update let b:start_time=localtime() + else + echo "Only " . (localtime() - b:start_time) . " seconds have elapsed + so far." + endif + endfunction + +- Reset the start time explicitly after each save. + + au BufWritePre * let b:start_time=localtime() + +Obviously, you should get rid of the else portion once you're certain +that this does indeed do what you wanted. + +The thing to note is that the CursorHold will only fire after +'updatetime' milliseconds of inactivity have elapsed. So, if you type +rapidly for one and a half minutes non-stop, it won't actually save +anything until you STOP activity long enough. This may be what you want +anyway because it won't interrupt your activity with a forced save. + +The actual save-delay can be changed from '60' to another number (in seconds) +or a variable or anything like that. This entire functionality can be easily +wrapped inside a nice script which enables/disables this on a per-buffer basis +(maybe with maps etc.). If desired, I can provide that also. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Quickly +insert #if 0 - #endif around block of code</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=249">http://vim.sf.net/tip_view.php?tip_id=249</A><BR> + +One of my favorite macros that I use in vim (and vi) inserts a #if 0 #endif +sandwich around a block of code. I always map this to the 2 key sequence ;' +which is the semi-colon followed by the single quote. Look at your keyboard, +you will notice these keys are adjacent to one another. I like this mapping +because it's very fast, my fingers easily roll from one key to the next, +obviously YMMV. + +To use this mapping, go to the line of code that you want the '#if 0' to be +on, type ma to mark this line with the marker a, then move to the line that +should be last line just above the '#endif' and press ;' + + " insert #if 0 - #endif around block of code map ;' mz'aO<Esc>i#if + 0<Esc>'zo<Esc>i#endif<Esc> + +-- David Thompson dat1965@yahoo.com + +</pre></tip> </html> <Tip category="KVim"> +<html><center>One big window</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=250">http://vim.sf.net/tip_view.php?tip_id=250</A><BR> + +If you like to see your files in fullscreen, and you have to edit more files, +you can do the following. * Use only one window * Open further files with :e * +type :nm <A-Up> :bp!<CR> * type :nm <A-Down> :bn!<CR> +* type :nm <C-F4> :bd!<CR> You can of course change the keys. +Now to switch between windows, you can press Alt-Up, and Alt-Down (Just in +the GUI, if you use console, don't use Alt key) Another idea is to map them +to Ctrl-Tab, and Ctrl-Shift-Tab To close the current file you can press Ctrl-F4 + +</pre></tip> </html> <Tip category="KVim"> <html><center>align +#endif with corresponding #if/#ifdef</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=251">http://vim.sf.net/tip_view.php?tip_id=251</A><BR> + +If you try to impose any sort of alignment on your preprocessor directives, +rather than just starting them on column 0, this mapping will align the #endif +'correctly' when you type '#en', start a new line, and bring you back to +the correct alignment to edit code. + +inoremap <buffer> #en +X<BS><Esc>?#if<CR>"zy0^Og0"zpDa#endif<CR>X<BS><Esc>?#end?-1<CR>^"zy0^O0"zpDa + +I am reasonably sure this is insensitive to vim options... + +</pre></tip> </html> <Tip category="KVim"> <html><center>python +script to align statements</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=252">http://vim.sf.net/tip_view.php?tip_id=252</A><BR> + +i know there's some awk scripts out there that do the same thing, and if i +were a real trooper i would have written this in vims internal language but... + +i wrote a python script to align statements. + +i put this in my .vimrc: map L :!lineUp.py<cr> " of course lineUp.py +is somewhere in my path + +and i have this python file somewhere in my path: <A +HREF="http://ophinity.com/res/dotFiles/lineUp.py">http://ophinity.com/res/dotFiles/lineUp.py</A><BR> + +so now i can just pipe the offending lines thru my code: :5, 10 !lineUp.py +or using the mapping above, visually select the lines and press 'L' + +</pre></tip> </html> <Tip category="KVim"> <html><center>The +power of | (v75|r- actually...)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=253">http://vim.sf.net/tip_view.php?tip_id=253</A><BR> + +'|' as you may well be aware is the goto column motion, and that "75|" +will place your cursor on column 75 of the current line. + +That in itself is pretty handy at times, but some true power arises when +used in conjuction with visual mode and replace. Or you could just say a +sneaky trick :) + +v75|r- will repace from the cursor to the end of line with '-' *breakdown* +v to turn on visual mode 75 for the count | *bar* to goto column r to enter +repace - to specify the char to replace. + +A handy and quick way to make a noticable section of your code (or whatever). + +A handy way to use this (formated to just drop into DrChip's CStubs): "// +-[Feral]--------------------------------------------------------------- +"// <cursor> + elseif wrd == "//" + exe "norm! a + -[AuthorId]\<esc>$lv75|r-$a\<cr>\<esc>$a " + +"// -[Feral:146/02@08:31]-------------------------------------------------- +"// <cursor> + elseif wrd == "///" + exe "norm! s + -[AuthorId:\<C-R>=strftime('%j/%y@%H:%M')\<CR>]\<esc>$lv75|r-$a\<cr>\<esc>$a + " + +"/* -[Feral:146/02@08:31]-------------------------------------------------- +" * <cursor> " * +-------------------------------------------------------------------- */ + elseif wrd == "/*" + exe "norm! a + -[AuthorId:\<C-R>=strftime('%j/%y@%H:%M')\<CR>]\<esc>$lv75|r-$a\<cr>\<cr>\<esc>2lv72|r-$a + */\<esc>k$a " + +Have to love VIM! + +</pre></tip> </html> <Tip category="KVim"> <html><center>Using +\%[] to easily match parts of a word.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=254">http://vim.sf.net/tip_view.php?tip_id=254</A><BR> + +This code fragment is suitable to drop into DrChip's CStubs. +After much searching I was unable to find a tip nor script +number to referance, I believe where I found Dr. Chip's CStubs originally : <A +HREF="http://users.erols.com/astronaut/vim/vimscript/drcstubs.vim">http://users.erols.com/astronaut/vim/vimscript/drcstubs.vim</A><BR> +Thank you Dr. Chip! (= + +If you have ever wanted to match parts of a word you may have considered +something like: if wrd == "re" || wrd == "ret" || wrd == "retu" || wrd == +"retur" + "do something + +Althought the above works well enough it is a pain to maintain and add new +words (not to mention its just a touch messy ;) ) + +A more elegant (and easier to use I believe) method would be to use \%[] +as part of a pattern. + +For instance, "\\<re\\%[tur]\\>" will match "re", "ret", "retu" or +"retur" + +*breakdown* \\< = start of word re = first letters of word we want to +require to match \\%[tur] = optionally match chars bewteen the braces, +i.e. 't', 'tu' or 'tur' \\> = end of word + +So, we can use this as a pattern for match like so (In DrChip's CStubs) + +elseif match(wrd, "\\<re\\%[tur]\\>") > -1 + exe "norm! bdWireturn\<Esc>" + +Which, I think, is a little better than the longer alternative: " vs elseif +wrd == "re" || wrd == "ret" || wrd == "retu" || wrd == "retur" + exe "norm! bdWireturn\<Esc>" + +Just another one of those VIM things that made me smile :) + +</pre></tip> </html> <Tip category="KVim"> +<html><center>arbitrary tags for file names</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=255">http://vim.sf.net/tip_view.php?tip_id=255</A><BR> + +This definitely work on linux and there is probably some windows equivalent. +I've started working with tomcat and many many .jsp files. I find this +trick to be very helpful. + +find -name '*.jsp' -printf '%f\t%P\t1\n' |sort > jsp.tags + +This will create a file called jsp.tags with tag entries for each .jsp file. +Within Vim I use + +:set tags+=jsp.tags + +Now I can to simple :tag file.jsp to quickly switch b/w the many, many +.jsp files. + +One important note. The utility sort will use the value of LC_COLLATE to sort +according to your locale. This will give Vim issues. So try "LC_COLLATE=C +sort" instead of plain "sort" + +</pre></tip> </html> <Tip category="KVim"> <html><center>Opening +current Vim file in your Windows browser</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=256">http://vim.sf.net/tip_view.php?tip_id=256</A><BR> + +Hi Vimmers + +open current file in browser + +map ,f :update<CR>:silent !start c:\progra~1\intern~1\iexplore.exe +file://%:p<CR> + +open http link under cursor in your browser + +map ,i :update<CR>: !start c:\progra~1\intern~1\iexplore.exe +<cWORD><CR> + +Note use of cWORD (not cword) meaning OUTER Word + +Works for me in XP & 98 (Original came from a posting by Ralf Arens) + +zzapper + +</pre></tip> </html> <Tip category="KVim"> +<html><center>fast page up/down.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=257">http://vim.sf.net/tip_view.php?tip_id=257</A><BR> + +i discovered a cool way to move between pages of the same document in vim +6.1. press a number in -normal mode- and the page up/down. the document +will move with that number of pages up/down.if the number is greater that +the nr of pages, document will move to begin/end of file. i didn't test it +on other version. + +</pre></tip> </html> <Tip category="KVim"> <html><center>how +long is the current word?</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=258">http://vim.sf.net/tip_view.php?tip_id=258</A><BR> + +ever wondered how long the current word is? this can be quite useful when +editing data files. simply add the following to your .vimrc + +nmap <C-_> :echo 'word' expand("<cword>") ' wordlen =' +strlen(expand("<cword>"))<CR> + +and it will tell you the word under the cursor, and how long it is. + +and for things that arent words, this addition to your .vimrc works on +sections of a line that have been hightligted in visual mode + +vmap <C-_> "-y:echo 'word' @- ' wordlen =' strlen(@-)<CR> + +again you see the "word", and its length this may also work on vim 5.x, +but i havent checked to make sure. + +</pre></tip> </html> <Tip category="KVim"> <html><center>removing +the toolbar (icons) from gvim</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=259">http://vim.sf.net/tip_view.php?tip_id=259</A><BR> + +Change good or bad usually encounters interia from people in excepting it. +gvim 6.0 is the first version that introduced the icons shortcut in shape +of a toolbar under the menu. when we upgraded to the new and improved vim +6.1 from vim 5.7 some of people in our company encountered some problems +with their syntax highlighting and some of them objected on the new toolbar +which displayed icons for some common tasks for people more used to GUI. + +I finally figured out how to remove this new feature since I also didn't +see much use for it + +Here is for all those who haven't figured it out yet + +In your .gvimrc include the following two lines + +unmenu ToolBar unmenu! ToolBar + +Doing this from an open gvim does not remove them but grays them out but +doing from gvimrc does the job + +I was also trying to remove the menus at the top and almost succeeded with +a similar technique but somehow the Buffer menu item stays there no matter +what. IMHO it is a bug but it could very well be a feature ;) + +I tried this + +unmenu * unmenu! * + +even added this line after the above two but didn't help unmenu Buffers + +I hope this benefits you all as much as I have benefitted from all your tips + +</pre></tip> </html> <Tip category="KVim"> +<html><center>gvim-->mouse-->popup menu</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=260">http://vim.sf.net/tip_view.php?tip_id=260</A><BR> + +This tip is for those who prefer to do some of the common operations like +cut/copy/paste etc using mouse. All u have to do is + + :set mousemodel=popup + +by this u get a popup menu on right click of your mouse and u can do all +the common operations like undo, cut, copy, paste, select etc using mouse. + +u can also customise your popup menu by editing $VIMRUNTIME/menu.vim + +</pre></tip> </html> <Tip category="KVim"> <html><center>Close +windows from Gvim poup menu</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=261">http://vim.sf.net/tip_view.php?tip_id=261</A><BR> + +To close windows from the popup menu add these lines to your .gvimrc + +:amenu PopUp.Close.\ Window :confirm close<CR> :amenu PopUp.Close.\ +Other :confirm only<CR> + +You obviously need ':set mousemodel=popup' in your .gvimrc as well :=) + +</pre></tip> </html> <Tip category="KVim"> <html><center>Bored +of ur arrow shapped mouseptr?</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=262">http://vim.sf.net/tip_view.php?tip_id=262</A><BR> + +here is how u can change the shape of ur mouseptr in gvim. + +:set mouseshape=n:pencil + +this will change the shape of the mouseptr to pencil in normal mode. u can +choose different shapes for different modes. see :h mouseshape + +Want more shapes? + +Then look for the file cursorfont.h in ur X11/ directory. This file contains +lots of cursor shape #define definitions, like . #define XC_heart 62 . +now :set mouseshape=n:62 will set the shape of the mouseptr to heart in +normal mode. + +-ncr + +</pre></tip> </html> <Tip category="KVim"> +<html><center>color active line</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=263">http://vim.sf.net/tip_view.php?tip_id=263</A><BR> + +This tip shows how to color the active line, the line in which the cursor +is, for better reading. You should try possibility 2 before 1, IMHO it is +mostly usable. + +possibility 1: + :au! CursorHold * let @/ = '\%' . line('.') . 'l.*' :set ut=500 + +explanation: + After 500 ms of waiting for you to hit a key, vim sets the search + register to a pattern that matches the current line. + +problem: + Register / holds the search pattern, so you cannot have color the active + line and search. Therefore another solution: + +possibility 2: + :highlight CurrentLine guibg=darkgrey guifg=white (or whatever + colors you want) :au! Cursorhold * exe 'match CurrentLine /\%' + . line('.') . 'l.*/' :set ut=100 + +explanation: + This solution uses 'match' to highlight a string, it does not interface + with the current search pattern. + +addition: + Turning the highlighning off: + :au! Cursorhold :match none + The order of these commands are important. If :match none is executed + first, the autocommand would almost immediately execute another match + command. + +references to vim help: + :help Cursorhold :help 'ut' :help /\%l :help "/ :help \% + +</pre></tip> </html> <Tip category="KVim"> <html><center>F5 +Compile and Run, F8 Compile (ala Visual Studio)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=264">http://vim.sf.net/tip_view.php?tip_id=264</A><BR> + +I love vim, it's my default editor on my Sun, Windows, Linux and *BSD boxen. +That said, I hate having to flip windows to compile while doing the +write->compile->debug loop. + +If you're used to Visual Studio and the ability it has to just hit F5 to +compile and run the current file or F8 to compile or step through the code +you'll appreciate this... + +This is my Windows version of this scriplet/tiplet. For other platforms, +you'll want to change the IF ELSE loops. You should actually never see +the "Unsuccessful" message from the compile/run loop unless the compiler +completely bombs out. This is from my _vimrc... + +map <F5> :call CompileRunGcc()<CR> + +map <F8> : call CompileGcc()<CR> + +func! CompileRunGcc() + exec "w" "Save the file exec "!gcc % -o %< && cr 10 && IF + EXIST %<.exe (%<) ELSE banner -c = Compile Unsuccessful + " exec "i" "jump back where we were + + +endfunc + +func! CompileGcc() + exec "w" exec "!gcc % -o %< && IF EXIST %<.exe (cr 5 && + banner -c # Success) ELSE banner -c # Compile Unsuccessful + " exec "i" + +endfunc + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Fast help in full window</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=265">http://vim.sf.net/tip_view.php?tip_id=265</A><BR> + +You can get fast access to help by writing small script + +#!/bin/bash vim -c "help $1" -c only + +now name it eg. vih and from cl + +$ vih makeprg + +</pre></tip> </html> <Tip category="KVim"> +<html><center>use -S command line switch</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=266">http://vim.sf.net/tip_view.php?tip_id=266</A><BR> + +The -S switch could be used to simplify common idiom: start Vim and source +a script file: gvim -c ":so foobar.vim" got translated into gvim -S foobar.vim + +Yes, this tip is trivial but I still see the -c ":so x" way too often. Time +to update your mind! + +</pre></tip> </html> <Tip category="KVim"> +<html><center>selectively displaying abbreviations</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=267">http://vim.sf.net/tip_view.php?tip_id=267</A><BR> + +Hi Vimmers, abbreviations have always been one of the most useful parts of +vi(m), trouble is when you've got too many you forgot what you called them. + +You can of course list the whole lot with + +:ab<cr> + +But did you know that you can type the first few letters of your abbreviations +and get a list of just thos abs eg + +:ab php<cr> gives me all my php abs & :ab perl<cr> gives me all +my perls + +also try control-D instrad of <cr> + +zzapper + +</pre></tip> </html> <Tip category="KVim"> <html><center>Get cursor +position as byte percentage instead of line percentage</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=268">http://vim.sf.net/tip_view.php?tip_id=268</A><BR> + +On line 300 of a thousand line file, Vim will show you that you're 30% +through the file. But what if most of the lines have one character in them, +and some of them have twenty thousand? Sometimes it comes in handy to know +your percentage through the file in terms of current-byte / total-bytes. +I looked through the Vim docs and couldn't find a way to do this, so I wrote +a Vim function to show it. + +Put this in your .vimrc: + +function! Percent() + let byte = line2byte( line( "." ) ) + col( "." ) - 1 let size = (line2byte( + line( "$" ) + 1 ) - 1) " return byte . " " . size . " " . (byte * 100) + / size return (byte * 100) / size +endfunction + +(Uncomment the first return to see intermediate values.) + +And put this somewhere in your "set statusline=...": + + %{Percent()}%% + +See "help statusline", "help eval". + +</pre></tip> </html> <Tip category="KVim"> <html><center>Syntax highlighting +is "out of sync", seems to correct itself with refresh ??</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=269">http://vim.sf.net/tip_view.php?tip_id=269</A><BR> + +This one has come across the 'vim' users mailing list many times, and probably +comp.editors as well... + +Summary: see :help :syn-sync and search for 'sync' in your favorite syntax +file in $VIMRUNTIME/syntax + +Long Version: The syntax highlight code utilizes a certain synchronization +method to efficiently figure out syntax highlighting, specifically if you +aren't at the very beginning or end of a file. The specific setting is 'syntax +sync'. For various file types the method is set by default in this is setup +in the syntax file and one can vary the degree of trouble which VIM goes to to +try and figure this out. As an example for C, from $VIMRUNTIME/syntax/c.vim: + +if exists("c_minlines") + let b:c_minlines = c_minlines +else + if !exists("c_no_if0") + let b:c_minlines = 50 " #if 0 constructs can be long + else + let b:c_minlines = 15 " mostly for () constructs + endif +endif exec "syn sync ccomment cComment minlines=" . b:c_minlines + +Where c_minlines is the minimum number of lines that VIM goes backward to try +to find the start of a comment for syntax highlighting. If that line which +starts a comment is outside of that range, highlighting will appear wrong. + +You can easily set up something like this in your .vimrc: let c_minlines=500 +or even bigger, but realize that it is a performance trade-off and that +syntax highlighting will slow things down. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Insert a single character</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=270">http://vim.sf.net/tip_view.php?tip_id=270</A><BR> + +Using Insert mode to insert a single character feels clumsy (you need 3 +keypresses for one character), so here's a slightly easier way: + +:nmap <space> i_<esc>r + +Now, when in Normal mode, just press space followed by what it is you want +to insert. + +BUG: Repeating the insertion with . doesn't work. + +</pre></tip> </html> <Tip category="KVim"> <html><center>easy +(un)commenting out of source code</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=271">http://vim.sf.net/tip_view.php?tip_id=271</A><BR> + +Something that I do quite alot is comment out blocks of text, only to uncomment +that same block later. The following mappings have proven useful to me. They +can be applied using visually selected blocks, or with motion keys. + +" lhs comments map ,# :s/^/#/<CR> map ,/ :s/^/\/\//<CR> map ,> +:s/^/> /<CR> map ," :s/^/\"/<CR> map ,% :s/^/%/<CR> +map ,! :s/^/!/<CR> map ,; :s/^/;/<CR> map ,- :s/^/--/<CR> +map ,c :s/^\/\/\\|^--\\|^> \\|^[#"%!;]//<CR> + +" wrapping comments map ,* :s/^\(.*\)$/\/\* \1 \*\//<CR> map ,( +:s/^\(.*\)$/\(\* \1 \*\)/<CR> map ,< :s/^\(.*\)$/<!-- +\1 -->/<CR> map ,d :s/^\([/(]\*\\|<!--\) \(.*\) +\(\*[/)]\\|-->\)$/\2/<CR> + +The commands to comment a selection of text are as follows, begining with +begining-of-line comments: + + ,# shell, perl, etc ,/ c++ ,> email quote ," vim ,% + latex, prolog ,! assembly?... add single ! ,; scheme ,- + don't remember this one... add -- ,c clears any of the previous + comments + +Here are the wrapping comments, each line wrapped individually: + + ,* c ,( Standard ML ,< html ,d clears any of + the wrapping comments + +</pre></tip> </html> <Tip category="KVim"> <html><center>automaticaly +formating pasted text (p=`])</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=272">http://vim.sf.net/tip_view.php?tip_id=272</A><BR> + +In times past I used a nice editor that had the neat feature of automatically +setting pasted text to the proper indent level. Recently I've begun to miss +this so I went looking in the help and camp up with.... + +=`] + +which will format to the end of the pasted text... Perfect to call right +after you past something as the cursor ends up at the top of the pasted text, +thus the mapping: + +:map <c-p> =`] + +" by the by the above may should be nmap and I am pretty sure c-p is unused, +your mileage will vary no doubt. + +However I wanted the formatting to automatically be done so it was two simple +(once I figured out how!) nnoremap: + +" [Feral:185/02@14:27] map c-p to what p was (past with no formatting), map +p to p and = to end of pasted text. :nnoremap p p=`] :nnoremap <c-p> p + +This simply (as the comment hints at) maps normal mode p to what p did (paste) +then = to `] (last character in the previously changed text). While ctrl+p +just does what p did. (just in case you find you don't want a bit of text +auto formatted.). + +reference: :h :nnoremap :h p :h = :h `] + +Whatever the name of this idea is, tis something I find handy :) + +Happy VIMing + +</pre></tip> </html> <Tip category="KVim"> <html><center>Fast +fixing of email quotations (too long lines)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=273">http://vim.sf.net/tip_view.php?tip_id=273</A><BR> + +When using VIM as your editor of choice, even for email processing - as I +do - it is often unpleasing how some MUA's quote the email body produced by +mailers such as Outlook. The lines often span across multiple visual lines +and its difficult to reply on certain parts of it. + +With VIM, you can quickly fix those quotations to maintain a proper 75 char +break. For example, when using Mutt, put this line in your .muttrc, or use +a custom .vimrc_mail for it: + +set editor="vim -c 'set fo=tcrq' -c 'set tw=76'" + +For other MUA's this has to be fitted. However, now, when your quoted email +is displayed, you can use this VIM sequence to fix it: + +1. move cursor to first line of broken paragraph 2. press 'V' and move to the +last line of the paragraph you want to fix 3. press 'g' and then 'q'. The +marked text will wrap around to your specified textwidth (76 in our case) +and the quotations will be preserved across the lines + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Some useful mappings for TeX</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=274">http://vim.sf.net/tip_view.php?tip_id=274</A><BR> + +You know, TeX requires a lot of additional formatting code. I'm tired of +opening and closing braces, brakets, + \beginning and \ending etc. I particularly hate typing \begin and \end. +To help myself and to save a few(not a few) keystrokes I naturaly came up to +some solutions, which I wish to share with other TeXnicians and TeXperts whhich +use Vim. "===============================cut here========================= +"=============== you can put it in ~/.vim/after/ftplugin/tex.vim +=============== " " Note: i_<C-L> " This constructs a skeleton of a TeX +environment. " You write a line like this: " floatingfigure:ht<C-L> +" and after you press <C-L>, you get: " " \begin[ht]{floatingfigure} +" " \end{floatingfigure} " -- INSERT -- " " where floatingfigure is the +desired environment " ht are options " : is delimiter; in fact, you can +use whatever delimiter you want " as long it is not in &iskeyword option. +inoremap <buffer> <C-L> + \:s/[^][:alnum:]<bar>]\+/,/eg + \I\begin{ea}[A]%d%%P \:s/\[,/[/e \:s/,]/]/e + \:s/\[]//e \0f{y%o\endpO +inoremap <buffer> { {}i inoremap <buffer> [ []i inoremap +<buffer> ^ ^{}i inoremap <buffer> _ _{}i inoremap <buffer> +\( \(\)hi inoremap <buffer> \[ \[\]hi + +" Note: v_<C-L> " For this to work, you have to write on a blank +line the name of " the desired environment and options (see i_<C-L>) +and visual select " (from top to bottom) this and following lines. " After +pressing <C-L> the selected lines will be surrounded " with begin/end +skeleton of the environment. vnoremap <buffer> <C-L> o + \:s/[^][:alnum:]<bar>]\+/,/eg + \I\begin{ea}[A]%d%%P \:s/\[,/[/e \:s/,]/]/e + \:s/\[]//e \0f{y%gvoo\endp +" vnoremap <buffer> { di{}P " vnoremap <buffer> +[ di[]P vnoremap <buffer> di^{}P vnoremap <buffer> di_{}P +vnoremap <buffer> \( di\(\)hP vnoremap <buffer> \[ di\[\]hP + +" This makes "two spaces after a comma" before every :write au BufWritePre +*.tex %s/,\(\S\)/, \1/ge + +"==================== You can put this in your ~/.vimrc +======================== " If cursor is inside braces and not before comma, +blank or opening brace, " exit the brace block and stay in insert mode. " +If cursor is outside braces, it inserts a space or perform an abbreviation +" as normal. function! CleverSpace() + let CharOnCursor = strpart( getline('.'), col('.')-2, 1) let + CharAfterCursor = strpart( getline('.'), col('.'), 1) if CharOnCursor + !~ ',\|\s\|(' && CharAfterCursor =~ ')\|]\|}' + normal x + endif +endfunction inoremap <Space> <Space>:call CleverSpace()<LF>a + +" I use the last function not only for LaTeX but also in C sources. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Some useful mappings for TeX</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=275">http://vim.sf.net/tip_view.php?tip_id=275</A><BR> + +You know, TeX requires a lot of additional formatting code. I'm tired of +opening and closing braces, brakets, + \beginning and \ending etc. I particularly hate typing \begin and \end. +To help myself and to save a few(not a few) keystrokes I naturaly came up to +some solutions, which I wish to share with other TeXnicians and TeXperts whhich +use Vim. "===============================cut here========================= +"=============== you can put it in ~/.vim/after/ftplugin/tex.vim +=============== " " Note: i_<C-L> " This constructs a skeleton of a TeX +environment. " You write a line like this: " floatingfigure:ht<C-L> +" and after you press <C-L>, you get: " " \begin[ht]{floatingfigure} +" " \end{floatingfigure} " -- INSERT -- " " where floatingfigure is the +desired environment " ht are options " : is delimiter; in fact, you can +use whatever delimiter you want " as long it is not in &iskeyword option. +inoremap <buffer> <C-L> + \:s/[^][:alnum:]<bar>]\+/,/eg + \I\begin{ea}[A]%d%%P \:s/\[,/[/e \:s/,]/]/e + \:s/\[]//e \0f{y%o\endpO +inoremap <buffer> { {}i inoremap <buffer> [ []i inoremap +<buffer> ^ ^{}i inoremap <buffer> _ _{}i inoremap <buffer> +\( \(\)hi inoremap <buffer> \[ \[\]hi + +" Note: v_<C-L> " For this to work, you have to write on a blank +line the name of " the desired environment and options (see i_<C-L>) +and visual select " (from top to bottom) this and following lines. " After +pressing <C-L> the selected lines will be surrounded " with begin/end +skeleton of the environment. vnoremap <buffer> <C-L> o + \:s/[^][:alnum:]<bar>]\+/,/eg + \I\begin{ea}[A]%d%%P \:s/\[,/[/e \:s/,]/]/e + \:s/\[]//e \0f{y%gvoo\endp +" vnoremap <buffer> { di{}P " vnoremap <buffer> +[ di[]P vnoremap <buffer> di^{}P vnoremap <buffer> di_{}P +vnoremap <buffer> \( di\(\)hP vnoremap <buffer> \[ di\[\]hP + +" This makes "two spaces after a comma" before every :write au BufWritePre +*.tex %s/,\(\S\)/, \1/ge + +"==================== You can put this in your ~/.vimrc +======================== " If cursor is inside braces and not before comma, +blank or opening brace, " exit the brace block and stay in insert mode. " +If cursor is outside braces, it inserts a space or perform an abbreviation +" as normal. function! CleverSpace() + let CharOnCursor = strpart( getline('.'), col('.')-2, 1) let + CharAfterCursor = strpart( getline('.'), col('.'), 1) if CharOnCursor + !~ ',\|\s\|(' && CharAfterCursor =~ ')\|]\|}' + normal x + endif +endfunction inoremap <Space> <Space>:call CleverSpace()<LF>a + +" I use the last function not only for LaTeX but also in C sources. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Function signature previewer</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=276">http://vim.sf.net/tip_view.php?tip_id=276</A><BR> + +Have you ever tried to call a function which parameters you have forgotten? +Especially those long named and with long parameter list GTK+ functions +like gtk_menu_item_image_from_stock_new(..........) !!! By accident I saw a +function in Vim help. It's name was PreviewWord and it allowed one to jump +in the preview window to the tag for the word cursor is on. I _slightly_ +modified this function not to need tags file, but to search included files +instead. I wrote another function, which uses the above said one, which +triggers PreviewWord when you open the parenthesis after a function name. +Here it is: " Note: " This is literally stolen from Vim help. The only +changes are: " (1) if w != "" becomes if w =~ "\k" " +(2) exe "silent! ptag " . w becomes exe "silent! psearch " . w " * +The first change prevents PreviewWord of searching while cursor is on some " +non-keyword characters, e.g. braces, asterisks, etc. function! PreviewWord() + if &previewwindow " don't do this in the + preview window + return + endif let w = expand("<cword>") " get the word under + cursor if w =~ "\k" " if there is one + ":ptag" to it + + " Delete any existing highlight before showing another tag + silent! wincmd P " jump to preview + window if &previewwindow " if we really + get there... + match none " delete existing + highlight wincmd p " back to + old window + endif + + " Try displaying a matching tag for the word under the cursor + let v:errmsg = "" exe "silent! psearch " . w if v:errmsg =~ + "tag not found" + return + endif + + silent! wincmd P " jump to preview + window if &previewwindow " if we really get + there... + if has("folding") + silent! .foldopen " don't want + a closed fold + endif call search("$", "b") " to end of + previous line let w = substitute(w, '\\', '\\\\', + "") call search('\<\V' . w . '\>') " + position cursor on match " Add a match highlight to + the word at this position hi previewWord term=bold + ctermbg=green guibg=green exe 'match previewWord "\%' + . line(".") . 'l\%' . col(".") . 'c\k*"' wincmd p + " back to old window + endif + endif +endfunction au! CursorHold *.[ch] nested call PreviewWord() + +" Note: " When you open a parenthesis after a function name, and +at the " line end, that function's definition is previewed through +PreviewWord(). " This is inspired from Delphi's CodeInsight technology. +" Something similar (PreviewClassMembers) could be written for " the C++ +users, for previewing the class members when you type " a dot after an +object name. " If somebody decides to write it, please, mail it to me. +function! PreviewFunctionSignature() + let CharOnCursor = strpart( getline('.'), col('.')-2, 1) if col(".") == + col("$") + call PreviewWord() + endif return "(" +endfunction inoremap <buffer> ( +<C-R>=PreviewFunctionSignature()<LF> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Function signature previewer</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=277">http://vim.sf.net/tip_view.php?tip_id=277</A><BR> + +Have you ever tried to call a function which parameters you have forgotten? +Especially those long named and with long parameter list GTK+ functions +like gtk_menu_item_image_from_stock_new(..........) !!! By accident I saw a +function in Vim help. It's name was PreviewWord and it allowed one to jump +in the preview window to the tag for the word cursor is on. I _slightly_ +modified this function not to need tags file, but to search included files +instead. I wrote another function, which uses the above said one, which +triggers PreviewWord when you open the parenthesis after a function name. +Here it is: " Note: " This is literally stolen from Vim help. The only +changes are: " (1) if w != "" becomes if w =~ "\k" " +(2) exe "silent! ptag " . w becomes exe "silent! psearch " . w " * +The first change prevents PreviewWord of searching while cursor is on some " +non-keyword characters, e.g. braces, asterisks, etc. function! PreviewWord() + if &previewwindow " don't do this in the + preview window + return + endif let w = expand("<cword>") " get the word under + cursor if w =~ "\k" " if there is one + ":ptag" to it + + " Delete any existing highlight before showing another tag + silent! wincmd P " jump to preview + window if &previewwindow " if we really + get there... + match none " delete existing + highlight wincmd p " back to + old window + endif + + " Try displaying a matching tag for the word under the cursor + let v:errmsg = "" exe "silent! psearch " . w if v:errmsg =~ + "tag not found" + return + endif + + silent! wincmd P " jump to preview + window if &previewwindow " if we really get + there... + if has("folding") + silent! .foldopen " don't want + a closed fold + endif call search("$", "b") " to end of + previous line let w = substitute(w, '\\', '\\\\', + "") call search('\<\V' . w . '\>') " + position cursor on match " Add a match highlight to + the word at this position hi previewWord term=bold + ctermbg=green guibg=green exe 'match previewWord "\%' + . line(".") . 'l\%' . col(".") . 'c\k*"' wincmd p + " back to old window + endif + endif +endfunction au! CursorHold *.[ch] nested call PreviewWord() + +" Note: " When you open a parenthesis after a function name, and +at the " line end, that function's definition is previewed through +PreviewWord(). " This is inspired from Delphi's CodeInsight technology. +" Something similar (PreviewClassMembers) could be written for " the C++ +users, for previewing the class members when you type " a dot after an +object name. " If somebody decides to write it, please, mail it to me. +function! PreviewFunctionSignature() + let CharOnCursor = strpart( getline('.'), col('.')-2, 1) if col(".") == + col("$") + call PreviewWord() + endif return "(" +endfunction inoremap <buffer> ( +<C-R>=PreviewFunctionSignature()<LF> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>all the right moves</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=278">http://vim.sf.net/tip_view.php?tip_id=278</A><BR> + +One of the principles of effective text editing is moving around very +efficiently. Following are some pointers which may help u do that. + + h move one character left j move one row down + k move one row up l move one char. right. w move + to begining of next word b move to begining of previous word + e move to end of word W move to begining of next word after a + whitespace B move to begining of pervious word before a whitespace + E move to end of word before a whitespace. + +(All the above movements can be preceeded by a numeric value . i.e '4j' +will move 4 rows down ) + + ^ move to first non blank char of the line. g_ move to last non + blank char of the line. 0 moev to begining of line $ move + to end of line. gg move to first line. G move to last line. + nG move to "n"th line. H top of screen. + M middle of screen + L bottom of screen + Ctrl-D move half page down Ctrl-U move half page up. Ctrl-B page-up + Ctrl-F page down. + + Ctrl-o last cursor position. '[a-z,0-9,A-Z] jump to the marker. (u + can set a marker on line by :- m[a-zA-Z,0-9] and then jump back to + it by '[a-z,A-Z0-9] + + n next matching search pattern N previous matching search pattern * + next word under cursor + # previous word under cursor. g* next matching search pattern + under cursor. g# previous matching search pattern under cursor. + +</pre></tip> </html> <Tip category="KVim"> <html><center>On Windows, make GVim +the default action for double-click with "unknown file types"</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=279">http://vim.sf.net/tip_view.php?tip_id=279</A><BR> + +I find myself installing the following registry modification for all my +PC's now (even other people's PC's). It applies to Microsoft Windows +machines only. The following is also for Windows 9x... NT or XP or 2000 +may require modifications (which I don't care to understand!). + +The problem: You double-click on a file that doesn't have a 'registered type' +and that pesky "What program should I use?" dialog pops up. Even worse, +depending on the installation, the GVim icon may not be listed, and one has +to browse to the executable... and then the type becomes forever bonded +to being editted with GVim (if that box is checked). The standard Vim 6.1 +installation does include a "right click to edit" menu item for all files, +but a double-click is so much faster! + +The solution: What if unregistered types would just automatically open up +in GVim? Well, they can.. with a little registry trickery. + +How to Install it: + +Step 1. Create a text file called "vimalways.reg" and paste the below text +into it. + +Step 2. Important NOTE: You will have to edit the pathname to correspond +to the pathname of your GVim.exe. The text below works fine for a GVim 6.1 +default installation. + +Step 3: Save the file. + +Step 4: Right-click on the file and select "install". Then you are done! + +------ vimalways.reg ------- cut here ------snip---snip--- REGEDIT4 + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open with &GVim] @="Open +with &GVim" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open with &GVim\command] +@="\"C:\\vim\\vim61\\gvim.exe\" \"%1\"" + +----end of file---- cut here----- snip---snip---- + +Note 1. This can't be de-installed automatically, and if you want to remove +it, you'll have to edit the registry by hand (annoying, but easy). + +Note 2. Keep this file around, so when you upgrade your GVim, all you have +to do is modify the pathname (to say, for example, vim62) and then install +it again. + +Ok, thanks for playing! And thanks to the author(s) of Vim and GVim. +If it weren't for them, I'd still be using elvis or stevie! + + +</pre></tip> </html> <Tip category="KVim"> <html><center>Integration +with PyUnit testing framework</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=280">http://vim.sf.net/tip_view.php?tip_id=280</A><BR> + +Vim has a wonderful ability to integrate with external tools, like compilers, +make, ctags etc. That's one of the reasons we love it. + +PyUnit can be seen as a "compiler" for the Python test code. To understand +it, Vim should be told about the language the PyUnit speaks. This could be +done with 'errorformat' option: + +setlocal efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m + +This magic spell enables Vim to parse unittest.TextRunner's output and to +enter quick-fix mode. To run all your unit tests at once you'll need to setup +'makeprg' option and provide a runner. I'm using this setup: + +setlocal makeprg=./alltests.py + +And contents of the alltests.py (for the sake of completeness): + +#!/usr/bin/env python2 + +import unittest import sys sys.path.append('unittests') + +modules_to_test = ( + 'fooTest', 'barTest', 'bazTest', +) + +def suite(): + alltests = unittest.TestSuite() for module in map(__import__, + modules_to_test): + alltests.addTest(unittest.findTestCases(module)) + return alltests + +if __name__ == '__main__': + unittest.main(defaultTest='suite') + +============== end of the alltests.py file ======================== + +While talking about it, I'd also suggest to add a couple of mappings. +In the end, my vim/files/ftplugin/python.vim looks like this: + +setlocal makeprg=./alltests.py\ -q setlocal efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ +line\ %l%.%#,%Z%[%^\ ]%\\@=%m iabbr <buffer> sae self.assertEquals +iabbr <buffer> sar self.assertRaises + +For details see :help quick-fix, :help +'efm' and :help 'makeprg'. See also: <A +HREF="http://c2.com/cgi/wiki?PythonUnit">http://c2.com/cgi/wiki?PythonUnit</A><BR> + +Many thanks to Stefan Roemer who patiently spent quite some time to build +'efm' for me. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Stateful zz</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=281">http://vim.sf.net/tip_view.php?tip_id=281</A><BR> + +Do you find yourself hitting 'zz' all the time in order to see some context of +what you're currently working on? If so, then this tip might be for you. If +you add the following line in your vimrc, you can toggle zz mode by pressing +<Leader>zz. + +" maintain a constant zz state, second call will toggle it back off map +<Leader>zz :let &scrolloff=999-&scrolloff<CR> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Folding with Regular Expression</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=282">http://vim.sf.net/tip_view.php?tip_id=282</A><BR> + +Well, I've tried to understand some of the folding scripts, but life's too +short. Instead, I added the following lines to my vimrc file. + +set +foldexpr=(getline(v:lnum)=~@/)?0:(getline(v:lnum-1)=~@/)\|\|(getline(v:lnum+1)=~@/)?1:2 +map \z :set foldmethod=expr foldlevel=0 foldcolumn=2<CR> + +The first line is an extension of foldexpr=(getline(v:lnum)=~@/)?0:1 The +second line (re)sets the foldmethod to expr(ession) plus. + +First search for /regexp/, then fold everything else with \z Use zr to reveal +more context (before/after) lines. + +You could add (getline(v:lnum-2)=~@/)\|\|(getline(v:lnum+2)=~@/)?2:3 but it +will take longer as folded lines (the majority) evaluate the full expression. + +What could be easier? + +</pre></tip> </html> <Tip category="KVim"> <html><center>Turn +on syntax coloring in Mac OS X</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=283">http://vim.sf.net/tip_view.php?tip_id=283</A><BR> + +This tip is actually for vim 6.1. To turn on syntax coloring in Mac OS X +enter the following commands, or place them in your $HOME/.vimrc file. + +:set term=builtin_beos-ansi :syntax on + +</pre></tip> </html> <Tip category="KVim"> <html><center>Mapping +to print syntax highlighted buffer in B&W</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=284">http://vim.sf.net/tip_view.php?tip_id=284</A><BR> + +I use this mapping to print syntax highlighted C++ code in B&W This tip +needs vimscript #233 print_bw. + +The mapping is as follows map <C-p> :color +print_bw<CR>:hardcopy<CR>:color sean<CR>:syn on<CR> + +Change ":color sean" to whatever is your chosen color scheme. Need to +change line 7 of print_bw from "syntax reset" to "syntax off" <C-p> +on a syntax highlighted buffer turns off syntax highlighting , sets the +colors to B&W, prints the buffer, resets the color scheme and turns on syntax +highlighting again. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Don't use the escape key!</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=285">http://vim.sf.net/tip_view.php?tip_id=285</A><BR> + +Vim (any vi really) is a dream for touch typists... Until you want to switch +from insert mode to normal mode. Then you've got to reach way up to whack +the escape key. + +Or at least that's what I was doing until I realized that (drum roll please) + + Esc is exactly equivalent to control-[ (that's the + control key plus the left square bracket key) + +That little bit of knowledge, plus mapping my caps lock to another control +key, was what turned my fascination with Vim into true love. You never have +to lose track of the home row again! + +For Xfree86 users - you can make the capslock key another control key by adding + +Option "XkbOptions" "ctrl:nocaps" + +to the InputDevice section of your XF86Config file. + +For Windows NT/2000 users - use the following .reg file to do the same thing: + +REGEDIT4 + +[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] +"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00 + +</pre></tip> </html> <Tip category="KVim"> <html><center>Recover +after doing something... ugly.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=286">http://vim.sf.net/tip_view.php?tip_id=286</A><BR> + +I was once editing a file and wanted to test something. The test was meant +to add a line at the end of the file, from outside vim. All was fine, but +instead of >>, I wrote >. You can imagine what happened... :) + +If you happen to do something like that, the solution is: + +:recover + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Cool trick to change numbers</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=287">http://vim.sf.net/tip_view.php?tip_id=287</A><BR> + +In the gvim if you want to decrement any number just put ur curcor on that +number in Esc mode and pres <CTRL> X + +</pre></tip> </html> <Tip category="KVim"> <html><center>A keymapping +to generate Java setters and getters automatically</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=288">http://vim.sf.net/tip_view.php?tip_id=288</A><BR> + +This mapping makes it much simpler to write new java classes by simplifying +some of the dull repetative coding (ie setters and getters). + +To use, first write a basic class with the following format: + +public class MyClass { + + private <type> <varname> = <initvalue>; private + <type> <varname> = initvalue>; + + // getters + + // setters + +} + +Note the getters/setters comment -- they are important as they are used to +place the getters and setters. + +The mapping is: + +map jgs mawv/ <Enter>"ty/ +<Enter>wvwh"ny/getters<Enter>$a<Enter><Enter>public +<Esc>"tpa<Esc>"npbiget<Esc>l~ea()<Enter>{<Enter><Tab>return +<Esc>"npa;<Enter>}<Esc>=<Enter><Esc>/setters<Enter>$a<Enter><Enter>public +void <Esc>"npbiset<Esc>l~ea(<Esc>"tpa +<Esc>"npa)<Enter>{<Enter><Tab>this.<Esc>"npa=<Esc>"npa;<Enter>}<Esc>=<Enter>`ak + +(the above should be one long line with no spaces between the end of the +lines above). + +To use this to generate a class go to the variable that should have a +setter/getter and place the curser at the beginning of the 'private': + + private <type> <variable> = <initvalue>' ^ + +Then type: + +jgs + +this will create the first getter/setter and then move up to the next +variable. You can just keep typing jgs until all the getters/setters have +been generated. + +This should mapping isn't perfect and someone could probably make it a little +cleaner. It could also relatively easily be adapted to C++. Please feel free +to send me any feedback/enhancements as I am trying to compile a list of these. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Alternative +<escape> that allows you to do a "quick and dirty +insert" and get out into normal mode</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=289">http://vim.sf.net/tip_view.php?tip_id=289</A><BR> + +This is an alternative key combo for the escape key from the one mentioned +by David A. Rogers in vimtip #285. + +I do a lot of editting in Vim, and I've always found myself in situations where +I had to "do a quick insert" - basically (from normal mode), change into insert +mode, type in one quick word, then <esc> out, then navigate elsewhere. + +As has been rightly observed by a lot of people, the <esc> key can +sometimes be a little bit out of the way. But that's no problem for ViM, is it? + +At first, I thought of editting the ViM source code itself, in order to come +up with a command that could do things like say "let me jump into insert +mode, type a few quick words, then escape out into normal mode when i press +something like double <space>". + +It was only later when reading through the section in +Jesse Goerz's "Beginner's Guide to ViM" on remapping (<A +HREF="http://newbiedoc.sourceforge.net/tutorials/vim/mapping-vim.html) +that I got inspired to retake a look at using remapping as an alternative +instead.">http://newbiedoc.sourceforge.net/tutorials/vim/mapping-vim.html) +that I got inspired to retake a look at using remapping as an alternative +instead.</A><BR> + +This is what I came up with.. Use whatever is comfortable for you - single +or double <Shift-space> + +:map! <S-space> <esc> :map! <S-space><S-space> +<esc> + +With this quick combo ("Shift", + <space>), one can easily (and might +I add, intuitively) "do a quick insert" and exit quickly out into normal +mode. I guess I always thought the <space> would be a good way to +do this sort of thing, since it is after all, so intuitive in the typing +process. So why not make it such that it can "escape" you out into normal +mode as well? Just type 'i', to go into insert mode, type in your stuff, +and once you're done, hit Shift-space! + +</pre></tip> </html> <Tip category="KVim"> <html><center>Text +Processing With Integrated Spell Checking</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=290">http://vim.sf.net/tip_view.php?tip_id=290</A><BR> + +I have written an HTML document to help others use Vim as a basic text +processing application. It discusses how to integrate spell checking, +dictionary, and thesaurus applications. It also talks about wrapping lines, +indentation, justification, and the vim settings that effect the behavior +of these operations. The document can be found at: + <A + HREF="http://www.highley-recommended.com/text-processing.html">http://www.highley-recommended.com/text-processing.html</A><BR> + +Everything has been tested with UNIX, Linux, Windows, and Windows with +Cygwin patforms. + +</pre></tip> </html> <Tip category="KVim"> <html><center>^P +& auto filling of variables and text</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=291">http://vim.sf.net/tip_view.php?tip_id=291</A><BR> + +Do you know you can auto fill the variable and names as you type your code +? This will help most of the programmers, who always try hard to remember the +variable names and browse through all the files to find out the variable name. + Use Ctrl+P and Ctrl+N to autofill the variables names etc. Just practice, + you will feel the ease of using vim + +</pre></tip> </html> <Tip category="KVim"> +<html><center>vim + cscope + cygwin</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=292">http://vim.sf.net/tip_view.php?tip_id=292</A><BR> + +I've found that vim + cscope + cygwin does not work. The problem seems to +be that in + +sprintf(cmd, "exec %s -dl -f %s", prog, csinfo[i].fname); + +vim execs cscope with the "-dl" options, causing it to fail. It is probably +a cscope bug, but a simple workaround is top build vim without thad "d": + +sprintf(cmd, "exec %s -l -f %s", prog, csinfo[i].fname); + +seems to work for me! + +</pre></tip> </html> <Tip category="KVim"> <html><center>remember +where you had ended reading help</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=293">http://vim.sf.net/tip_view.php?tip_id=293</A><BR> + +You could jump to the last place you had been while reading Vim help files +if you add this to your .vimrc file: + +au BufLeave * if &ft == "help" | mark H | endif + +Then use 'H to go to the mark H. + +To work between Vim runs 'viminfo' option should be setup to save file marks. +See :help 'viminfo' and :help file-marks for more information. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Use +Ctrl-S to save current or new files.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=294">http://vim.sf.net/tip_view.php?tip_id=294</A><BR> + +I wanted to have a single key stroke that would save existing files, or call +the file browser. Here's a key map for Ctrl-S to accomplish that (place in +vimrc file): + +if has("gui_running") + " If the current buffer has never been saved, it will have no name, + " call the file browser to save it, otherwise just save it. :map + <silent> <C-S> :if expand("%") == ""<CR>:browse confirm + w<CR>:else<CR>:confirm w<CR>:endif<CR> +endif + +Tom Kimpton + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Line/word/file/whatever completion</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=295">http://vim.sf.net/tip_view.php?tip_id=295</A><BR> + +In addition to vimtip #291 you can use whole <C-x> completion mode. It +can complete whole lines (<C-x>l, then <C-p>, <C-n>), +filenames (<C-f>), keywords, words from custom dictionary and many, +many others. During coding it usually saves a LOT of key strokes ;) This +mode has many other powerful features, for example when completing word (by +<C-x><C-p> or just by <C-p>) you can continue completion +with another <C-x><C-p>. For example, after writing such text: + +this is first line second line is here + +Placing cursor at third line and pressing <C-x>l will double last +line - <C-n>, <C-p> in this moment can be used to manipulate +completed line. Or, instead of completing whole line you can press 'f' and +then complete by <C-p> which will result in 'first' word. After that +you can <C-x><C-p> to get 'line' word (since this is next word +after 'first'). Try yourself for other powerful combinations. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Attach +the currently open file to email</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=296">http://vim.sf.net/tip_view.php?tip_id=296</A><BR> + +This is very simple, but most people don't seem to take advantage of +this. Often you have some file (source code or other text file) already open +in an existing vim session and you need to attach it with an email. It is +very simple. + - First copy the filename into clipboard. For this I put the following + mapping in vimrc and press <F2>: + nnoremap <F2> :let @*=expand("%:p")<cr> + - Go to your email compose window and use your regular file attachment + menu (Insert->File in outlook) and press ^V (or whatever key to paste + clipboard) and press Enter. + +That is all there to it. If you are on windows and your email client doesn't +accept forward-slashes, then you might want to change the map to: + + nnoremap <F2> :let @*=substitute(expand("%:p"), "/", "\\", + "g")<cr> + +HTH, Hari + +</pre></tip> </html> <Tip category="KVim"> <html><center>Start +in insert mode without loosing your escape key</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=297">http://vim.sf.net/tip_view.php?tip_id=297</A><BR> + +There are two parts to this, each is fairly simple. + +First, I want to start in insert mode. Well "set im!" in my vimrc did the +job, but I lost the escape key. Second, I have found that often times, +when I'm in command mode, I hit escape trying to get back into insert mode. +I am always rewarded with a beep, telling me once again I made that mistake. + +So I mapped esc in command mode to set insert mode (":set im") and I mapped +esc in insert mode to unset insert mode (<c-o>:set im) Well then I +realized if you hit "i" in command mode, escape woulding work the first time. +So here's the code to add to your vimrc: + +set im! " start in insert mode map <esc> :set +im!<cr> " escape in command mode goes to insert mode map +i :set im!<cr> " i in command mode goes to insert mode +map! <esc> <c-o>:set im!<cr> " escape in insert mode goes +to command mode + +see :help insert + +</pre></tip> </html> <Tip category="KVim"> <html><center>Changing +case with regular expressions</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=298">http://vim.sf.net/tip_view.php?tip_id=298</A><BR> + +I stumbled across this factoid on a website about vi. I haven't been able to +locate it in the Vim documentation, but it works in Vim, and it's very handy. + +There are times that you might like to go through a file and change the case +of characters that match some arbitrary criteria. If you understand regular +expressions well, you can actually do this fairly easily. + +It's as simple as placing \U or \L in front of any backreferences in your +regular expressions. Vim will make the text in the backreference uppercase +or lowercase (respectively). + +(A "backreference" is a part of a regular expression that refers to a previous +part of a regular expression. The most common backrefernces are &, \1, \2, +\3, ... , \9). + +Some examples that demonstrate the power of this technique: + +Lowercase the entire file - :%s/.*/\L&/g + +(& is a handy backreference that refers to the complete text of the match.) + +Uppercase all words that are preceded by a < (i.e. opening HTML tag names): +:%s/<\(\w*\)/<\U\1/g + +Please add a note if you know where this is in the documentation. I have +done Ctrl-D searches on upper, lower, \U, and \L with no luck. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Open file under cursor.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=299">http://vim.sf.net/tip_view.php?tip_id=299</A><BR> + +A little thing that I did and found quite useful: + +function! OpenFileUnderCursor() + let FileName = expand("<cfile>") let OldPath = getcwd() silent cd + %:p:h execute "silent sp +e " . FileName execute "silent cd " . OldPath +endfunction + +map! silent <M-e> :call OpenFileUnderCursor()<CR> + +Then use Alt+E on a filename to open it (relative to the directory the +current file resides in). + +</pre></tip> </html> <Tip category="KVim"> <html><center>Making +a tags file for IDL (Interactive Data Language)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=300">http://vim.sf.net/tip_view.php?tip_id=300</A><BR> + +I have recently began using the tags features of vim (:help tags) with my +fortran codes and come to appreciate their power. I also do a lot of coding +in IDL (Interactive Data Language), but found that ctags did not have native +support for IDL. If you take the time you can learn how to get ctags to +support IDL, but I found, after a search of usenet, that someone else has +already done this and written a perl script called idltags. It is part +of an emacs package (is anyone still reading?) that you need to download, +called idlwave, which is located at: + <A HREF="http://idlwave.org/">http://idlwave.org/</A><BR> +and currently (I don't know if this will change) the direct download link is + <A + HREF="http://idlwave.org/download/idlwave.tar.gz">http://idlwave.org/download/idlwave.tar.gz</A><BR> +In the usenet pages the maintainer, JD Smith, was suggesting that idlwave +had outgrown idltags and was not sure it was still needed, so I don't know +how long it will be available. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Edit +files in path, or related.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=301">http://vim.sf.net/tip_view.php?tip_id=301</A><BR> + +You can write a little shell function that will let you easily edit any file +that is in the path, or which's location can be retrieved with the whereis +tool. This is something similar to what I have in /etc/profile: + +function vvim() { vim `whereis $1|cut -d: -f2` } function ggvim() { gvim +`whereis $1|cut -d: -f2` } + +Then just type, for example, "vvim ls", and you'll start vim with /bin/ls +and /usr/share/man/ls.1.gz loaded :) (it's not very useful to edit /bin/ls, +but you get the ideea ;) + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Use gvim in kmail</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=302">http://vim.sf.net/tip_view.php?tip_id=302</A><BR> + +To automatically open gvim to edit in kmail, "-f" command line option must +be used . In kmail configuration go to the composer settings , and write +in the "use external editor" field the following command : "gvim -f %f" +Without -f option gvim would work in background and editing would not have +any effect on kmail. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Statusline +Tab Level Function Ruler TVIM</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=303">http://vim.sf.net/tip_view.php?tip_id=303</A><BR> + +I use this function to let me know if my cursor is on a TAB column. The t* +on the ruler means I am not. But t3 means the cursor is on tablevel 3 ~vimrc +----------------------- My Ruler ------------------------ r4,c13,t3 ~vimrc +----------------------- My Ruler ------------------------ r4,c14,t* If you +want to change a tab level you can drag or push the first character of a line +to a desired tab level. (more on that later) This ruler replacement will let +you know where you are, whether you like to use space tabs (see vimtip #12 ) +or regular tabs. My function is set to four space tabs stops and only goes +9 levels but can be easily modified. + +Actually I just wanted to learn how to use a function in my _vimrc and this +was my first attempt. Add this to your _vimrc + +"--------------------cut------------------ set laststatus=2 "This makes sure +the ruler shows. See help laststatus set statusline=%f\ ---------\ My\ +Ruler\ ----------\ r%l,c%c,t%{ShowTab()} "See help statusline (I toggle +between 12 helpful rulers -- more on that later) fu ShowTab() + let TabLev='*' let Col=(col(".")) if Col == 1 | let TabLev='0' | + en if Col == 5 | let TabLev='1' | en if Col == 9 | let TabLev='2' | + en if Col ==13 | let TabLev='3' | en if Col ==17 | let TabLev='4' | + en if Col ==21 | let TabLev='5' | en if Col ==25 | let TabLev='6' | + en if Col ==29 | let TabLev='7' | en if Col ==33 | let TabLev='8' | + en if Col ==37 | let TabLev='9' | en +return TabLev endf "The ruler (statusline) shows a t* unless you are on +col 1,5,9,13,... "-------------------cut------------------- + +This function ShowTab() gets called and updates the ruler with every cursor +move but it does not slow things down as I type. Perhaps a speed typist +may complain :-) In case I write something else you may search on the key +word TVIM Best Wishes TVIM Tamed Vim paradocs@frontiernet.net + +</pre></tip> </html> <Tip category="KVim"> +<html><center>fold braces and javadoc</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=304">http://vim.sf.net/tip_view.php?tip_id=304</A><BR> + +If you'd like to have javadoc folded together with areas in braces try that +<pre> set foldmethod=syntax set foldenable syn region foldBraces +start=/{/ end=/}/ transparent fold syn region foldJavadoc start=,/\*\*, +end=,\*/, transparent fold keepend </pre> and play a bit with: +<pre> set foldlevel=0 set foldnestmax=10 </pre> parameters + +</pre></tip> </html> <Tip category="KVim"> <html><center>Best +of VIM Tips (VIM's best Features)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=305">http://vim.sf.net/tip_view.php?tip_id=305</A><BR> + +Here's a necessarily cryptic list of "MY" Best Vim Tips +that I've gleaned from <A HREF="http://vim.sf.net/ & +comp.editors ">http://vim.sf.net/ & comp.editors </A><BR> <A +HREF="http://groups.google.com/groups?safe=off&group=comp.editors">http://groups.google.com/groups?safe=off&group=comp.editors</A><BR> + +updated version at <A +HREF="http://www.rayninfo.co.uk/vimtips.html">http://www.rayninfo.co.uk/vimtips.html</A><BR> +------------------------------------------------------------------------------ +# Absolutely essential +------------------------------------------------------------------------------ +vim.sf.net : Visit frequently comp.editors : "VIM" dominated +newsgroup * # g* g# : find word under cursor (forwards/backwards) +% : match brackets {}[]() matchit.vim : % now matches +tags <tr><td><script> etc <C-N> <C-P> : word +completion in insert mode <C-X><C-L> : Line complete SUPER +USEFUL /<C-R><C-W> : Pull <cword> onto search/command +line :set ignorecase # you nearly always want this :syntax on : colour +syntax in Perl,HTML,PHP etc :h slash<C-D> : type control-D and get a +list all help topics containing + slash (plus use TAB for Help completion) +------------------------------------------------------------------------------ +# MAKE IT EASY TO UPDATE/RELOAD_vimrc :nmap +,s :source $VIM/_vimrc :nmap ,v :e $VIM/_vimrc +------------------------------------------------------------------------------ +#VISUAL MODE Mappings :vmap sb "zdi<b><C-R>z</b><ESC> +: wrap <b></b> around VISUALLY selected +Text :vmap st "zdi<?= <C-R>z ?><ESC> +: wrap <?= ?> around VISUALLY selected Text +------------------------------------------------------------------------------ +# Exploring :Ex : file explorer note capital Ex \be +: builtin buffer explorer :ls : list of buffers(eg +following) :cd .. : move to parent directory +------------------------------------------------------------------------------ +# Great guu : lowercase line gUU +: uppercase line gf : open file name under +cursor (SUPER) ga : display hex,ascii value of +character under cursor ggVGg? : rot13 whole file +CTRL-A,CTRL-X : increment,decerement number under cursor + win32 users must remap CNTRL-A +CTRL-R=5*5 : insert 25 into text +------------------------------------------------------------------------------ +# Makes all other tips superfluous :h 42 :h holy-grail :help! +------------------------------------------------------------------------------ +# Markers & moving about '. : jump to last modification +line (SUPER) `. : jump to exact spot in last modification +line <C-O> : retrace your movements in file +(old) <C-I> : retrace your movements in file (new) +:ju(mps) :help jump-motions :history : list of all your commands +------------------------------------------------------------------------------ +# Abbreviations & maps :map <f7> :'a,'bw! c:/aaa/x :map <f8> +:r c:/aaa/x :map <f9> :w<CR>:!c:/php/php.exe %<CR> +:map <f11> :.w! c:/aaa/xr<CR> :map <f12> :r +c:/aaa/xr<CR> :ab php : list of abbreviations beginning +php :map , : list of maps beginning , # For use in Maps +<CR> : carriage Return for maps <ESC> : +Escape <LEADER> : normally \ <BAR> : | pipe +------------------------------------------------------------------------------ +# List your Registers :reg : display contents +of all registers "1p.... : retrieve numeric buffers +------------------------------------------------------------------------------ +# Useful trick "ayy@a : execute "Vim command" in a +text file yy@" : same thing using unnamed register +------------------------------------------------------------------------------ +# Get output from other commands :r!ls.exe : +reads in output of ls !!date : same thing +:%!sort -u : use an external program to filter content +------------------------------------------------------------------------------ +# Multiple Files Management :wn : write file and move to +next (SUPER) :bd : remove file from buffer list (SUPER) +:sav php.html : Save current file as php.html and "move" to php.html +:sp fred.txt : open fred.txt into a split :e! : return to +unmodified file :w c:/aaa/% : save file elsewhere :e # : +edit alternative file :e % :rew : rewwind to first file in +ARGS :bn : next file :bp : next file :brew +------------------------------------------------------------------------------ +# Recording (BEST TIP of ALL) qq # record to q your commands +q @q to execute @@ to Repeat # editing a register/recording "ap +<you can now see register contents, edit as required> "add @a +------------------------------------------------------------------------------ +# _vimrc essentials :set incsearch : jumps to search word as you type (annoying +but excellent) :set wildignore=*.o,*.obj,*.bak,*.exe :set shiftwidth=3 +------------------------------------------------------------------------------ +# launching Win IE :nmap ,f :update<CR>:silent +!start c:\progra~1\intern~1\iexplore.exe +file://%:p<CR> :nmap ,i :update<CR>: !start +c:\progra~1\intern~1\iexplore.exe <cWORD><CR> +------------------------------------------------------------------------------ +# FTPing from VIM cmap ,r :Nread <A +HREF="ftp://209.51.134.122/public_html/index.html +">ftp://209.51.134.122/public_html/index.html </A><BR> cmap ,w :Nwrite <A +HREF="ftp://209.51.134.122/public_html/index.html">ftp://209.51.134.122/public_html/index.html</A><BR> +gvim <A +HREF="ftp://209.51.134.122/public_html/index.html">ftp://209.51.134.122/public_html/index.html</A><BR> +------------------------------------------------------------------------------ +# appending to registers (use CAPITAL) # yank +5 lines into "a" then add a further 5 "a5yy 10j "A5yy +------------------------------------------------------------------------------ +[I : show lines matching word under cursor <cword> +------------------------------------------------------------------------------ +#Conventional Shifting :'a,'b>> # visual shifting +(builtin-repeat) :vnoremap < <gv :vnoremap > >gv +------------------------------------------------------------------------------ +# searching /^joe.*fred.*bill/ : normal /^[A-J]\+/ : search +for lines beginning A-J followed by at leat 1 A-J /forum\(\_.\)*pent +search over possible multiple lines /fred\_s*joe/i : any +whitespace including newline /fred\|joe : Search for FRED OR JOE +------------------------------------------------------------------------------ +#substitution :%s/fred/joe/igc : general substitute command +:%s/\r//g : Delete DOS returns ^M :'a,'bg/fred/s/dick/joe/gc +: VERY USEFUL :s/\(.*\):\(.*\)/\2 : \1/ : reverse fields separated +by : :%s/^.\{-}pdf/new.pdf/ non greedy matching (ie to first pdf) +:s/fred/<c-r>a/g substitute "fred" with contents of register "a" +:%s/^\(.*\)\n\1/\1$/ delete duplicate lines # non-greedy matching +\{-} :%s/^.\{-}pdf/new.pdf/ :help /\{-} :s/fred/<c-r>a/g +substitute "fred" with contents of register "a" # multiple commands +:%s/\f\+\.gif\>/\r&\r/g | v/\.gif$/d | %s/gif/jpg/ :%s/suck\|buck/loopy/gc +: ORing :s/__date__/\=strftime("%c")/ : insert datestring +------------------------------------------------------------------------------ +# global command :g/^\s*$/d :delete all blank lines :g!/^dd/d : +delete lines not containing string :v/^dd/d : delete lines not +containing string :g/fred/,/joe/d : not line based :v/./.,/./-1join : compress +empty lines :'a,'b g/^Error/ . w >> errors.txt :g/cmap\|form/p : ORing +------------------------------------------------------------------------------ +# Paste register * :redir @* : redirect commands to paste :redir +END "*yy : yank to paste "*p : insert paste buffer +------------------------------------------------------------------------------ +# Formatting text gq<CR> gqap (a is motion p paragraph (visual mode)) +------------------------------------------------------------------------------ +# Operate command over multiple files :argdo +%s/foo/bar/ :bufdo %s/foo/bar/ :windo %s/foo/bar/ +------------------------------------------------------------------------------ +# Command line tricks gvim -h ls | gvim - : edit a PIPE!! # +vg.ksh (shell script) # vi all files in directory containing +keyword $1 and jump to $1 gvim.exe -c "/$1" $(grep -isl "$1" *) & +------------------------------------------------------------------------------ + +</pre></tip> </html> <Tip category="KVim"> <html><center>Open a +web-browser with the URL in the current line</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=306">http://vim.sf.net/tip_view.php?tip_id=306</A><BR> + +function! Browser () + let line = getline (".") let line = matchstr (line, "http[^ ]*") exec + "!netscape ".line +endfunction + +map <Leader>w :call Browser ()<CR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>annoying +"Hit any key to close this window..."</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=307">http://vim.sf.net/tip_view.php?tip_id=307</A><BR> + +i use gvim and bash heavily under win98. i have + +let $HOME = substitute($HOME, '\\', '/', 'g') set shell=bash\ --rcfile\ +\"$HOME\"_bashrc\ -i + +in my _vimrc, and something like + +function br() { if [ $1 ]; then + explorer.exe ${1//\//\\} + else + explorer.exe ${PWD//\//\\} + fi +} + +in my _bashrc. when i finish editing one html file, i simply type :!br % + +everything works fine now. but when :!br % executes, one console window will +bump out and wait me to press some key to contiue. i consider this quiet +annoying. i want the console window to disappear automatically if no fault +has happened. does anyone know how to achieve this? thanks. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Move through wrapped lines.</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=308">http://vim.sf.net/tip_view.php?tip_id=308</A><BR> + +If you don't like the fact that when you press Up and Down on a wrapped line, +you get to the next phisical line instead of the next line on the screen, +you can do something like this: + +imap <silent> <Down> <C-o>gj imap <silent> <Up> +<C-o>gk + +nmap <silent> <Down> gj nmap <silent> <Up> gk + +</pre></tip> </html> <Tip category="KVim"> <html><center>close +vim you left open remotely</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=309">http://vim.sf.net/tip_view.php?tip_id=309</A><BR> + +Vim 6 has this cool client-server protocol. I use it all the time to edit +a file in an existing gvim, like so $ gvim --remote [filename] + +Today I left myself logged in at the console at work, and when I got home +I realized I had left vim running with files unsaved. I think I even left +it in insert mode. I wanted to edit these files at home. So I ssh'd to the +machine and started playing with the --remote commands. + +:help was a bit cryptic + --remote-send {keys} Send {keys} to server and exit. + +After a lot of failed attempts, I finally succeeded in getting the remote +vim to save its buffers and quit. + +$ DISPLAY=:0 vim --servername GVIM --remote-send '<ESC>:wqa<CR>' + +A couple of notable things. Then environment variable DISPLAY has to be the +display of the remote vim, and you have to be able to open that display. The +client-server stuff is done through X. + +The <CR> is important. This part eluded me for a long time. The {keys} +are just like keys you would press if you were editing at the console, +and you have to press enter, or vim won't do anything. + +Check your .swp files to make sure vim really closed the files it was +editing. Vim provides little feedback as to the success or failure of what +you're trying to do remotely. Nonetheless, it's clearly a useful feature to +have available. + +</pre></tip> </html> <Tip category="KVim"> <html><center>showing ascii +value of the current character in decimal, hex, and octal</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=310">http://vim.sf.net/tip_view.php?tip_id=310</A><BR> + +dont know if you guys know this or not, but i was trying to make the word +"hello" to upper case by trying "gaUw" (= which didnt work but it showed +the decimal, hex, and octal of the char under the cursor... ncie to know. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Open +the folder containing the currently open file</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=311">http://vim.sf.net/tip_view.php?tip_id=311</A><BR> + +Occasionally, on windows, I have files open in gvim, that the folder for that +file is not open. This key map opens the folder that contains the currently +open file. The expand() is so that we don't try to open the folder of an +anonymous buffer, we would get an explorer error dialog in that case. + +if has("gui_running") + if has("win32") + " Open the folder containing the currently open file. Double <CR> at + end " is so you don't have to hit return after command. Double quotes are + " not necessary in the 'explorer.exe %:p:h' section. :map <silent> + <C-F5> :if expand("%:p:h") != ""<CR>:!start explorer.exe + %:p:h<CR>:endif<CR><CR> + endif +endif + +Tom. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Copy, Cut, and Paste</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=312">http://vim.sf.net/tip_view.php?tip_id=312</A><BR> + +PS: copy, cut, and paste are the words from (usually) gui editor. + +Ever try to cut (or copy) some lines and paste to another place? If you +need to count the lines first, then try these to eliminate counting task. + +Cut and Paste: + +1. Place the cursor at the beginning of the block you want to CUT. 2. Mark +it with md 3. Go to the end of the block. 4. Cut it with d'd 5. Go to the +new location that you want to PASTE those text. 6. Press P. + +Copy and Paste: + +1. Place the cursor at the beginning of the block you want to COPY. 2. Mark +it with my 3. Go to the end of the block. 4. Cut it with y'y 5. Go to the +new location that you want to PASTE those text. 6. Press P. + +The name of the mark used is related to the operation (d:delete or y:yank). +I found that those mark names requires minimal movement of my finger. ;) + +</pre></tip> </html> <Tip category="KVim"> <html><center>printing +using kprinter (unix + kde)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=313">http://vim.sf.net/tip_view.php?tip_id=313</A><BR> + +just add set printexpr=system('kprinter'\ .\ '\ '\ .\ v:fname_in)\ .\ +delete(v:fname_in)\ +\ v:shell_error to your ~/.vimrc; further on all your +printing will be piped through the nice and consistent print-dialog of kde. + +lg, tomte + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Insert and back...</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=314">http://vim.sf.net/tip_view.php?tip_id=314</A><BR> + +this is related to vimtip #289 in terms of programmers (like I) too lazy to +move their hands to reach the far far away <esc> key.... joking! :) + actually the less your hands move around the faster you type, and the fester + you type the more time you have on your hands to think of "what" you type... + +here is a small snippet from my mappings file, ready to speed things up: // +the key overloading might be a somewhat confusing at first.... + +--cut--- imap <S-Space> <esc>l imap <C-CR> <esc>o +imap <S-CR> <esc>O + +nmap <S-Space> i nmap <space><space> i nnoremap <CR> +o nmap <S-CR> O + +---uncut--- + +Good luck!! + +</pre></tip> </html> <Tip category="KVim"> +<html><center>"Smart <home>"</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=315">http://vim.sf.net/tip_view.php?tip_id=315</A><BR> + +to make it faster to navigate through indented code here is a common way to +"go home"... + +---cut--- fun! s:SmartHome() + if col('.') != match(getline('.'), '\S')+1 + norm ^ + else + :call cursor(line('.'),2) norm h + endif +endfun inoremap <silent><home> <C-O>:call +<SID>SmartHome()<CR> nnoremap <silent><home> :call +<SID>SmartHome()<CR> vnoremap <silent><home> :call +<SID>SmartHome()<CR> + +---uncut--- + +what this snippet does is make the <home> key behave as it does in +such IDEs as PythonWin or MSVisualStudio, and that is first go to the first +non whitespace, and then to the first char on the line. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Using +/pattern/ search in a script</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=316">http://vim.sf.net/tip_view.php?tip_id=316</A><BR> + +There are a number of ways you can search for a pattern in a script. +The search function is the typical way to search for a pattern. But, it +has limited options. In particular, there are no options to control the +position of the cursor after it matches the pattern. + +Instead you can use :normal command. The secret is to add a <CR> +(^M) on the end of the command. For example, to search for "pattern" +and move the cursor to the end of the matching pattern issue the command: + +:normal /pattern/e+1^M + +where ^M is a real carriage return. It can be entered with +<c-v><c-m>. + +Another use is when you want to enter a bunch of normal commands together. +For example, if you were looking to find a '{' to highlight and delete +a C block. The '{' may not be on the same line so you can't use the "f" +normal command. + +:normal V/{/^M%d + +A drawback to using the normal command is that if the pattern does not +match then it is difficult to detect. Also, you can get in trouble with +the wrapscan setting. + +For more information about these commands look at + +:help / :help normal :help search() + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Mozilla Vim Keybindings</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=317">http://vim.sf.net/tip_view.php?tip_id=317</A><BR> + +If you use VIM you like the h, j, k, and l movement keys. I found myself +annoyed at not having these movement keys available when browsing web pages. +Moving to the arrow keys on a laptop is annoying to just scroll the page. + +Locate your mozilla/res/builtin directory (varies by platform). You could +search for htmlBindings.xml to find it. (ie. locate htmlBindings.xml. + +On Mac OS X it's inside the Mozilla application bundle. +/Applications/Mozilla/Mozilla.app/Contents/MacOS/res/builtin. + +Create a new XML file called userHTMLBindings.xml, making it executable for +all users and making sure the CRLF format is the same as htmlBindings.xml. +i.e. on Mac OS X most files use \r but Vim writes \n instead. You can either +save the file with Vim as a Mac formatted file or use tr '\n' '\r' < +input.xml > output.xml to convert the file. + +Place the following XML into the userHTMLBindings.xml file. + +<?xml version="1.0"?> + +<bindings id="htmlBindings" + xmlns="<A + HREF="http://www.mozilla.org/xbl"">http://www.mozilla.org/xbl"</A><BR> + xmlns:xul="<A + HREF="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">">http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"></A><BR> + + <binding id="browserUser"> + <handlers> + <handler event="keypress" key="h" command="cmd_scrollLeft"/> + <handler event="keypress" key="j" command="cmd_scrollLineDown"/> + <handler event="keypress" key="k" command="cmd_scrollLineUp"/> + <handler event="keypress" key="l" command="cmd_scrollRight"/> + </handlers> + </binding> + </bindings> + +There are many more bindings one could configure to get Vim like keybindings. +You can read <A HREF="http://www.mozilla.org/unix/customizing.html#keys for +more information.">http://www.mozilla.org/unix/customizing.html#keys for +more information.</A><BR> + +PS. I love the keymaster/gatekeeper xul reference in the xul URL above. +It's from the original GhostBusters movie. ;-) + + + +</pre></tip> </html> <Tip category="KVim"> <html><center>Extended +Bracket and Parenthesis + extras for perl</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=318">http://vim.sf.net/tip_view.php?tip_id=318</A><BR> + +This is an extension of vimtip #153 I found this tip useful, but the jump +seemed out of place for me, I couldn't enter just one ' or ", and so I created +an improvement Basically, I set it up so that when you're in perl and have +a non keyword charcter, (except for @, $ and % for perl) and you type a { +you get: { + | <- cursor +} Where as, when I have a keyword I get: word{} With the cursor in the middle, +for hashes in perl. I can jump out of any block, except the "" or '' blocks, +by typing their closing charcter. So } jumps me out past the next } in +the file. + +Warning, this search may wrap around. + +Finally, I made it so that, using the alt key, <Alt-'> inserts a ' +<Alt-/> inserts a " <Alt-[> inserts a [ <Alt-]> inserts a +] <Alt--> inserts a { <Alt-=> inserts a } <Alt-,> inserts +a < <Alt-.> inserts a > + +"######################################## " File - +matchMe.vim " Date - Wednesday, August 21, 2002 +"######################################## + +" This code fixes my problem with " does the one format for perl and still +keeps hashes function! InsertBrackets() + let fileType = &ft + + if fileType == 'perl' + let col = col('.') - 1 if !col || getline('.')[col - 1] !~ + '\k' && getline('.')[col - 1] !~ '\$' && getline('.')[col - 1] + !~ '@' && getline('.')[col - 1] !~ '%' && getline('.')[col - + 1] !~ '#' + return "{\<cr>\<bs>}\<esc>ko" + else + return "{}\<esc>i\<c-o>:echo \<cr>" + endif + else + return "{\<cr>\<bs>}\<esc>ko" + endif +endfunction + +" This code jumps out of the brackets function! JumpNext(normChar) + let ret = + "\<space>\<esc>ma\<left>/\\".a:normChar."\<cr>mb`ai\<del>\<esc>`bi\<right>" + return ret +endfunction + +" mappings inoremap " ""<esc>i<c-o>:echo +<cr> inoremap ' ''<esc>i<c-o>:echo <cr> +inoremap < <><esc>i<c-o>:echo <cr> +inoremap ( ()<esc>i<c-o>:echo <cr> inoremap [ +[]<esc>i<c-o>:echo <cr> inoremap { <c-r>=InsertBrackets +()<cr> inoremap > <c-r>=JumpNext(">")<cr> +inoremap ) <c-r>=JumpNext(")")<cr> +inoremap ] <c-r>=JumpNext("]")<cr> inoremap } +<c-r>=JumpNext("}")<cr> inoremap <m-[> [ inoremap <m-]> +] inoremap <m-/> " inoremap <m--> { inoremap <m-=> } +inoremap <m-,> < inoremap <m-.> > inoremap <m-'> ' + +"######################################## " End Of File +"######################################## + +If you have any other suggestions, drop a note... + +</pre></tip> </html> <Tip category="KVim"> <html><center>text +formatting (lining up ='s,('s etc))</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=319">http://vim.sf.net/tip_view.php?tip_id=319</A><BR> + +some time onw would like to reformat text like a=1; foo=2; longstring=1; c=2 + +to + +a =1; foo =2; longstring =1; c =2; + +Note I am not sure wether the code above is displayed properly in your browsers +what is basically shows is all the ='s are lined up in a single column +and this is how we achive it 0f=20i<space><esc>020lvf=hx and +this is what it does 0 goes to first column f= +finds next occurance of = on current line 20i<space><esc> +inserts 20 spaces before = 0 goesback to +first column 20l forward 20 column vf=hx +deletes everything up to the = sign + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Borland pageup/down behavier</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=320">http://vim.sf.net/tip_view.php?tip_id=320</A><BR> + +borlandbehavier = the cursor keeps the same xy position during pageup/down + +Im new to VIM scripting, im sure it can be done smarter? I read vimtip #105 +and it gave me a clue of how BorlandPageUp/Down could be done. + +" i could'nt find any get_number_of_visible_lines function, so i made my own. +function GetNumberOfVisibleLines() + let cur_line = line(".") let cur_col = virtcol(".") normal H let + top_line = line(".") normal L let bot_line = line(".") + + execute "normal " . cur_line . "G" execute "normal " . cur_col . "|" + return bot_line - top_line +endfunc + +" noremap <PageUp> 39<C-U>:set scroll=0<CR> +function! MyPageUp() + let visible_lines = GetNumberOfVisibleLines() execute "normal " + . visible_lines . "\<C-U>:set scroll=0\r" +endfunction + +" noremap <PageDown> 39<C-D>:set scroll=0<CR> +function! MyPageDown() + let visible_lines = GetNumberOfVisibleLines() execute "normal " + . visible_lines . "\<C-D>:set scroll=0\r" +endfunction + +" BorlandPascal pageup/down behavier! " todo: when hitting top/bottom of file, +then restore Y to lastY noremap <PageUp> :call MyPageUp()<CR> +noremap <PageDown> :call MyPageDown()<CR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>Centura +swap with upper/lower line behavier</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=321">http://vim.sf.net/tip_view.php?tip_id=321</A><BR> + +I was once forced to use a windows development suite called "Centura". +The only good thing i remember was its swap current_line with upper/lower line. + +function! MySwapUp() + let cur_col = virtcol(".") normal ddkkp execute "normal " . cur_col . "|" +endfunction + +function! MySwapDown() + let cur_col = virtcol(".") normal ddp execute "normal " . cur_col . "|" +endfunction + +" swap lines and preserve cursorx " todo: in visual mode, perform swap with +line before/after the selection noremap <S-Up> :call MySwapUp()<CR> +noremap <S-Down> :call MySwapDown()<CR> + +</pre></tip> </html> <Tip category="KVim"> <html><center>text +template with placeholders</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=322">http://vim.sf.net/tip_view.php?tip_id=322</A><BR> + +Many scripts/ftplugin provide text or code templates. Sadly none of the +marks the places where you are supposed to "fill in the form". My own code +templates for C/C++ insert a triple percent (%%%) where you are supposed to +enter something. I mapped ;; to find the next %%% and change them. All the +template mappings are insert-mode only, while the "skip to next placeholder" +is both insert and normal mode enabled. + +A complete for-loop template for C++ looks like: + +:imap <buffer> ;fo <C-O>mzfor( %%%; %%%; %%%)<CR>{ // +%%%<CR>%%%<CR>}<CR><C-O>'z;; + +The command to go to the next placeholder is this: + +:imap <buffer> ;; <C-O>/%%%<CR><C-O>c3l :nmap +<buffer> ;; /%%%<CR>c3l + +Every time I need a for-loop ;fo produces this ( _ is the cursor position) +: for( _; %%% ; %%%) { // %%% + %%% +} + +Now I enter starting value (i=0): for( i=0_; %%% ; %%%) { // %%% + %%% +} + +and go to the condition using ;; for( i=0; _ ; %%%) { // %%% + %%% +} + +and so forth. + +The choice of %%% proved to be almost universal, it even works in MATLAB or +LaTeX where % is the comment character. + +Even if you forget to replace one %%%, that's not a problem as the compiler +flags is as a syntax error (except MATLAB and LaTeX, of course). + +It made my life easier, maybe it works for you. + +</pre></tip> </html> <Tip category="KVim"> +<html><center>using folders with latex</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=323">http://vim.sf.net/tip_view.php?tip_id=323</A><BR> + +set foldmarker=\\begin,\\end set foldmethod=marker + +this is useful with big latex document + +</pre></tip> </html> <Tip category="KVim"> <html><center>Search +and replace in files named NAME</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=324">http://vim.sf.net/tip_view.php?tip_id=324</A><BR> + +I'm not sure if there is a simple way to do this from within Vim, but, +I wrote this simple script that does it. It basically searches for files +named NAMED (whatever name pass) for a given string and replaces that with +a given string: find_replace.sh NAMED "string_to_find" "string_to_replace" + +This is all done from the command line without opening Vim. + +Of course one could do things like: + :let n = 1 :while n <= argc() " loop over all + files in arglist : exe "argument " . n : " start at + the last char in the file and wrap for the : " first + search to find match at start of file : normal G$ : + let flags = "w" : while search("foo", flags) > 0 : + s/foo/bar/g : let flags = "W" : endwhile : update + " write the file if modified : let n = n + 1 :endwhile + +As suggested in the Vim help files :-) but, I wanted to go and find only +these files... here is the script: + 1 #!/bin/sh 2 # Luis Mondesi < lemsx1@hotmail.com > 3 # + DESCRIPTION: 4 # it uses vim to replace a given string for 5 # + another in a number of files 6 # 7 # usage: 8 # find_replace.sh file + "string" "replace" 9 # + 10 if [ $1 -a $2 -a $3 ]; then 11 for i in `find . -name "$1" + -type f | xargs grep -l $2`; do 12 # how do search and replace + 13 # the screen might flicker... vim opening and closing... + 14 vim -c ":%s/$2/$3/g" -c ":wq" $i 15 done 16 exit 0 + 17 fi 18 # I should never reach here 19 echo -e "USAGE: find_replace.sh + file 'string' 'replace' \n\n" 20 exit 1 + +</pre></tip> </html> <Tip category="KVim"> <html><center>Errorformat +for java/ant/junit/cygwin/bash</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=325">http://vim.sf.net/tip_view.php?tip_id=325</A><BR> + +If you program in Java and use Jakarta ant for builds *and* if you have the +bash shell, this tip will make your development experience a little smoother. + +This tip will result in a working compile/edit/debug system (in Win32 vim/gvim +and in Cygwin vim) that takes you to the exact lines where the build fails, +whether the failure is a compilation error or a junit test failure. If you +use bash on a linux box, you shouldn't have to change very much to get +everything to work. + +There are 6 sections: 1. set up your build script 2. set up makeprg 3. set +up shell options 4. set up path formatting options 5. set up your errorformat +6. set up key mappings + +Set up build script ------------------- Add the following script to your path +(I use /usr/local/bin/): + +mymake: #!/bin/bash cd /work/ ant -emacs $* 2>&1 | tr '\\' / | tr ^M ' +' | sed -u -n -f /usr/local/bin/testerrors.sed | tee /tmp/errors + +Comment: sed -u is non-standard, use the code at: <A +HREF="http://mail.gnu.org/pipermail/bug-gnu-utils/2002-May/000192.html to +get">http://mail.gnu.org/pipermail/bug-gnu-utils/2002-May/000192.html to +get</A><BR> the -u option for sed (this avoids waiting for the build output +to get to the screen) + +testerrors.sed: # This assumes that all your junit test cases are in a com.* +package /^Running com\./ { + # duplicate the line s!\(.*\)!\1\ +\1! + P + + # turn the test package into a directory path for %D errorformat + s!.*\(com\..*\)\.[A-Za-z_][A-Za-z0-9_]*!\1! s!\.!/!g s!.*!Entering: + /work/src/&! + + # print the line and go on p n +} + +# just pass any unmatched lines through p + +Set up makeprg -------------- Add the following lines to your vimrc: + autocmd BufNewFile,BufRead /work/*.java set makeprg=mymake autocmd + BufNewFile,BufRead ?:/work/*.java set makeprg=mymake + +Set up shell options -------------------- Add the following lines to your +vimrc: + " in order to have bash as the shell for win32 vi.exe and gvim.exe, + you have " to set these options, and also build vimrun.exe in the cygwin + environment " so that the system() call is executed via bash, not cmd.exe + -- the command " to build vimrun.exe is "make -f Make_cyg.mak vimrun.exe" + set shell=bash.exe set shellcmdflag=-c set shellslash + +Also to use this environment in Win32 gvim, you must recompile vimrun so +that gvim invokes the shell via bash, not via cmd.exe. + +Set up path formatting options ------------------------------ Add the +following lines to your vimrc: + " allows DOS file names from UNIX (Cygwin) vim set isfname+=\ + +Set up your errorformat ----------------------- Add the following lines to +your vimrc: + " the "\%DEntering:\ %f," rule relies on a sed script which generates " + "Entering: " messages for each test class run (the directory name is " + generated from the test class package and a hard-coded src root) + + " the "%\\C" at the start of the exception matching line tells to match + " case-exact (the exception mathching lines rely on the %D rule that sets + " up the correct directory from the package structure) + + " ant/junit/javac errorformat set errorformat= + \%-G%.%#build.xml:%.%#, \%-G%.%#warning:\ %.%#, \%-G%\\C%.%#EXPECTED%.%#, + \%f:%l:\ %#%m, \C:%f:%l:\ %m, \%DEntering:\ %f\ %\\=, \%ECaused\ + by:%[%^:]%#:%\\=\ %\\=%m, \%ERoot\ cause:%[%^:]%#:%\\=\ %\\=%m, + \%Ecom.%[%^:]%#:%\\=\ %\\=%m, \%Eorg.%[%^:]%#:%\\=\ %\\=%m, + \%Ejava.%[%^:]%#:%\\=\ %\\=%m, \%Ejunit.%[%^:]%#:%\\=\ %\\=%m, + \%-Z%\\C\ at\ com.mypkg.%.%#.test%[A-Z]%.%#(%f:%l)\ %\\=, + \%-Z%\\C\ at\ com.mypkg.%.%#.setUp(%f:%l)\ %\\=, \%-Z%\\C\ at\ + com.mypkg.%.%#.tearDown(%f:%l)\ %\\=, \%-Z%^\ %#%$, \%-C%.%#, \%-G%.%# + +NOTE: Make sure that the character before "at" is an actual Tab character +in the three long -Z lines above + +Here is an annotated version: + set errorformat= + " don't treat the build.xml diagnostic as an error + \%-G%.%#build.xml:%.%#, + + " don't treat warning lines as errors \%-G%.%#warning:\ %.%#, + + " don't treat lines containing "EXPECTED" as errors + \%-G%\\C%.%#EXPECTED%.%#, + + " look for this standard error format \%f:%l:\ %#%m, + + " look for this standard error format (with C: on front) \C:%f:%l:\ %m, + + " look for special sed-generated "Entering" lines while running tests + \%DEntering:\ %f\ %\\=, + + " look for exceptions that were thrown in the tests, use the exception + " description as the error message (don't know how to also include the + " exception name in the error message) \%ECaused\ by:%[%^:]%#:%\\=\ + %\\=%m, \%ERoot\ cause:%[%^:]%#:%\\=\ %\\=%m, \%Ecom.%[%^:]%#:%\\=\ + %\\=%m, \%Eorg.%[%^:]%#:%\\=\ %\\=%m, \%Ejava.%[%^:]%#:%\\=\ %\\=%m, + \%Ejunit.%[%^:]%#:%\\=\ %\\=%m, + + " using the "Entering" directory and the filename/line number provided + " in the exception trace, go to the test method where the exception + " was thrown \%-Z%\\C\ at\ com.mypkg.%.%#.test%[A-Z]%.%#(%f:%l)\ + %\\=, \%-Z%\\C\ at\ com.mypkg.%.%#.setUp(%f:%l)\ %\\=, \%-Z%\\C\ at\ + com.mypkg.%.%#.tearDown(%f:%l)\ %\\=, + + " empty lines terminate searching for further exception lines \%-Z%^\ + %#%$, + + " any line can intervene between the start of an exception printout + " and the line where it ends (last in list so that it is matched if + " none of the other exception trace patterns match) \%-C%.%#, + + " all other lines are not errors \%-G%.%# + +Set up key mappings ------------------- Add the following lines to your vimrc: + nmap <F10> :clist<CR> nmap <F11> :cprev<CR> nmap + <F12> :cnext<CR> + +This allows for quick error navigation. + +NOTES ----- Vim treats the "Entering: /work/src/..." messages in a weird way. +If there are any actual errors, then these error lines are ignored by the +:cnext and :cprev commands, but if there are no real errors, then :cnext and +:cprev roll through these "Entering:" messages as if they were errors, but +since they don't include any line numbers, the cursor position is never moved. + +I thought that this was strange, but even stranger, it is programmed directly +into the vim error handling code to function exactly this way. There were +no comments, and nobody responded on the vim mailing list, so I just decided +to live with it. + +The upshot of it all is that if you see an error like "Entering:", chances +are that your build succeeded and all the tests ran without a problem. + +Hope this helps... + +Mail me with bugs at jdsumsion at earthlink.net. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Help +for VIM Help (VIM QuickRef)</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=326">http://vim.sf.net/tip_view.php?tip_id=326</A><BR> + +Type :help quickref or :h quic + +And get a VIM Command Quick Reference Page brilliant for beginners & +oldtimers alike + +type :h help to learn how to use help + +Other Help Tips + +# help for help :h visual<C-D><tab> : obtain list of all +visual help topics + : Then use tab to step thru them +:h ctrl<C-D> : list help of all control keys :h :r +: help for :ex command :h CTRL-R : normal mode :h \r +: what's \r in a regexp :h i_CTRL-R : help for say <C-R> +in insert mode :h c_CTRL-R : help for say <C-R> in command +mode :h v_CTRL-V : visual mode :h tutor : VIM Tutor + +These are also listed in my Best Of VIM Tips vimtip #305 + +</pre></tip> </html> <Tip category="KVim"> +<html><center>key mappings</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=327">http://vim.sf.net/tip_view.php?tip_id=327</A><BR> + +I use my left thumb for the alt key and right for the space. Using this +combo, you can get some useful key maps for which you don't have to move +your hands. I find I have to turn my hand a little to press the left ctrl key. + +These are some maps i use for C programming. + +map ' ` map <C-f> :w<C-m>:!make<C-m> map <M-]> +<C-]> Tags map <M-[> +<C-t> Tags map <M-u> +:!ctags -R *<C-m> Build +Tags map <M-c> I/*<Esc>A*/<Esc> +Comment current line map <M-d> ^xx$xx +Delete comment for a single line map <M-l> +[{zf% Fold upto the enclosing brace +level map <M-o> zo open fold +map <M-i> zc close fold map +<M-.> :cn<C-m> Go +to next error in list map <M-,> :cp<C-m> +previous error in list + +imap <Tab> <C-p> +Complete word inoremap <S-Tab> <Tab> +Tab inoremap { <CR>{<CR> +Brace and line inoremap } <CR>} +brace and line. saves one enter stroke + +imap <M-j> <Esc> +Escape. Don't want to move my hand to esc key. imap <M-k> <C-y> +Copy line from above. imap <M-q> /* */<Esc>hhi +Comment selected lines + +noremap <M-r> ddko{<C-m>}<Esc>kpko Convert a +simple statement to a compound statement. And place cursor above prev line. +noremap <M-k> ddko{<C-m>}<Esc>kpo Same as +above but place cursor below old line. + +vnoremap <M-j> <Esc> vnoremap <M-c> +di/*<C-m>/<C-m><Esc>kkp Commented selected text + +nmap <M-n> :noh<CR> No hilight + +Bye, + Nithin. + +</pre></tip> </html> <Tip category="KVim"> <html><center>Vim +in Microsoft Visual Foxpro</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=328">http://vim.sf.net/tip_view.php?tip_id=328</A><BR> + +You can tell MS VFP to use an external editor for editing project files. +To tell MS VFP to use Vim: + +start regedit locate [HKEY_CURRENT_USER + \Software + \Microsoft + \VisualFoxPro + \5.0 + \Options] + +and create a new item TEDIT with string content "/N +C:\Progra~1\vim\vim61\gvim.exe" (or whatever your path to Vim happens to be.) + +This will not replace the internal VFP editor for such things as modifying the +"click method" for a button (unfortunately), but when you modify a program, +VFP will fire up gvim. + +Start MS VFP, start Help and look for TEDIT. ;-) + +</pre></tip> </html> <Tip category="KVim"> +<html><center>A map for swapping words</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=329">http://vim.sf.net/tip_view.php?tip_id=329</A><BR> + +Put the following map into your <.vimrc>: + + nmap <silent> gw + "_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/<cr><c-o><c-l> + +Then when you put the cursor on or in a word, press "gw", and the word will +be swapped with the next word. The words may even be separated by punctuation +(such as "abc = def"). + +While we're talking swapping, here's a map for swapping characters: + + nmap <silent> gc xph + +This hint was formed in a collaboration between Chip Campbell - Arun Easi - +Benji Fisher + +</pre></tip> </html> <Tip category="KVim"> +<html><center>how to stop auto indenting</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=330">http://vim.sf.net/tip_view.php?tip_id=330</A><BR> + +Since VIM 6.0 the indent has been improved so much. But sometimes when +we are pasting formated text (source code or HTML etc) into a buffer, VIM +indents again so that lines will be padded with too much spaces. + +Setting nocindent, noautoindent, nosmartindent still cannot stop this. All you +need to do is "set paste", then paste your stuff, and then "set nopaste" again. + +Ref: indentexpr + +</pre></tip> </html> <Tip category="KVim"> +<html><center>modline magic...</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=331">http://vim.sf.net/tip_view.php?tip_id=331</A><BR> + + One of the things about vim that are both quite simple yet very +useful is that you can store by-file settings... that is each file can +contain settings specific to it. this thing is called a modline (:help +modline). though this is limited to only the 'set' command arguments, you +can do allot of local to file things like the indent type, folding method +and so on. + +the syntax is as follows: + +// vim:set ts=4 sw=4 nowrap: + +or + +/* vim:noai:ts=2:sw=4: */ + + The modlines can be contained in comments so as to not interfere with +the file syntax (shown here for C/C++). these lines are read by vim when +it loads the file, and they can either be in the first or last 5 lines +(by default). + +refer to ':help modline' + +//and a happy 20th birthday to the good old smiley!! :-) + +</pre></tip> </html> <Tip category="KVim"> +<html><center>make footnotes in vim</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=332">http://vim.sf.net/tip_view.php?tip_id=332</A><BR> + +I found at <A +HREF="http://groups.google.com/groups?q=vim+changing+shell+to+zsh&hl=en&lr=&ie=UTF-8&selm=S_Rh9.716%24a5.124150%40news.uchicago.edu&rnum=4">http://groups.google.com/groups?q=vim+changing+shell+to+zsh&hl=en&lr=&ie=UTF-8&selm=S_Rh9.716%24a5.124150%40news.uchicago.edu&rnum=4</A><BR> +a macro to insert footnotes in vim, but it doesn't work as of vim6.0. so i +wrote my own; this macro requires two differents shortcuts, one for entering +the first footnote, the other one for all subsequent footnotes. + +when you hit "K0" (first footnote) or "KK" (all other footnotes) in normal +mode, your cursor is positionned at the end of the document, in the footnote & +in insert mode. The "a" bookmark is set to the place where you entered the +footnote in the text. so a "`a" will bring you back to the location of the +footnote in the text. + +" for now requires entering K0 for the first footnote and then KK +nmap K0 i[0]<esc>maG$i<end><enter>[0] nmap KK +maG$?\[[0-9]*\]<enter>yt]G$i<end><enter><esc>p<C-a>i<end>]<esc>`aP<C-a><right>i]<esc>maG$i<end><end> + +</pre></tip> </html> <Tip category="KVim"> +<html><center>Syntax-based folding for c/c++/java</center> <pre> <A +HREF="http://vim.sf.net/tip_view.php?tip_id=333">http://vim.sf.net/tip_view.php?tip_id=333</A><BR> + +Here's a function to toggle the use of syntax-based folding for a c/c++/java +file. It also handles folding markers. + +function! OutlineToggle() + if (! exists ("b:outline_mode")) + let b:outline_mode = 0 + endif + + if (b:outline_mode == 0) + syn region myFold start="{" end="}" transparent fold syn sync + fromstart set foldmethod=syntax + + silent! exec "%s/{{{/<<</" silent! exec "%s/}}}/>>>/" + + let b:outline_mode = 1 + else + set foldmethod=marker + + silent! exec "%s/<<</{{{/" silent! exec "%s/>>>/}}}/" + + let b:outline_mode = 0 + endif +endfunction + +</html></tip> diff --git a/runtime/kvim32x32.png b/runtime/kvim32x32.png Binary files differnew file mode 100644 index 000000000..6e95a6f59 --- /dev/null +++ b/runtime/kvim32x32.png diff --git a/runtime/kvim48x48.png b/runtime/kvim48x48.png Binary files differnew file mode 100644 index 000000000..348d4af48 --- /dev/null +++ b/runtime/kvim48x48.png diff --git a/runtime/kvim64x64.png b/runtime/kvim64x64.png Binary files differnew file mode 100644 index 000000000..6ca4de253 --- /dev/null +++ b/runtime/kvim64x64.png diff --git a/runtime/menu.vim b/runtime/menu.vim index db5dc9259..b4ab63030 100644 --- a/runtime/menu.vim +++ b/runtime/menu.vim @@ -193,7 +193,7 @@ inoremenu <script> <silent> 20.400 &Edit.&Select\ All<Tab>ggVG <C-O>:call <SID>S cnoremenu <script> <silent> 20.400 &Edit.&Select\ All<Tab>ggVG <C-U>call <SID>SelectAll()<CR> an 20.405 &Edit.-SEP2- <Nop> -if has("win32") || has("win16") || has("gui_gtk") || has("gui_motif") +if has("win32") || has("win16") || has("gui_gtk") || has("gui_kde") || has("gui_motif") an 20.410 &Edit.&Find\.\.\. :promptfind<CR> vunmenu &Edit.&Find\.\.\. vnoremenu &Edit.&Find\.\.\. y:promptfind <C-R>"<CR> @@ -382,7 +382,7 @@ if has("keymap") endif unlet s:n endif -if has("win32") || has("win16") || has("gui_gtk") || has("gui_photon") +if has("win32") || has("win16") || has("gui_gtk") || has("gui_kde") || has("gui_photon") an 20.470 &Edit.Select\ Fo&nt\.\.\. :set guifont=*<CR> endif diff --git a/runtime/plugin/NetrwFileHandlers.vim b/runtime/plugin/NetrwFileHandlers.vim new file mode 100644 index 000000000..102d8d45f --- /dev/null +++ b/runtime/plugin/NetrwFileHandlers.vim @@ -0,0 +1,26 @@ +" NetrwFileHandlers: contains various extension-based file handlers for +" netrw's browser +" Author: Charles E. Campbell, Jr. +" Date: Jun 25, 2004 +" Version: 1 +" --------------------------------------------------------------------- + +" NetrwFileHandler_html: handles html +fun! NetrwFileHandler_html(webpage) +" call Dfunc("NetrwFileHandler_html(".a:webpage.")") + + let host= substitute(a:webpage,'^\w\+://\%(\w*@\)\=\(\w\+\)/.*$','\1','e') +" call Decho("host<".host.">") + + if host == hostname() || host == substitute(hostname(),'\..*$','','e') + let page= substitute(a:webpage,'^\w\+://\%(\w*@\)\=\(\w\+\)/','file://\1/'.expand("$HOME").'/','e') + else + let page= substitute(a:webpage,'^\w\+://\%(\w*@\)\=\(\w\+\)/','http://\1/','e') + endif +" call Decho("executing !mozilla ".page) + exe "!mozilla ".page + +" call Dret("NetrwFileHandler_html") +endfun + +" --------------------------------------------------------------------- diff --git a/runtime/plugin/netrw.vim b/runtime/plugin/netrw.vim index 60dec437f..7022f58d5 100644 --- a/runtime/plugin/netrw.vim +++ b/runtime/plugin/netrw.vim @@ -1,7 +1,7 @@ " netrw.vim: Handles file transfer and remote directory listing across a network " Last Change: Jun 24, 2004 " Maintainer: Charles E. Campbell, Jr. PhD <drchipNOSPAM at campbellfamily.biz> -" Version: 47c NOT RELEASED +" Version: 47f NOT RELEASED " License: Vim License (see vim's :help license) " " But be doers of the word, and not only hearers, deluding your own selves @@ -12,7 +12,7 @@ if exists("loaded_netrw") || &cp finish endif -let loaded_netrw = "v47c" +let loaded_netrw = "v47f NOT RELEASED" let s:save_cpo = &cpo set cpo&vim @@ -31,6 +31,38 @@ if !exists("g:netrw_cygwin") let g:netrw_cygwin= 0 endif endif +if !exists("g:netrw_list_cmd") + if executable("ssh") + " provide a default listing command + let g:netrw_list_cmd= "ssh HOSTNAME ls -FLa" + else + call Decho("ssh is not executable, can't do remote directory exploring") + let g:netrw_list_cmd= "" + endif +endif +if !exists("g:netrw_rm_cmd") + let g:netrw_rm_cmd = "ssh HOSTNAME rm" +endif +if !exists("g:netrw_rmf_cmd") + let g:netrw_rmf_cmd = "ssh HOSTNAME rm -f" +endif +if !exists("g:netrw_rmdir_cmd") + let g:netrw_rmdir_cmd = "ssh HOSTNAME rmdir" +endif +if !exists("g:netrw_rename_cmd") + let g:netrw_rename_cmd= "ssh HOSTNAME mv" +endif +if exists("g:netrw_silent") && g:netrw_silent != 0 + let g:netrw_silentxfer= "silent " +else + let g:netrw_silentxfer= "" +endif +if !exists("g:netrw_winsize") + let g:netrw_winsize= "" +endif +if !exists("g:netrw_list_hide") + let g:netrw_list_hide= "" +endif " --------------------------------------------------------------------- " Default values for global protocol variables {{{1 @@ -68,20 +100,6 @@ if !exists("g:netrw_fetch_cmd") let g:netrw_fetch_cmd = "" endif endif -if !exists("g:netrw_list_cmd") - if executable("ssh") - let g:netrw_list_cmd= "ssh HOSTNAME ls -FLa" - else -" call Decho("ssh is not executable, can't do netlist") - let g:netrw_list_cmd= "" - endif -endif -if exists("g:netrw_silent") && g:netrw_silent != 0 - let g:netrw_silentxfer= "silent " -else - let g:netrw_silentxfer= "" -endif - if has("win32") \ && exists("g:netrw_use_nt_rcp") @@ -124,7 +142,7 @@ com! -nargs=* NetUserPass call NetUserPass(<f-args>) " ------------------------------------------------------------------------ " NetSavePosn: saves position of cursor on screen {{{1 fun! s:NetSavePosn() -" call Dfunc("NetSavePosn()") + call Dfunc("NetSavePosn()") " Save current line and column let s:netrw_winnr= winnr() let s:netrw_line = line(".") @@ -135,13 +153,13 @@ fun! s:NetSavePosn() let s:netrw_hline= line(".") call s:NetRestorePosn() -" call Dret("NetSavePosn : winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline) + call Dret("NetSavePosn : winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline) endfun " ------------------------------------------------------------------------ " NetRestorePosn: restores the cursor and file position as saved by NetSavePosn() {{{1 fun! <SID>NetRestorePosn() -" call Dfunc("NetRestorePosn() winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline) + call Dfunc("NetRestorePosn() winnr=".s:netrw_winnr." line=".s:netrw_line." col=".s:netrw_col." hline=".s:netrw_hline) exe "silent! ".s:netrw_winnr."wincmd w" if v:shell_error == 0 @@ -154,13 +172,13 @@ fun! <SID>NetRestorePosn() " restore position exe "norm! ".s:netrw_line."G0".s:netrw_col."\<bar>" -" call Dret("NetRestorePosn") + call Dret("NetRestorePosn") endfun " ------------------------------------------------------------------------ " NetRead: responsible for reading a file over the net {{{1 fun! s:NetRead(...) -" call Dfunc("NetRead(a:1<".a:1.">)") + call Dfunc("NetRead(a:1<".a:1.">)") " save options call s:NetOptionSave() @@ -182,18 +200,18 @@ fun! s:NetRead(...) " get name of a temporary file let tmpfile= tempname() -" call Decho("ichoice=".ichoice." readcmd<".readcmd.">") + call Decho("ichoice=".ichoice." readcmd<".readcmd.">") while ichoice <= a:0 " attempt to repeat with previous host-file-etc if exists("b:netrw_lastfile") && a:0 == 0 -" call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">") + call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">") let choice = b:netrw_lastfile let ichoice= ichoice + 1 else exe "let choice= a:" . ichoice -" call Decho("no lastfile: choice<" . choice . ">") + call Decho("no lastfile: choice<" . choice . ">") " Reconstruct Choice if choice starts with '"' if match(choice,"?") == 0 @@ -211,7 +229,7 @@ fun! s:NetRead(...) echo ':Nread sftp://[user@]machine[[:#]port]/path uses sftp' break elseif match(choice,"^\"") != -1 -" call Decho("reconstructing choice") + call Decho("reconstructing choice") if match(choice,"\"$") != -1 " case "..." let choice=strpart(choice,1,strlen(choice)-2) @@ -225,7 +243,7 @@ fun! s:NetRead(...) let ichoice = ichoice + 1 if ichoice > a:0 echoerr "Unbalanced string in filename '". wholechoice ."'" -" call Dret("NetRead") + call Dret("NetRead") return endif let choice= a:{ichoice} @@ -235,13 +253,13 @@ fun! s:NetRead(...) endif endif -" call Decho("choice<" . choice . ">") + call Decho("choice<" . choice . ">") let ichoice= ichoice + 1 " fix up windows urls if has("win32") let choice = substitute(choice,'\\','/','ge') -" call Decho("fixing up windows url to <".choice."> tmpfile<".tmpfile) + call Decho("fixing up windows url to <".choice."> tmpfile<".tmpfile) exe 'lcd ' . fnamemodify(tmpfile,':h') let tmpfile = fnamemodify(tmpfile,':t') @@ -250,12 +268,12 @@ fun! s:NetRead(...) " Determine method of read (ftp, rcp, etc) call s:NetMethod(choice) - " Check if NetList() should be handling this request -" call Decho("checking if netlist: choice<".choice."> netrw_list_cmd<".g:netrw_list_cmd.">") + " Check if NetBrowse() should be handling this request + call Decho("checking if netlist: choice<".choice."> netrw_list_cmd<".g:netrw_list_cmd.">") if choice =~ "^.*/$" if strlen(g:netrw_list_cmd) > 0 - keepjumps call s:NetList(choice) -" call Dret("NetRead") + keepjumps call s:NetBrowse(choice) + call Dret("NetRead") else echoerr "sorry, can't do a remote listing; ssh isn't executable" endif @@ -269,7 +287,7 @@ fun! s:NetRead(...) "......................................... " rcp: NetRead Method #1 if b:netrw_method == 1 " read with rcp -" call Decho("read via rcp (method #1)") + call Decho("read via rcp (method #1)") " ER: noting done with g:netrw_uid yet? " ER: on Win2K" rcp machine[.user]:file tmpfile " ER: if machine contains '.' adding .user is required (use $USERNAME) @@ -288,7 +306,7 @@ fun! s:NetRead(...) let uid_machine = g:netrw_machine endif endif -" call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) + call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".uid_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) let b:netrw_lastfile = choice @@ -296,17 +314,17 @@ fun! s:NetRead(...) "......................................... " ftp + <.netrc>: NetRead Method #2 elseif b:netrw_method == 2 " read with ftp + <.netrc> -" call Decho("read via ftp+.netrc (method #2)") + call Decho("read via ftp+.netrc (method #2)") let netrw_fname= b:netrw_fname new set ff=unix exe "put ='".g:netrw_ftpmode."'" exe "put ='get ".netrw_fname." ".tmpfile."'" if exists("g:netrw_port") && g:netrw_port != "" -" call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) + call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port else -" call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine) + call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine) exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine endif " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) @@ -321,7 +339,7 @@ fun! s:NetRead(...) " ftp + machine,id,passwd,filename: NetRead Method #3 elseif b:netrw_method == 3 " read with ftp + machine, id, passwd, and fname " Construct execution string (four lines) which will be passed through filter -" call Decho("read via ftp+mipf (method #3)") + call Decho("read via ftp+mipf (method #3)") let netrw_fname= b:netrw_fname new set ff=unix @@ -347,9 +365,9 @@ fun! s:NetRead(...) " -i : turns off interactive prompting from ftp " -n unix : DON'T use <.netrc>, even though it exists " -n win32: quit being obnoxious about password -" call Decho('performing ftp -i -n') + call Decho('performing ftp -i -n') norm 1Gdd -" call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") + call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n" " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) if getline(1) !~ "^$" @@ -362,7 +380,7 @@ fun! s:NetRead(...) "......................................... " scp: NetRead Method #4 elseif b:netrw_method == 4 " read with scp -" call Decho("read via scp (method #4)") + call Decho("read via scp (method #4)") if exists("g:netrw_port") && g:netrw_port != "" let useport= " -P ".g:netrw_port else @@ -370,10 +388,10 @@ fun! s:NetRead(...) endif if g:netrw_cygwin == 1 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') -" call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) + call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile else -" call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) + call Decho("executing: !".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile endif let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) @@ -381,7 +399,7 @@ fun! s:NetRead(...) "......................................... elseif b:netrw_method == 5 " read with http (wget) -" call Decho("read via http (method #5)") + call Decho("read via http (method #5)") if g:netrw_http_cmd == "" echoerr "neither wget nor fetch command is available" exit @@ -389,7 +407,7 @@ fun! s:NetRead(...) if match(b:netrw_fname,"#") == -1 " simple wget -" call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.escape(b:netrw_fname,' ?&')) + call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.escape(b:netrw_fname,' ?&')) exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.escape(b:netrw_fname,' ?&') let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) @@ -397,12 +415,12 @@ fun! s:NetRead(...) " wget plus a jump to an in-page marker (ie. http://abc/def.html#aMarker) let netrw_html= substitute(b:netrw_fname,"#.*$","","") let netrw_tag = substitute(b:netrw_fname,"^.*#","","") -" call Decho("netrw_html<".netrw_html.">") -" call Decho("netrw_tag <".netrw_tag.">") -" call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html) + call Decho("netrw_html<".netrw_html.">") + call Decho("netrw_tag <".netrw_tag.">") + call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html) exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) -" call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/') + call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/') exe 'norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>" endif let b:netrw_lastfile = choice @@ -410,7 +428,7 @@ fun! s:NetRead(...) "......................................... " cadaver: NetRead Method #6 elseif b:netrw_method == 6 " read with cadaver -" call Decho("read via cadaver (method #6)") + call Decho("read via cadaver (method #6)") " Construct execution string (four lines) which will be passed through filter let netrw_fname= b:netrw_fname @@ -432,7 +450,7 @@ fun! s:NetRead(...) " perform cadaver operation: norm 1Gdd -" call Decho("executing: %!".g:netrw_dav_cmd) + call Decho("executing: %!".g:netrw_dav_cmd) exe g:netrw_silentxfer."%!".g:netrw_dav_cmd bd! let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) @@ -441,13 +459,13 @@ fun! s:NetRead(...) "......................................... " rsync: NetRead Method #7 elseif b:netrw_method == 7 " read with rsync -" call Decho("read via rsync (method #7)") + call Decho("read via rsync (method #7)") if g:netrw_cygwin == 1 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') -" call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) + call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile else -" call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) + call Decho("executing: !".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile endif let result = s:NetGetFile(readcmd,tmpfile, b:netrw_method) @@ -466,13 +484,13 @@ fun! s:NetRead(...) else let netrw_option= "ftp" endif -" call Decho("read via fetch for ".netrw_option) + call Decho("read via fetch for ".netrw_option) if exists("g:netrw_uid") && g:netrw_uid != "" && exists("g:netrw_passwd") && g:netrw_passwd != "" -" call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".escape(b:netrw_fname,' ?&')) + call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".escape(b:netrw_fname,' ?&')) exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_uid.':'.g:netrw_passwd.'@'.g:netrw_machine."/".escape(b:netrw_fname,' ?&') else -" call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".escape(b:netrw_fname,' ?&')) + call Decho("executing: !".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".escape(b:netrw_fname,' ?&')) exe g:netrw_silentxfer."!".g:netrw_fetch_cmd." ".tmpfile." ".netrw_option."://".g:netrw_machine."/".escape(b:netrw_fname,' ?&') endif @@ -482,14 +500,14 @@ fun! s:NetRead(...) "......................................... " sftp: NetRead Method #9 elseif b:netrw_method == 9 " read with sftp -" call Decho("read via sftp (method #4)") + call Decho("read via sftp (method #4)") if g:netrw_cygwin == 1 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') -" call Decho("!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) -" call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) + call Decho("!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) + call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile) exe "!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".cygtmpfile else -" call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) + call Decho("executing: !".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile) exe g:netrw_silentxfer."!".g:netrw_sftp_cmd." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')." ".tmpfile endif let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method) @@ -502,7 +520,7 @@ fun! s:NetRead(...) endwhile " cleanup -" call Decho("cleanup") + call Decho("cleanup") if exists("b:netrw_method") unlet b:netrw_method unlet g:netrw_machine @@ -510,14 +528,14 @@ fun! s:NetRead(...) endif call s:NetOptionRestore() -" call Dret("NetRead") + call Dret("NetRead") endfun " end of NetRead " ------------------------------------------------------------------------ " NetGetFile: Function to read file "fname" with command "readcmd". {{{1 fun! s:NetGetFile(readcmd, fname, method) -" call Dfunc("NetGetFile(readcmd<".a:readcmd.">,fname<".a:fname."> method<".a:method.">)") + call Dfunc("NetGetFile(readcmd<".a:readcmd.">,fname<".a:fname."> method<".a:method.">)") if exists("*NetReadFixup") " for the use of NetReadFixup (not otherwise used internally) @@ -528,14 +546,14 @@ fun! s:NetGetFile(readcmd, fname, method) if &term == "win32" if &shell == "bash" let fname=a:fname -" call Decho("(win32 && bash) fname<".fname.">") + call Decho("(win32 && bash) fname<".fname.">") else let fname=substitute(a:fname,'/','\\\\','ge') -" call Decho("(win32 && !bash) fname<".fname.">") + call Decho("(win32 && !bash) fname<".fname.">") endif else let fname= a:fname -" call Decho("(copied) fname<".fname.">") + call Decho("(copied) fname<".fname.">") endif " get the file, but disable undo when reading a new buffer @@ -594,10 +612,10 @@ fun! s:NetGetFile(readcmd, fname, method) let &ul= oldul endif elseif filereadable(fname) -" call Decho("exe<".a:readcmd." ".v:cmdarg." ".fname.">") + call Decho("exe<".a:readcmd." ".v:cmdarg." ".fname.">") exe a:readcmd." ".v:cmdarg." ".fname else -" call Dret("NetGetFile") + call Dret("NetGetFile") return endif @@ -609,22 +627,22 @@ fun! s:NetGetFile(readcmd, fname, method) else let line2= line("$") - line2 endif -" call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")") + call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")") call NetReadFixup(a:method, line1, line2) endif -" call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> fname<".a:fname."> readable=".filereadable(a:fname)) + call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> fname<".a:fname."> readable=".filereadable(a:fname)) " insure that we have the right filetype and that its being displayed filetype detect redraw! -" call Dret("NetGetFile") + call Dret("NetGetFile") endfun " ------------------------------------------------------------------------ " NetWrite: responsible for writing a file over the net {{{1 fun! s:NetWrite(...) range -" call Dfunc("NetWrite(a:0=".a:0.")") + call Dfunc("NetWrite(a:0=".a:0.")") " option handling let mod= 0 @@ -646,7 +664,7 @@ fun! s:NetWrite(...) range " attempt to repeat with previous host-file-etc if exists("b:netrw_lastfile") && a:0 == 0 -" call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">") + call Decho("using b:netrw_lastfile<" . b:netrw_lastfile . ">") let choice = b:netrw_lastfile let ichoice= ichoice + 1 else @@ -681,7 +699,7 @@ fun! s:NetWrite(...) range let ichoice = ichoice + 1 if choice > a:0 echoerr "Unbalanced string in filename '". wholechoice ."'" -" call Dret("NetWrite") + call Dret("NetWrite") return endif let choice= a:{ichoice} @@ -690,7 +708,7 @@ fun! s:NetWrite(...) range endif endif endif -" call Decho("choice<" . choice . ">") + call Decho("choice<" . choice . ">") let ichoice= ichoice + 1 " fix up windows urls @@ -711,7 +729,7 @@ fun! s:NetWrite(...) range "......................................... " rcp: NetWrite Method #1 if b:netrw_method == 1 " write with rcp -" Decho "write via rcp (method #1)" + Decho "write via rcp (method #1)" if s:netrw_has_nt_rcp == 1 if exists("g:netrw_uid") && ( g:netrw_uid != "" ) let uid_machine = g:netrw_machine .'.'. g:netrw_uid @@ -725,7 +743,7 @@ fun! s:NetWrite(...) range let uid_machine = g:netrw_machine endif endif -" call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".escape(b:netrw_fname,' ?&')) + call Decho("executing: !".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".escape(b:netrw_fname,' ?&')) exe g:netrw_silentxfer."!".g:netrw_rcp_cmd." ".s:netrw_rcpmode." ".tmpfile." ".uid_machine.":".escape(b:netrw_fname,' ?&') let b:netrw_lastfile = choice @@ -736,14 +754,14 @@ fun! s:NetWrite(...) range new set ff=unix exe "put ='".g:netrw_ftpmode."'" -" call Decho(" NetWrite: put ='".g:netrw_ftpmode."'") + call Decho(" NetWrite: put ='".g:netrw_ftpmode."'") exe "put ='put ".tmpfile." ".netrw_fname."'" -" call Decho("put ='put ".tmpfile." ".netrw_fname."'") + call Decho("put ='put ".tmpfile." ".netrw_fname."'") if exists("g:netrw_port") && g:netrw_port != "" -" call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) + call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port) exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine." ".g:netrw_port else -" call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine) + call Decho("executing: %!".g:netrw_ftp_cmd." -i ".g:netrw_machine) exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i ".g:netrw_machine endif " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) @@ -779,9 +797,9 @@ fun! s:NetWrite(...) range " -i : turns off interactive prompting from ftp " -n unix : DON'T use <.netrc>, even though it exists " -n win32: quit being obnoxious about password -" call Decho('performing ftp -i -n') + call Decho('performing ftp -i -n') norm 1Gdd -" call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") + call Decho("executing: %!".g:netrw_ftp_cmd." -i -n") exe g:netrw_silentxfer."%!".g:netrw_ftp_cmd." -i -n" " If the result of the ftp operation isn't blank, show an error message (tnx to Doug Claar) if getline(1) !~ "^$" @@ -800,10 +818,10 @@ fun! s:NetWrite(...) range endif if g:netrw_cygwin == 1 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') -" call Decho("executing: !".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) + call Decho("executing: !".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&') else -" call Decho("executing: !".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) + call Decho("executing: !".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) exe g:netrw_silentxfer."!".g:netrw_scp_cmd.useport." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&') endif let b:netrw_lastfile = choice @@ -816,7 +834,7 @@ fun! s:NetWrite(...) range "......................................... " dav: NetWrite Method #6 elseif b:netrw_method == 6 " write with cadaver -" call Decho("write via cadaver (method #6)") + call Decho("write via cadaver (method #6)") " Construct execution string (four lines) which will be passed through filter let netrw_fname= b:netrw_fname @@ -838,7 +856,7 @@ fun! s:NetWrite(...) range " perform cadaver operation: norm 1Gdd -" call Decho("executing: %!".g:netrw_dav_cmd) + call Decho("executing: %!".g:netrw_dav_cmd) exe g:netrw_silentxfer."%!".g:netrw_dav_cmd bd! let b:netrw_lastfile = choice @@ -848,10 +866,10 @@ fun! s:NetWrite(...) range elseif b:netrw_method == 7 " write with rsync if g:netrw_cygwin == 1 let cygtmpfile=substitute(tmpfile,'^\(\a\):','/cygdrive/\1/','e') -" call Decho("executing: !".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) + call Decho("executing: !".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".cygtmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&') else -" call Decho("executing: !".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) + call Decho("executing: !".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&')) exe g:netrw_silentxfer."!".g:netrw_rsync_cmd." ".tmpfile." ".g:netrw_machine.":".escape(b:netrw_fname,' ?&') endif let b:netrw_lastfile = choice @@ -869,7 +887,7 @@ fun! s:NetWrite(...) range set ff=unix put ='put '.tmpfile.' '.netrw_fname norm 1Gdd -" call Decho("executing: %!".g:netrw_sftp_cmd.' '.uid_machine) + call Decho("executing: %!".g:netrw_sftp_cmd.' '.uid_machine) exe g:netrw_silentxfer."%!".g:netrw_sftp_cmd.' '.uid_machine bd! let b:netrw_lastfile= choice @@ -881,7 +899,7 @@ fun! s:NetWrite(...) range endwhile " cleanup -" call Decho("cleanup") + call Decho("cleanup") let result=delete(tmpfile) call s:NetOptionRestore() @@ -889,17 +907,25 @@ fun! s:NetWrite(...) range let &mod= mod " usually equivalent to set nomod endif -" call Dret("NetWrite") + call Dret("NetWrite") endfun " end of NetWrite " ------------------------------------------------------------------------ -" NetList: This function uses the command in g:netrw_list_cmd to get a list {{{1 +" Remote Directory Browsing Support: {{{1 +" NetBrowse: This function uses the command in g:netrw_list_cmd to get a list {{{2 " of the contents of a remote directory. It is assumed that the " g:netrw_list_cmd has a string, HOSTNAME, that needs to be substituted " with the requested remote hostname first. -fun! <SID>NetList(dirname) -" call Dfunc("NetList(dirname<".a:dirname.">)") +fun! <SID>NetBrowse(dirname) + call Dfunc("NetBrowse(dirname<".a:dirname.">)") + + " sanity check + if !exists("g:netrw_list_cmd") || g:netrw_list_cmd == '' + echoerr "***netrw*** this system doesn't support remote directory listing" + call Dret("NetBrowse 0") + return 0 + endif " make this buffer modifiable setlocal ma @@ -907,8 +933,8 @@ fun! <SID>NetList(dirname) " analyze a:dirname and g:netrw_list_cmd let dirpat = '^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$' if a:dirname !~ dirpat - echoerr "NetList: I don't understand your dirname<".a:dirname.">" -" call Dret("NetList 0 : badly formatted dirname") + echoerr "NetBrowse: I don't understand your dirname<".a:dirname.">" + call Dret("NetBrowse 0 : badly formatted dirname") return 0 endif let method = substitute(a:dirname,dirpat,'\1','') @@ -916,57 +942,57 @@ fun! <SID>NetList(dirname) let machine = substitute(a:dirname,dirpat,'\3','') let path = substitute(a:dirname,dirpat,'\4','') let fname = substitute(a:dirname,'^.*/\ze.','','') -" call Decho("set up method <".method .">") -" call Decho("set up user <".user .">") -" call Decho("set up machine<".machine.">") -" call Decho("set up path <".path .">") -" call Decho("set up fname <".fname .">") + call Decho("set up method <".method .">") + call Decho("set up user <".user .">") + call Decho("set up machine<".machine.">") + call Decho("set up path <".path .">") + call Decho("set up fname <".fname .">") let listcmd = substitute(g:netrw_list_cmd,'\<HOSTNAME\>',user.machine,'') -" call Decho("set up listcmd<".listcmd.">") + call Decho("set up listcmd<".listcmd.">") if fname =~ '@$' && fname !~ '^"' -" call Decho("attempt transfer of symlink as file") - call s:NetList(substitute(a:dirname,'@$','','e')) + call Decho("attempt transfer of symlink as file") + call s:NetBrowse(substitute(a:dirname,'@$','','e')) redraw! -" call Dret("NetList 0 : symlink") + call Dret("NetBrowse 0 : symlink") return 0 elseif fname !~ '/$' && fname !~ '^"' " looks like a regular file, attempt transfer -" call Decho("attempt transfer as regular file<".a:dirname.">") + call Decho("attempt transfer as regular file<".a:dirname.">") " remove any filetype indicator from end of dirname, except for the " "this is a directory" indicator (/). There shouldn't be one of those, " anyway. let path= substitute(path,'[*=@|]$','','e') -" call Decho("new path<".path.">") + call Decho("new path<".path.">") " remote-read the requested file into current buffer enew! - exe "file ".method."://".machine."/".path + exe "file ".method."://".user.machine."/".path exe "silent doau BufReadPre ".fname - silent call s:NetRead(method."://".machine."/".path) + silent call s:NetRead(method."://".user.machine."/".path) exe "silent doau BufReadPost ".fname 1d set nomod -" call Dret("NetList 0 : file<".fname.">") + call Dret("NetBrowse 0 : file<".fname.">") return 0 endif " --------------------------------------------------------------------- " Perform Directory Listing: -" call Decho("Perform directory listing...") + call Decho("Perform directory listing...") " set up new buffer and map let bufname = method.'://'.user.machine.'/'.path let bufnamenr = bufnr(bufname) -" call Decho("bufname<".bufname."> bufnamenr=".bufnamenr) + call Decho("bufname<".bufname."> bufnamenr=".bufnamenr) if bufnamenr != -1 " buffer already exists, switch to it! exe "b ".bufnamenr if line("$") >= 5 -" call Dret("NetList 1") + call Dret("NetBrowse 1") return 1 endif else @@ -975,22 +1001,46 @@ fun! <SID>NetList(dirname) setlocal bt=nofile bh=wipe nobl exe 'file '.bufname set bt=nowrite bh=hide nobl - nnoremap <buffer> <cr> :exe "norm! 0"<bar>call <SID>NetList(<SID>NetListChgDir(expand("%")))<cr> + nnoremap <buffer> <silent> <cr> :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),expand("<cWORD>")))<cr> + nnoremap <buffer> <silent> <c-l> :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<cr> + nnoremap <buffer> <silent> - :exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'../'))<cr> + nnoremap <buffer> <silent> a :let g:netrw_list_showall=1<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./'))<cr> + nnoremap <buffer> <silent> o :exe g:netrw_winsize."wincmd s"<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),expand("<cWORD>")))<cr> + nnoremap <buffer> <silent> v :exe g:netrw_winsize."wincmd v"<bar>exe "norm! 0"<bar>call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),expand("<cWORD>")))<cr> + nnoremap <buffer> <silent> x :exe "norm! 0"<bar>call <SID>NetBrowseX(<SID>NetBrowseChgDir(expand("%"),expand("<cWORD>")))<cr> + exe 'nnoremap <buffer> <silent> <del> :exe "norm! 0"<bar>call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>' + exe 'vnoremap <buffer> <silent> <del> :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>' + exe 'nnoremap <buffer> <silent> D :exe "norm! 0"<bar>call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>' + exe 'vnoremap <buffer> <silent> D :call <SID>NetBrowseRm("'.user.machine.'","'.path.'")<cr>' + exe 'nnoremap <buffer> <silent> R :exe "norm! 0"<bar>call <SID>NetBrowseRename("'.user.machine.'","'.path.'")<cr>' + nnoremap <buffer> ? :he netrw-dir<cr> setlocal ma -" call Decho("executing: r! ".listcmd." '".path."'") + call Decho("executing: r! ".listcmd." '".path."'") keepjumps put ='\" ==============================' keepjumps put ='\" Netrw Remote Directory Listing' keepjumps put ='\" '.bufname + let g:netrw_bannercnt= 5 + if g:netrw_list_hide != "" && !exists("g:netrw_list_showall") + keepjumps put ='\" Hiding: '.g:netrw_list_hide + let g:netrw_bannercnt= g:netrw_bannercnt + 1 + endif keepjumps put ='\" ==============================' exe "silent r! ".listcmd." '".path."'" keepjumps 1d set ft=netrwlist - if line("$") >= 5 - keepjumps silent 5,$s/^\(.*\)\([/@]\)$/ \2\1/e - keepjumps silent 5,$call s:NetSort() - keepjumps silent 5,$s/^ \(.\)\(.*\)$/\2\1/e - keepjumps 5 + if line("$") >= g:netrw_bannercnt + if !exists("g:netrw_list_showall") + if g:netrw_list_hide != "" + call s:NetrwListHide() + endif + else + unlet g:netrw_list_showall + endif + exe 'keepjumps silent '.g:netrw_bannercnt.',$s/^\(.*\)\([/@]\)$/ \2\1/e' + exe 'keepjumps silent '.g:netrw_bannercnt.',$call s:NetSort()' + exe 'keepjumps silent '.g:netrw_bannercnt.',$s/^ \(.\)\(.*\)$/\2\1/e' + exe 'keepjumps '.g:netrw_bannercnt endif let prvbuf= bufnr(bufname) if prvbuf != -1 @@ -999,26 +1049,27 @@ fun! <SID>NetList(dirname) setlocal noma nomod -" call Dret("NetList 1") + call Dret("NetBrowse 1") return 1 endfun " --------------------------------------------------------------------- -" NetListCombine: -fun! <SID>NetListChgDir(dirname) - let newdir= expand("<cWORD>") -" call Dfunc("NetListChgDir(dirname<".a:dirname.">) newdir<".newdir.">") +" NetBrowseChgDir: {{{2 +fun! <SID>NetBrowseChgDir(dirname,newdir) + call Dfunc("NetBrowseChgDir(dirname<".a:dirname."> newdir<".a:newdir.">)") let dirname= a:dirname + let newdir = a:newdir if newdir !~ '/$' " handling a file let dirname= dirname.newdir -" call Decho("handling a file: dirname<".dirname.">") + call Decho("handling a file: dirname<".dirname.">") elseif newdir == './' " refresh the directory list -" call Decho("refresh directory listing") + call Decho("refresh directory listing") + set ma %d elseif newdir == '../' @@ -1033,18 +1084,154 @@ fun! <SID>NetListChgDir(dirname) " strip off a directory name from dirname let dirname= substitute(dirname,'^\(.*/\)[^/]\+/','\1','') endif -" call Decho("go up one dir: dirname<".dirname."> trailer<".trailer.">") + call Decho("go up one dir: dirname<".dirname."> trailer<".trailer.">") else " go down one directory let dirname= dirname.newdir -" call Decho("go down one dir: dirname<".dirname."> newdir<".newdir.">") + call Decho("go down one dir: dirname<".dirname."> newdir<".newdir.">") endif -" call Dret("NetListChgDir <".dirname.">") + call Dret("NetBrowseChgDir <".dirname.">") return dirname endfun +" --------------------------------------------------------------------- +" NetBrowseRm: remove a remote file or directory {{{2 +fun! <SID>NetBrowseRm(usrhost,path) range + call Dfunc("NetBrowseRm(usrhost<".a:usrhost."> path<".a:path.">)") + call Decho("firstline=".a:firstline." lastline=".a:lastline) + + " preparation for removing multiple files/directories + let ctr= a:firstline + + " remove multiple files and directories + while ctr <= a:lastline + exe ctr + + norm! 0 + let rmfile= a:path.expand("<cWORD>") + call Decho("rmfile<".rmfile.">") + + if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '/$') + " attempt to remove file + let netrw_rm_cmd= substitute(g:netrw_rm_cmd,'HOSTNAME',a:usrhost,'').' '.rmfile + call Decho("attempt to remove file: system(".netrw_rm_cmd.")") + call inputsave() + let ok= input("Confirm deletion of file<".rmfile."> ","y") + call inputrestore() + if ok == "y" + let ret= system(netrw_rm_cmd) + call Decho("returned=".ret." errcode=".v:shell_error) + endif + + else + " attempt to remove directory + let netrw_rmdir_cmd= substitute(g:netrw_rmdir_cmd,'HOSTNAME',a:usrhost,'').' '.rmfile + call Decho("attempt to remove dir: system(".netrw_rmdir_cmd.")") + call inputsave() + let ok= input("Confirm deletion of directory<".rmfile."> ","y") + call inputrestore() + + if ok == "y" + let ret= system(netrw_rmdir_cmd) + call Decho("returned=".ret." errcode=".v:shell_error) + + if v:shell_error != 0 + let netrw_rmf_cmd= substitute(g:netrw_rmf_cmd,'HOSTNAME',a:usrhost,'').' '.substitute(rmfile,'/$','','e') + call Decho("2nd attempt to remove dir: system(".netrw_rmf_cmd.")") + let ret= system(netrw_rmf_cmd) + call Decho("returned=".ret." errcode=".v:shell_error) + + if v:shell_error != 0 + echoerr "unable to remove directory<".rmfile."> -- is it empty?" + endif + endif + endif + endif + + let ctr= ctr + 1 + endwhile + + " refresh the directory + let curline= line(".")-1 + call Decho("refresh the directory") + call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./')) + exe curline + + call Dret("NetBrowseRm") +endfun + +" --------------------------------------------------------------------- +" NetBrowseRename: rename a remote file or directory {{{2 +fun! <SID>NetBrowseRename(usrhost,path) + call Dfunc("NetBrowseRename(usrhost<".a:usrhost."> path<".a:path.">)") + + " preparation for removing multiple files/directories + let ctr = a:firstline + let rename_cmd = substitute(g:netrw_rename_cmd,'\<HOSTNAME\>',a:usrhost,'') + + " attempt to rename files/directories + while ctr <= a:lastline + exe ctr + + norm! 0 + let oldname= a:path.expand("<cWORD>") + call Decho("oldname<".oldname.">") + + call inputsave() + let newname= input("Moving ".a:usrhost."'s ".oldname." to : ",oldname) + call inputrestore() + + let ret= system(rename_cmd." ".oldname." ".newname) + call Decho("executing system(".rename_cmd." ".oldname." ".newname) + + let ctr= ctr + 1 + endwhile + + " refresh the directory + let curline= line(".") + call <SID>NetBrowse(<SID>NetBrowseChgDir(expand("%"),'./')) + exe curline + call Dret("NetBrowseRename") +endfun + +" --------------------------------------------------------------------- +" NetBrowseX: allows users to write custom functions to operate on {{{2 +" files given their extension +fun! <SID>NetBrowseX(fname) + call Dfunc("NetBrowseX(".a:fname.")") + + let exten= substitute(a:fname,'.*\.\(.\{-}\)','\1','e') + call Decho("exten<".exten."> "."NetrwFileHandler_".exten."():exists=".exists("*NetrwFileHandler_".exten)) + if exten != "" && exists("*NetrwFileHandler_".exten) + exe "call NetrwFileHandler_".exten.'("'.a:fname.'")' + endif + call Dret("NetBrowseX") +endfun + +" --------------------------------------------------------------------- +" NetrwListHide: uses [range]g~...~d to delete files that match comma {{{2 +" separated patterns given in g:netrw_list_hide +fun! <SID>NetrwListHide() + call Dfunc("NetrwListHide() listhide<".g:netrw_list_hide.">") + + let listhide= g:netrw_list_hide + while listhide != "" + if listhide =~ ',' + let hide = substitute(listhide,',.*$','','e') + let listhide = substitute(listhide,'^.\{-},\(.*\)$','\1','e') + else + let hide = listhide + let listhide= "" + endif + call Decho("pruning <".hide."> listhide<".listhide.">") + exe 'keepjumps silent '.g:netrw_bannercnt.',$g~'.hide.'~d' + endwhile + + call Dret("NetrwListHide") +endfun + " ------------------------------------------------------------------------ " NetMethod: determine method of transfer {{{1 " method == 1: rcp @@ -1057,7 +1244,7 @@ endfun " 8: fetch " 9: sftp fun! s:NetMethod(choice) " globals: method machine id passwd fname -" call Dfunc("NetMethod(a:choice<".a:choice.">)") + call Dfunc("NetMethod(a:choice<".a:choice.">)") " initialization let b:netrw_method = 0 @@ -1089,11 +1276,11 @@ fun! s:NetMethod(choice) " globals: method machine id passwd fname let fetchurm = '^fetch://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$' let sftpurm = '^sftp://\([^/]\{-}\)/\(.*\)\=$' -" call Decho("determine method:") + call Decho("determine method:") " Determine Method " rcp://user@hostname/...path-to-file if match(a:choice,rcpurm) == 0 -" call Decho("rcp://...") + call Decho("rcp://...") let b:netrw_method = 1 let userid = substitute(a:choice,rcpurm,'\2',"") let g:netrw_machine= substitute(a:choice,rcpurm,'\3',"") @@ -1104,7 +1291,7 @@ fun! s:NetMethod(choice) " globals: method machine id passwd fname " scp://user@hostname/...path-to-file elseif match(a:choice,scpurm) == 0 -" call Decho("scp://...") + 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',"") @@ -1112,28 +1299,28 @@ fun! s:NetMethod(choice) " globals: method machine id passwd fname " http://user@hostname/...path-to-file elseif match(a:choice,httpurm) == 0 -" call Decho("http://...") + call Decho("http://...") let b:netrw_method = 5 let g:netrw_machine= substitute(a:choice,httpurm,'\1',"") let b:netrw_fname = substitute(a:choice,httpurm,'\2',"") " dav://hostname[:port]/..path-to-file.. elseif match(a:choice,davurm) == 0 -" call Decho("dav://...") + call Decho("dav://...") let b:netrw_method= 6 let g:netrw_machine= substitute(a:choice,davurm,'\1',"") let b:netrw_fname = substitute(a:choice,davurm,'\2',"") " rsync://user@hostname/...path-to-file elseif match(a:choice,rsyncurm) == 0 -" call Decho("rsync://...") + call Decho("rsync://...") let b:netrw_method = 7 let g:netrw_machine= substitute(a:choice,rsyncurm,'\1',"") let b:netrw_fname = substitute(a:choice,rsyncurm,'\2',"") " ftp://[user@]hostname[[:#]port]/...path-to-file elseif match(a:choice,ftpurm) == 0 -" call Decho("ftp://...") + call Decho("ftp://...") let userid = substitute(a:choice,ftpurm,'\2',"") let g:netrw_machine= substitute(a:choice,ftpurm,'\3',"") let g:netrw_port = substitute(a:choice,ftpurm,'\4',"") @@ -1161,7 +1348,7 @@ fun! s:NetMethod(choice) " globals: method machine id passwd fname endif elseif match(a:choice,fetchurm) == 0 -" call Decho("fetch://...") + call Decho("fetch://...") let b:netrw_method = 8 let g:netrw_userid = substitute(a:choice,fetchurm,'\2',"") let g:netrw_machine= substitute(a:choice,fetchurm,'\3',"") @@ -1170,7 +1357,7 @@ fun! s:NetMethod(choice) " globals: method machine id passwd fname " Issue an ftp : "machine id password [path/]filename" elseif match(a:choice,mipf) == 0 -" call Decho("(ftp) host id pass file") + call Decho("(ftp) host id pass file") let b:netrw_method = 3 let g:netrw_machine = substitute(a:choice,mipf,'\1',"") let g:netrw_uid = substitute(a:choice,mipf,'\2',"") @@ -1179,7 +1366,7 @@ fun! s:NetMethod(choice) " globals: method machine id passwd fname " Issue an ftp: "hostname [path/]filename" elseif match(a:choice,mf) == 0 -" call Decho("(ftp) host file") + call Decho("(ftp) host file") if exists("g:netrw_uid") && exists("g:netrw_passwd") let b:netrw_method = 3 let g:netrw_machine = substitute(a:choice,mf,'\1',"") @@ -1193,22 +1380,22 @@ fun! s:NetMethod(choice) " globals: method machine id passwd fname " sftp://user@hostname/...path-to-file elseif match(a:choice,sftpurm) == 0 -" call Decho("sftp://...") + call Decho("sftp://...") let b:netrw_method = 9 let g:netrw_machine= substitute(a:choice,sftpurm,'\1',"") let b:netrw_fname = substitute(a:choice,sftpurm,'\2',"") " Issue an rcp: hostname:filename" (this one should be last) elseif match(a:choice,rcphf) == 0 -" call Decho("(rcp) [user@]host:file) rcphf<".rcphf.">") + call Decho("(rcp) [user@]host:file) rcphf<".rcphf.">") let b:netrw_method = 1 let userid = substitute(a:choice,rcphf,'\2',"") let g:netrw_machine= substitute(a:choice,rcphf,'\3',"") let b:netrw_fname = substitute(a:choice,rcphf,'\4',"") -" call Decho('\1<'.substitute(a:choice,rcphf,'\1',"").">") -" call Decho('\2<'.substitute(a:choice,rcphf,'\2',"").">") -" call Decho('\3<'.substitute(a:choice,rcphf,'\3',"").">") -" call Decho('\4<'.substitute(a:choice,rcphf,'\4',"").">") + call Decho('\1<'.substitute(a:choice,rcphf,'\1',"").">") + call Decho('\2<'.substitute(a:choice,rcphf,'\2',"").">") + call Decho('\3<'.substitute(a:choice,rcphf,'\3',"").">") + call Decho('\4<'.substitute(a:choice,rcphf,'\4',"").">") if userid != "" let g:netrw_uid= userid endif @@ -1222,18 +1409,18 @@ fun! s:NetMethod(choice) " globals: method machine id passwd fname let b:netrw_method = -1 endif -" call Decho("a:choice <".a:choice.">") -" call Decho("b:netrw_method <".b:netrw_method.">") -" call Decho("g:netrw_machine<".g:netrw_machine.">") -" call Decho("g:netrw_port <".g:netrw_port.">") -" if exists("g:netrw_uid") "Decho -" call Decho("g:netrw_uid <".g:netrw_uid.">") -" endif "Decho -" if exists("g:netrw_passwd") "Decho -" call Decho("g:netrw_passwd <".g:netrw_passwd.">") -" endif "Decho -" call Decho("b:netrw_fname <".b:netrw_fname.">") -" call Dret("NetMethod") + call Decho("a:choice <".a:choice.">") + call Decho("b:netrw_method <".b:netrw_method.">") + call Decho("g:netrw_machine<".g:netrw_machine.">") + call Decho("g:netrw_port <".g:netrw_port.">") + if exists("g:netrw_uid") "Decho + call Decho("g:netrw_uid <".g:netrw_uid.">") + endif "Decho + if exists("g:netrw_passwd") "Decho + call Decho("g:netrw_passwd <".g:netrw_passwd.">") + endif "Decho + call Decho("b:netrw_fname <".b:netrw_fname.">") + call Dret("NetMethod") endfun " end of NetMethod @@ -1246,32 +1433,32 @@ fun! NetUserPass(...) " get/set userid if a:0 == 0 -" call Dfunc("NetUserPass(a:0<".a:0.">)") + call Dfunc("NetUserPass(a:0<".a:0.">)") if !exists("g:netrw_uid") || g:netrw_uid == "" " via prompt let g:netrw_uid= input('Enter username: ') endif else " from command line -" call Dfunc("NetUserPass(a:1<".a:1.">) {") + call Dfunc("NetUserPass(a:1<".a:1.">) {") let g:netrw_uid= a:1 endif " get password if a:0 <= 1 " via prompt -" call Decho("a:0=".a:0." case <=1:") + call Decho("a:0=".a:0." case <=1:") let g:netrw_passwd= inputsecret("Enter Password: ") else " from command line -" call Decho("a:0=".a:0." case >1: a:2<".a:2.">") + call Decho("a:0=".a:0." case >1: a:2<".a:2.">") let g:netrw_passwd=a:2 endif -" call Dret("NetUserPass") + call Dret("NetUserPass") endfun " end NetUserPass " ------------------------------------------------------------------------ " NetOptionSave: save options and set to "standard" form {{{1 fun!s:NetOptionSave() -" call Dfunc("NetOptionSave()") + call Dfunc("NetOptionSave()") " Get Temporary Filename let s:aikeep = &ai @@ -1290,16 +1477,16 @@ fun!s:NetOptionSave() if has("win32") && !has("win95") let s:swfkeep= &swf set noswf -" call Decho("setting s:swfkeep to <".&swf.">") + call Decho("setting s:swfkeep to <".&swf.">") endif -" call Dret("NetOptionSave") + call Dret("NetOptionSave") endfun " ------------------------------------------------------------------------ " NetOptionRestore: restore options {{{1 fun! s:NetOptionRestore() -" call Dfunc("NetOptionRestore()") + call Dfunc("NetOptionRestore()") let &ai = s:aikeep let &cin = s:cinkeep @@ -1322,7 +1509,7 @@ fun! s:NetOptionRestore() unlet s:twkeep unlet s:dirkeep -" call Dret("NetOptionRestore") + call Dret("NetOptionRestore") endfun " ------------------------------------------------------------------------ @@ -1334,12 +1521,12 @@ endfun " at the end of the transfer. if has("win95") && g:netrw_win95ftp fun! NetReadFixup(method, line1, line2) -" call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")") + call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")") if method == 3 " ftp (no <.netrc>) let fourblanklines= line2 - 3 silent fourblanklines.",".line2."g/^\s*/d" endif -" call Dret("NetReadFixup") + call Dret("NetReadFixup") endfun endif diff --git a/runtime/syntax/netrwlist.vim b/runtime/syntax/netrwlist.vim index 09967f514..a22469e04 100644 --- a/runtime/syntax/netrwlist.vim +++ b/runtime/syntax/netrwlist.vim @@ -1,7 +1,7 @@ " Language : Netrw Remote-Directory Listing Syntax " Maintainer : Charles E. Campbell, Jr. -" Last change: Jun 10, 2004 -" Version : 1 +" Last change: Jun 25, 2004 +" Version : 2 " Syntax Clearing: {{{1 if version < 600 @@ -11,17 +11,24 @@ elseif exists("b:current_syntax") endif " Directory List Syntax Highlighting: {{{1 -syn match netrwDir "^.*/$" contains=netrwSpecial -syn match netrwSpecial "[*=@|/]$" -syn match netrwSlash contained "/" -syn match netrwComment '".*$' +syn match netrwDir "^.*/$" contains=netrwClassify +syn match netrwClassify "[*=|@/]$" +syn match netrwSlash contained "/" +syn match netrwSymLink "^.*@$" contains=netrwClassify +syn match netrwComment '".*$' contains=netrwHide +syn match netrwHide '^"\s*Hiding:' skipwhite nextgroup=netrwHidePat +syn match netrwHidePat contained "[^,]\+" skipwhite nextgroup=netrwHideSep +syn match netrwHideSep contained transparent "," skipwhite nextgroup=netrwHidePat " Highlighting Links: {{{1 if !exists("did_drchip_dbg_syntax") let did_drchip_netrwlist_syntax= 1 + hi link netrwClassify Function hi link netrwComment Comment + hi link netrwHide netrwComment + hi link netrwHidePat String hi link netrwDir Directory - hi link netrwSpecial Function + hi link netrwSymLink Special endif " Current Syntax: {{{1 diff --git a/runtime/tutor/tutor b/runtime/tutor/tutor index 7da46f037..04fe335b8 100644 --- a/runtime/tutor/tutor +++ b/runtime/tutor/tutor @@ -1,5 +1,5 @@ =============================================================================== -= W e l c o m e t o t h e V I M T u t o r - Version 1.5 = += W e l c o m e t o t h e V I M T u t o r - Version 1.7 = =============================================================================== Vim is a very powerful editor that has many commands, too many to @@ -10,6 +10,7 @@ The approximate time required to complete the tutor is 25-30 minutes, depending upon how much time is spent with experimentation. + ATTENTION: The commands in the lessons will modify the text. Make a copy of this file to practise on (if you started "vimtutor" this is already a copy). @@ -33,7 +34,7 @@ 1. Move the cursor around the screen until you are comfortable. 2. Hold down the down key (j) until it repeats. ----> Now you know how to move to the next lesson. + Now you know how to move to the next lesson. 3. Using the down key, move to Lesson 1.2. @@ -41,36 +42,36 @@ Note: If you are ever unsure about something you typed, press <ESC> to place you in Normal mode. Then retype the command you wanted. Note: The cursor keys should also work. But using hjkl you will be able to - move around much faster, once you get used to it. + move around much faster, once you get used to it. Really! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Lesson 1.2: ENTERING AND EXITING VIM + Lesson 1.2: EXITING VIM !! NOTE: Before executing any of the steps below, read this entire lesson!! 1. Press the <ESC> key (to make sure you are in Normal mode). - 2. Type: :q! <ENTER>. - ----> This exits the editor WITHOUT saving any changes you have made. - If you want to save the changes and exit type: - :wq <ENTER> + 2. Type: :q! <ENTER>. + This exits the editor, DISCARDING any changes you have made. 3. When you see the shell prompt, type the command that got you into this - tutor. That could be: vimtutor <ENTER> - Normally you would use: vim tutor <ENTER> - ----> 'vim' means enter the vim editor, 'tutor' is the file you wish to edit. + tutor. That would be: vimtutor <ENTER> 4. If you have these steps memorized and are confident, execute steps - 1 through 3 to exit and re-enter the editor. Then move the cursor down - to Lesson 1.3. + 1 through 3 to exit and re-enter the editor. + +NOTE: :q! <ENTER> discards any changes you made. In a few lessons you + will learn how to save the changes to a file. + + 5. Move the cursor down to Lesson 1.3. + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lesson 1.3: TEXT EDITING - DELETION -** While in Normal mode press x to delete the character under the cursor. ** + ** Press x to delete the character under the cursor. ** 1. Move the cursor to the line below marked --->. @@ -90,10 +91,10 @@ NOTE: As you go through this tutor, do not try to memorize, learn by usage. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Lesson 1.4: TEXT EDITING - INSERTION + Lesson 1.4: TEXT EDITING - INSERTION - ** While in Normal mode press i to insert text. ** + ** Press i to insert text. ** 1. Move the cursor to the first line below marked --->. @@ -113,33 +114,79 @@ NOTE: As you go through this tutor, do not try to memorize, learn by usage. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Lesson 1.5: TEXT EDITING - APPENDING + + + ** Press A to append text. ** + + 1. Move the cursor to the first line below marked --->. + It does not matter on what character the cursor is in that line. + + 2. Press A and type in the necessary additions. + + 3. As the text has been appended press <ESC> to return to Normal mode. + + 4. Move the cursor to the second line marked ---> and repeat + steps 2 and 3 to correct this sentence. + +---> There is some text missing from th + There is some text missing from this line. +---> There is also some text miss + There is also some text missing here. + + 5. When you are comfortable appending text move to lesson 1.6. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Lesson 1.6: EDITING A FILE + + + ** Use :wq to save a file and exit. ** + + !! NOTE: Before executing any of the steps below, read this entire lesson!! + + 1. Exit this tutor as you did in lesson 1.2: :q! + + 2. At the shell prompt type this command: vim tutor <ENTER> + 'vim' is the command to start the Vim editor, 'tutor' is the name of the + file you wish to edit. Use a file that may be changed. + + 3. Insert and delete text as you learned in the previous lessons. + + 4. Save the file with changes and exit Vim with: :wq <ENTER> + + 5. Restart the vimtutor and move down to the following summary. + + 6. After reading the above steps and understanding them: do it. + + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LESSON 1 SUMMARY 1. The cursor is moved using either the arrow keys or the hjkl keys. h (left) j (down) k (up) l (right) - 2. To enter Vim (from the % prompt) type: vim FILENAME <ENTER> + 2. To start Vim from the shell prompt type: vim FILENAME <ENTER> 3. To exit Vim type: <ESC> :q! <ENTER> to trash all changes. OR type: <ESC> :wq <ENTER> to save the changes. - 4. To delete a character under the cursor in Normal mode type: x + 4. To delete the character at the cursor type: x - 5. To insert text at the cursor while in Normal mode type: - i type in text <ESC> + 5. To insert or append text type: + i type inserted text <ESC> insert before the cursor + A type appended text <ESC> append after the line NOTE: Pressing <ESC> will place you in Normal mode or will cancel an unwanted and partially completed command. Now continue with Lesson 2. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lesson 2.1: DELETION COMMANDS - ** Type dw to delete to the end of a word. ** + ** Type dw to delete a word. ** 1. Press <ESC> to make sure you are in Normal mode. @@ -149,15 +196,15 @@ Now continue with Lesson 2. 4. Type dw to make the word disappear. - NOTE: The letters dw will appear on the last line of the screen as you type - them. If you typed something wrong, press <ESC> and start over. + NOTE: The letter d will appear on the last line of the screen as you type + it. Vim is waiting for you to type w . If you see another character + than d you typed something wrong; press <ESC> and start over. ---> There are a some words fun that don't belong paper in this sentence. 5. Repeat steps 3 and 4 until the sentence is correct and go to Lesson 2.2. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lesson 2.2: MORE DELETION COMMANDS @@ -182,56 +229,102 @@ Now continue with Lesson 2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Lesson 2.3: ON COMMANDS AND OBJECTS + Lesson 2.3: ON OPERATORS AND MOTIONS + + Many commands that change text are made from an operator and a motion. + The format for a delete command with the d delete operator is as follows: - The format for the d delete command is as follows: + d motion - [number] d object OR d [number] object Where: - number - is how many times to execute the command (optional, default=1). - d - is the command to delete. - object - is what the command will operate on (listed below). + d - is the delete operator. + motion - is what the operator will operate on (listed below). - A short list of objects: - w - from the cursor to the end of the word, including the space. - e - from the cursor to the end of the word, NOT including the space. - $ - from the cursor to the end of the line. + A short list of motions: + w - until the start of the next word, EXCLUDING its first character. + e - to the end of the current word, INCLUDING the last character. + $ - to the end of the line, INCLUDING the last character. -NOTE: For the adventurous, pressing just the object while in Normal mode - without a command will move the cursor as specified in the object list. + Thus typing de will delete from the cursor to the end of the word. + +NOTE: Pressing just the motion while in Normal mode without an operator will + move the cursor as specified. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Lesson 2.4: USING A COUNT FOR A MOTION + + + ** Typing a number before a motion repeats it that many times. ** + + 1. Move the cursor to the start of the line marked ---> below. + + 2. Type 2w to move the cursor two words forward. + + 3. Type 3e to move the cursor to the end of the third word forward. + + 4. Type 0 (zero) to move to the start of the line. + + 5. Repeat steps 2 and 3 with different numbers. + +---> This is just a line with words you can move around in. + + 6. Move on to Lesson 2.5. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Lesson 2.4: AN EXCEPTION TO 'COMMAND-OBJECT' + Lesson 2.5: USING A COUNT TO DELETE MORE + + + ** Typing a number with an operator repeats it that many times. ** + + In the combination of the delete operator and a motion mentioned above you + insert a count before the motion to delete more: + d number motion + + 1. Move the cursor to the first UPPER CASE word in the line marked --->. + 2. Type 2dw to delete the two UPPER CASE words - ** Type dd to delete a whole line. ** + 3. Repeat steps 1 and 2 with a different count to delete the consecutive + UPPER CASE words with one command + +---> this ABC DE line FGHI JK LMN OP of words is Q RS TUV cleaned up. + +NOTE: A count between the operator d and the motion works similar to + using the motion without an operator. + + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Lesson 2.6: OPERATING ON LINES + + + ** Type dd to delete a whole line. ** Due to the frequency of whole line deletion, the designers of Vi decided - it would be easier to simply type two d's in a row to delete a line. + it would be easier to simply type two d's to delete a line. 1. Move the cursor to the second line in the phrase below. 2. Type dd to delete the line. 3. Now move to the fourth line. - 4. Type 2dd (remember number-command-object) to delete the two lines. + 4. Type 2dd to delete two lines. - 1) Roses are red, - 2) Mud is fun, - 3) Violets are blue, - 4) I have a car, - 5) Clocks tell time, - 6) Sugar is sweet - 7) And so are you. +---> 1) Roses are red, +---> 2) Mud is fun, +---> 3) Violets are blue, +---> 4) I have a car, +---> 5) Clocks tell time, +---> 6) Sugar is sweet +---> 7) And so are you. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Lesson 2.5: THE UNDO COMMAND + Lesson 2.7: THE UNDO COMMAND - ** Press u to undo the last commands, U to fix a whole line. ** + ** Press u to undo the last commands, U to fix a whole line. ** 1. Move the cursor to the line below marked ---> and place it on the first error. @@ -254,45 +347,45 @@ NOTE: For the adventurous, pressing just the object while in Normal mode LESSON 2 SUMMARY - 1. To delete from the cursor to the end of a word type: dw - + 1. To delete from the cursor upto the next word type: dw 2. To delete from the cursor to the end of a line type: d$ - 3. To delete a whole line type: dd - 4. The format for a command in Normal mode is: - - [number] command object OR command [number] object + 4. To repeat a motion prepend it with a number: 2w + 5. The format for a change command is: + operator [number] motion where: - number - is how many times to repeat the command - command - is what to do, such as d for delete - object - is what the command should act upon, such as w (word), - $ (to the end of line), etc. + operator - is what to do, such as d for delete + [number] - is an optional count to repeat the motion + motion - moves over the text to operator on, such as w (word), + $ (to the end of line), etc. - 5. To undo previous actions, type: u (lowercase u) - To undo all the changes on a line type: U (capital U) - To undo the undo's type: CTRL-R + 6. To move to the start of the line use a zero: 0 + + 7. To undo previous actions, type: u (lowercase u) + To undo all the changes on a line, type: U (capital U) + To undo the undo's, type: CTRL-R ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lesson 3.1: THE PUT COMMAND - ** Type p to put the last deletion after the cursor. ** + ** Type p to put previously deleted text after the cursor. ** - 1. Move the cursor to the first line in the set below. + 1. Move the cursor to the first ---> line below. - 2. Type dd to delete the line and store it in Vim's buffer. + 2. Type dd to delete the line and store it in a Vim register. - 3. Move the cursor to the line ABOVE where the deleted line should go. + 3. Move the cursor to the c) line, ABOVE where the deleted line should go. - 4. While in Normal mode, type p to replace the line. + 4. Type p to put the line below the cursor. 5. Repeat steps 2 through 4 to put all the lines in correct order. - d) Can you learn too? - b) Violets are blue, - c) Intelligence is learned, - a) Roses are red, +---> d) Can you learn too? +---> b) Violets are blue, +---> c) Intelligence is learned, +---> a) Roses are red, @@ -300,45 +393,45 @@ NOTE: For the adventurous, pressing just the object while in Normal mode Lesson 3.2: THE REPLACE COMMAND - ** Type r and a character to replace the character under the cursor. ** + ** Type rx to replace the character at the cursor with x . ** 1. Move the cursor to the first line below marked --->. 2. Move the cursor so that it is on top of the first error. - 3. Type r and then the character which should replace the error. + 3. Type r and then the character which should be there. - 4. Repeat steps 2 and 3 until the first line is correct. + 4. Repeat steps 2 and 3 until the first line is equal to the second one. ---> Whan this lime was tuoed in, someone presswd some wrojg keys! ---> When this line was typed in, someone pressed some wrong keys! 5. Now move on to Lesson 3.2. -NOTE: Remember that you should be learning by use, not memorization. +NOTE: Remember that you should be learning by doing, not memorization. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Lesson 3.3: THE CHANGE COMMAND + Lesson 3.3: THE CHANGE OPERATOR - ** To change part or all of a word, type cw . ** + ** To change until the end of a word, type ce . ** 1. Move the cursor to the first line below marked --->. - 2. Place the cursor on the u in lubw. + 2. Place the cursor on the u in lubw. - 3. Type cw and the correct word (in this case, type 'ine'.) + 3. Type ce and the correct word (in this case, type ine ). - 4. Press <ESC> and move to the next error (the first character to be changed.) + 4. Press <ESC> and move to the next character that needs to be changed. 5. Repeat steps 3 and 4 until the first sentence is the same as the second. ---> This lubw has a few wptfd that mrrf changing usf the change command. ---> This line has a few words that need changing using the change command. -Notice that cw not only replaces the word, but also places you in insert. +Notice that ce deletes the word and places you in Insert mode. @@ -346,70 +439,70 @@ Notice that cw not only replaces the word, but also places you in insert. Lesson 3.4: MORE CHANGES USING c - ** The change command is used with the same objects as delete. ** + ** The change command is used with the same motions as delete. ** - 1. The change command works in the same way as delete. The format is: + 1. The change operator works in the same way as delete. The format is: - [number] c object OR c [number] object + c [number] motion - 2. The objects are also the same, such as w (word), $ (end of line), etc. + 2. The motions are the same, such as w (word) and $ (end of line). 3. Move to the first line below marked --->. 4. Move the cursor to the first error. - 5. Type c$ to make the rest of the line like the second and press <ESC>. + 5. Type c$ and type the rest of the line like the second and press <ESC>. ---> The end of this line needs some help to make it like the second. ---> The end of this line needs to be corrected using the c$ command. - +NOTE: You can use the Backspace key to correct mistakes while typing. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LESSON 3 SUMMARY - 1. To replace text that has already been deleted, type p . This Puts the + 1. To put back text that has just been deleted, type p . This puts the deleted text AFTER the cursor (if a line was deleted it will go on the line below the cursor). 2. To replace the character under the cursor, type r and then the - character which will replace the original. + character you want to have there. - 3. The change command allows you to change the specified object from the - cursor to the end of the object. eg. Type cw to change from the - cursor to the end of the word, c$ to change to the end of a line. + 3. The change operator allows you to change from the cursor to where the + motion takes you. eg. Type ce to change from the cursor to the end of + the word, c$ to change to the end of a line. 4. The format for change is: - [number] c object OR c [number] object + c [number] motion Now go on to the next lesson. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Lesson 4.1: LOCATION AND FILE STATUS + Lesson 4.1: CURSOR LOCATION AND FILE STATUS - - ** Type CTRL-g to show your location in the file and the file status. - Type SHIFT-G to move to a line in the file. ** + ** Type CTRL-G to show your location in the file and the file status. + Type G to move to a line in the file. ** Note: Read this entire lesson before executing any of the steps!! - 1. Hold down the Ctrl key and press g . A status line will appear at the - bottom of the page with the filename and the line you are on. Remember - the line number for Step 3. - - 2. Press shift-G to move you to the bottom of the file. + 1. Hold down the Ctrl key and press g . We call this CTRL-G. + A message will appear at the bottom of the page with the filename and the + position in the file. Remember the line number for Step 3. - 3. Type in the number of the line you were on and then shift-G. This will - return you to the line you were on when you first pressed Ctrl-g. - (When you type in the numbers, they will NOT be displayed on the screen.) +NOTE: You may see the cursor position in the lower right corner of the screen + This happens when the 'ruler' option is set (explained in lesson 6). - 4. If you feel confident to do this, execute steps 1 through 3. + 2. Press G to move you to the bottom of the file. + Type gg to move you to the start of the file. + 3. Type the number of the line you were on and then G . This will + return you to the line you were on when you first pressed CTRL-G. + 4. If you feel confident to do this, execute steps 1 through 3. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lesson 4.2: THE SEARCH COMMAND @@ -423,16 +516,16 @@ Now go on to the next lesson. 2. Now type 'errroor' <ENTER>. This is the word you want to search for. 3. To search for the same phrase again, simply type n . - To search for the same phrase in the opposite direction, type Shift-N . + To search for the same phrase in the opposite direction, type N . - 4. If you want to search for a phrase in the backwards direction, use the - command ? instead of /. + 4. To search for a phrase in the backward direction, use ? instead of / . ----> "errroor" is not the way to spell error; errroor is an error. + 5. To go back to where you came from press CTRL-O (Keep Ctrl down while + pressing the letter o). Repeat to go back further. CTRL-I goes forward. +Note: "errroor" is not the way to spell error; errroor is an error. Note: When the search reaches the end of the file it will continue at the - start. - + start, unless the 'wrapscan' option has been reset. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lesson 4.3: MATCHING PARENTHESES SEARCH @@ -444,21 +537,21 @@ Note: When the search reaches the end of the file it will continue at the 2. Now type the % character. - 3. The cursor should be on the matching parenthesis or bracket. + 3. The cursor will move to the matching parenthesis or bracket. - 4. Type % to move the cursor back to the first bracket (by matching). - ----> This ( is a test line with ('s, ['s ] and {'s } in it. )) + 4. Type % to move the cursor to the other matching bracket. -Note: This is very useful in debugging a program with unmatched parentheses! + 5. Move the cursor to another (,),[,],{ or } and see what % does. +---> This ( is a test line with ('s, ['s ] and {'s } in it. )) +Note: This is very useful in debugging a program with unmatched parentheses! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Lesson 4.4: A WAY TO CHANGE ERRORS + Lesson 4.4: THE SUBSTITUTE COMMAND ** Type :s/old/new/g to substitute 'new' for 'old'. ** @@ -466,43 +559,43 @@ Note: This is very useful in debugging a program with unmatched parentheses! 1. Move the cursor to the line below marked --->. 2. Type :s/thee/the <ENTER> . Note that this command only changes the - first occurrence on the line. + first occurrence of "thee" in the line. - 3. Now type :s/thee/the/g meaning substitute globally on the line. - This changes all occurrences on the line. + 3. Now type :s/thee/the/g . Adding the g flag means to substitute + globally in the line, change all occurrences of "thee" in the line. ---> thee best time to see thee flowers is in thee spring. 4. To change every occurrence of a character string between two lines, - type :#,#s/old/new/g where #,# are the numbers of the two lines. - Type :%s/old/new/g to change every occurrence in the whole file. - - - + type :#,#s/old/new/g where #,# are the line numbers of the range + of lines where the subsitution is to be done. + Type :%s/old/new/g to change every occurrence in the whole file. + Type :%s/old/new/gc to find every occurrence in the whole file, + with a prompt wether to substitute or not. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LESSON 4 SUMMARY - 1. Ctrl-g displays your location in the file and the file status. - Shift-G moves to the end of the file. A line number followed - by Shift-G moves to that line number. + 1. CTRL-G displays your location in the file and the file status. + G moves to the end of the file. + number G moves to that line number. + gg moves to the first line. 2. Typing / followed by a phrase searches FORWARD for the phrase. Typing ? followed by a phrase searches BACKWARD for the phrase. After a search type n to find the next occurrence in the same direction - or Shift-N to search in the opposite direction. + or N to search in the opposite direction. + CTRL-O takes you back to older positions, CTRL-I to newer positions. - 3. Typing % while the cursor is on a (,),[,],{, or } locates its - matching pair. + 3. Typing % while the cursor is on a (,),[,],{, or } goes to its match. - 4. To substitute new for the first old on a line type :s/old/new + 4. To substitute new for the first old in a line type :s/old/new To substitute new for all 'old's on a line type :s/old/new/g To substitute phrases between two line #'s type :#,#s/old/new/g To substitute all occurrences in the file type :%s/old/new/g To ask for confirmation each time add 'c' :%s/old/new/gc - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lesson 5.1: HOW TO EXECUTE AN EXTERNAL COMMAND @@ -510,27 +603,27 @@ Note: This is very useful in debugging a program with unmatched parentheses! ** Type :! followed by an external command to execute that command. ** 1. Type the familiar command : to set the cursor at the bottom of the - screen. This allows you to enter a command. + screen. This allows you to enter a command-line command. 2. Now type the ! (exclamation point) character. This allows you to execute any external shell command. 3. As an example type ls following the ! and then hit <ENTER>. This will show you a listing of your directory, just as if you were at the - shell prompt. Or use :!dir if ls doesn't work. + shell prompt. Or use :!dir if ls doesn't work. -Note: It is possible to execute any external command this way. +Note: It is possible to execute any external command this way, also with + arguments. Note: All : commands must be finished by hitting <ENTER> - - + From here one we will not always mention it. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lesson 5.2: MORE ON WRITING FILES - ** To save the changes made to the file, type :w FILENAME. ** + ** To save the changes made to the text, type :w FILENAME. ** 1. Type :!dir or :!ls to get a listing of your directory. You already know you must hit <ENTER> after this. @@ -539,10 +632,10 @@ Note: All : commands must be finished by hitting <ENTER> 3. Now type: :w TEST (where TEST is the filename you chose.) - 4. This saves the whole file (Vim Tutor) under the name TEST. - To verify this, type :!dir again to see your directory + 4. This saves the whole file (the Vim Tutor) under the name TEST. + To verify this, type :!dir or :!ls again to see your directory. -Note: If you were to exit Vim and enter again with the filename TEST, the file +Note: If you were to exit Vim and start it again with vim TEST , the file would be an exact copy of the tutor when you saved it. 5. Now remove the file by typing (MS-DOS): :!del TEST @@ -550,49 +643,49 @@ Note: If you were to exit Vim and enter again with the filename TEST, the file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Lesson 5.3: A SELECTIVE WRITE COMMAND - + Lesson 5.3: SELECTING TEXT TO WRITE - ** To save part of the file, type :#,# w FILENAME ** - 1. Once again, type :!dir or :!ls to obtain a listing of your directory - and choose a suitable filename such as TEST. + ** To save part of the file, type v motion :w FILENAME ** - 2. Move the cursor to the top of this page and type Ctrl-g to find the - number of that line. REMEMBER THIS NUMBER! + 1. Move the cursor to this line. - 3. Now move to the bottom of the page and type Ctrl-g again. REMEMBER THIS - LINE NUMBER ALSO! + 2. Press v and move the cursor to the fifth item below. Notice that the + text is highlighted. - 4. To save ONLY a section to a file, type :#,# w TEST where #,# are - the two numbers you remembered (top,bottom) and TEST is your filename. - - 5. Again, see that the file is there with :!dir but DO NOT remove it. + 3. Press the : character. At the bottom of the screen :'<,'> will appear. + 4. Type w TEST , where TEST is a filename that does not exist yet. Verify + that you see :'<,'>w TEST before you press Enter. + 5. Vim will write the selected lines to the file TEST. Use :!dir or !ls + to see it. Do not remove it yet! We will use it in the next lesson. +NOTE: Pressing v starts Visual selection. You can move the cursor around + to make the selection bigger or smaller. Then you can use an operator + to do something with the text. For example, d deletes the text. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lesson 5.4: RETRIEVING AND MERGING FILES - ** To insert the contents of a file, type :r FILENAME ** - - 1. Type :!dir to make sure your TEST filename is present from before. + ** To insert the contents of a file, type :r FILENAME ** - 2. Place the cursor at the top of this page. + 1. Place the cursor just above this line. -NOTE: After executing Step 3 you will see Lesson 5.3. Then move DOWN to - this lesson again. +NOTE: After executing Step 2 you will see text from Lesson 5.3. Then move + DOWN to see this lesson again. - 3. Now retrieve your TEST file using the command :r TEST where TEST is - the name of the file. + 2. Now retrieve your TEST file using the command :r TEST where TEST is + the name of the file you used. + The file you retrieve is placed below the cursor line. -NOTE: The file you retrieve is placed starting where the cursor is located. - - 4. To verify that a file was retrieved, cursor back and notice that there + 3. To verify that a file was retrieved, cursor back and notice that there are now two copies of Lesson 5.3, the original and the file version. +NOTE: You can also read the output of an external command. For example, + :r !ls reads the output of the ls command and puts it below the + cursor. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -608,14 +701,14 @@ NOTE: The file you retrieve is placed starting where the cursor is located. 2. :w FILENAME writes the current Vim file to disk with name FILENAME. - 3. :#,#w FILENAME saves the lines # through # in file FILENAME. - - 4. :r FILENAME retrieves disk file FILENAME and inserts it into the - current file following the cursor position. - - + 3. v motion :w FILENAME saves the Visually selected lines in file + FILENAME. + 4. :r FILENAME retrieves disk file FILENAME and puts it below the + cursor position. + 5. :r !dir reads the output of the dir command and puts it below the + cursor position ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -626,17 +719,17 @@ NOTE: The file you retrieve is placed starting where the cursor is located. 1. Move the cursor to the line below marked --->. - 2. Type o (lowercase) to open up a line BELOW the cursor and place you in - Insert mode. + 2. Type the lowercase letter o to open up a line BELOW the cursor and place + you in Insert mode. - 3. Now copy the line marked ---> and press <ESC> to exit Insert mode. + 3. Now type some text and press <ESC> to exit Insert mode. ---> After typing o the cursor is placed on the open line in Insert mode. 4. To open up a line ABOVE the cursor, simply type a capital O , rather than a lowercase o. Try this on the line below. -Open up a line above this by typing Shift-O while the cursor is on this line. +---> Open up a line above this by typing O while the cursor is on this line. @@ -647,94 +740,117 @@ Open up a line above this by typing Shift-O while the cursor is on this line. ** Type a to insert text AFTER the cursor. ** - 1. Move the cursor to the end of the first line below marked ---> by - typing $ in Normal mode. + 1. Move the cursor to the start of the line below marked --->. + + 2. Press e until the cursor is on the end of li . - 2. Type an a (lowercase) to append text AFTER the character under the - cursor. (Uppercase A appends to the end of the line.) + 3. Type an a (lowercase) to append text AFTER the cursor. -Note: This avoids typing i , the last character, the text to insert, <ESC>, - cursor-right, and finally, x , just to append to the end of a line! - - 3. Now complete the first line. Note also that append is exactly the same - as Insert mode, except for the location where text is inserted. - ----> This line will allow you to practice ----> This line will allow you to practice appending text to the end of a line. + 4. Complete the word like the line below it. Press <ESC> to exit Insert + mode. + 5. Use e to move to the next incomplete word and repeat steps 3 and 4. + +---> This li will allow you to pract appendi text to a line. +---> This line will allow you to practice appending text to a line. +Note: a, i and A all go to the same Insert mode, the only difference is where + the characters are inserted. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Lesson 6.3: ANOTHER VERSION OF REPLACE + Lesson 6.3: ANOTHER WAY TO REPLACE ** Type a capital R to replace more than one character. ** - 1. Move the cursor to the first line below marked --->. + 1. Move the cursor to the first line below marked --->. Move the cursor to + the beginning of the first xxx . - 2. Place the cursor at the beginning of the first word that is different - from the second line marked ---> (the word 'last'). + 2. Now press R and type the number below it in the second line, so that it + replaces the xxx . - 3. Now type R and replace the remainder of the text on the first line by - typing over the old text to make the first line the same as the second. + 3. Press <ESC> to leave Replace mode. Notice that the rest of the line + remains unmodified. ----> To make the first line the same as the last on this page use the keys. ----> To make the first line the same as the second, type R and the new text. + 5. Repeat the steps to replace the remaining xxx. - 4. Note that when you press <ESC> to exit, any unaltered text remains. +---> Adding 123 to xxx gives you xxx. +---> Adding 123 to 456 gives you 579. +NOTE: Replace mode is like Insert mode, but every typed character deletes an + existing character. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Lesson 6.4: COPY AND PASTE TEXT + ** use the y operator to copy text and p to paste it ** -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Lesson 6.4: SET OPTION + 1. Go to the line marked with ---> below and place the cursor after "a)". + + 2. Start Visual mode with v and move the cursor to just before "first". + + 3. Type y to yank (copy) the highlighted text. - ** Set an option so a search or substitute ignores case ** + 4. Move the cursor to the end of the next line: j$ - 1. Search for 'ignore' by entering: - /ignore - Repeat several times by hitting the n key + 5. Type p to put (paste) the text. Then type: a second <ESC> . - 2. Set the 'ic' (Ignore case) option by typing: - :set ic + 6. Use Visual mode to select " item.", yank it with y , move to the end of + the next line with j$ and put the text there with p . - 3. Now search for 'ignore' again by entering: n - Repeat search several more times by hitting the n key +---> a) this is the first item. + b) - 4. Set the 'hlsearch' and 'incsearch' options: - :set hls is + Note: you can also use y as an operator; yw yanks one word. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Lesson 6.5: SET OPTION - 5. Now enter the search command again, and see what happens: - /ignore - 6. To remove the highlighting of matches, type: - :nohlsearch -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - LESSON 6 SUMMARY + ** Set an option so a search or substitute ignores case ** + 1. Search for 'ignore' by entering: /ignore <ENTER> + Repeat several times by pressing n . - 1. Typing o opens a line BELOW the cursor and places the cursor on the open - line in Insert mode. - Typing a capital O opens the line ABOVE the line the cursor is on. + 2. Set the 'ic' (Ignore case) option by entering: :set ic - 2. Type an a to insert text AFTER the character the cursor is on. - Typing a capital A automatically appends text to the end of the line. + 3. Now search for 'ignore' again by pressing n + Notice that Ignore and IGNORE are now also found. - 3. Typing a capital R enters Replace mode until <ESC> is pressed to exit. + 4. Set the 'hlsearch' and 'incsearch' options: :set hls is - 4. Typing ":set xxx" sets the option "xxx" + 5. Now type the search command again and see what happens: /ignore <ENTER> + 6. To disable ignoring case enter: :set noic +Note: To remove the highlighting of matches enter: :nohlsearch +Note: If you want to ignore case for just one search command, use \c + in the phrase: /ignore\c <ENTER> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + LESSON 6 SUMMARY + 1. Type o to open a line BELOW the cursor and start Insert mode. + Type O to open a line ABOVE the cursor. + 2. Type a to insert text AFTER the cursor. + Type A to insert text after the end of the line. + 3. The e command moves to the end of a word. + 4. The y operator yanks (copies) text, p puts (pastes) it. + 5. Typing a capital R enters Replace mode until <ESC> is pressed. + 6. Typing ":set xxx" sets the option "xxx". Some options are: + 'ic' 'ignorecase' ignore upper/lower case when searching + 'is' 'incsearch' show partial matches for a search phrase + 'hls' 'hlsearch' highlight all matching phrases + You can either use the long or the short option name. + + 7. Prepend "no" to switch an option off: :set noic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - LESSON 7: ON-LINE HELP COMMANDS + LESSON 7.1: GETTING HELP ** Use the on-line help system ** @@ -745,39 +861,85 @@ Note: This avoids typing i , the last character, the text to insert, <ESC>, - press the <F1> key (if you have one) - type :help <ENTER> - Type :q <ENTER> to close the help window. + Read the text in the help window to find out how the help works. + type CTRL-W CTRL-W to jump from one window to another + Type :q <ENTER> to close the help window. You can find help on just about any subject, by giving an argument to the ":help" command. Try these (don't forget pressing <ENTER>): :help w - :help c_<T + :help c_CTRL-D :help insert-index :help user-manual - - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - LESSON 8: CREATE A STARTUP SCRIPT + LESSON 7.2: CREATE A STARTUP SCRIPT - ** Switch on Vim features ** - Vim has many more features than Vi, but most of them are disabled by default. - To start using more features you have to create a "vimrc" file. + ** Enable Vim features ** - 1. Start editing the "vimrc" file, this depends on your system: - :edit ~/.vimrc for Unix - :edit $VIM/_vimrc for MS-Windows + Vim has many more features than Vi, but most of them are disabled by + default. To start using more features you have to create a "vimrc" file. - 2. Now read the example "vimrc" file text: + 1. Start editing the "vimrc" file. This depends on your system: + :e ~/.vimrc for Unix + :e $VIM/_vimrc for MS-Windows - :read $VIMRUNTIME/vimrc_example.vim + 2. Now read the example "vimrc" file contents: + :r $VIMRUNTIME/vimrc_example.vim 3. Write the file with: - - :write + :w The next time you start Vim it will use syntax highlighting. You can add all your preferred settings to this "vimrc" file. + For more information type :help vimrc-intro + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + LESSON 7.3: COMPLETION + + + ** Command line completion with CTRL-D and <TAB> ** + + 1. Make sure Vim is not in compatible mode: :set nocp + + 2. Look what files exist in the directory: :!ls or :!dir + + 3. Type the start of a command: :e + + 4. Press CTRL-D and Vim will show a list of commands that start with "e". + + 5. Press <TAB> and Vim will complete the command name to ":edit". + + 6. Now add a space and the start of an existing file name: :edit FIL + + 7. Press <TAB>. Vim will complete the name (if it is unique). + +NOTE: Completion works for many commands. Just try pressing CTRL-D and + <TAB>. It is especially useful for :help . + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + LESSON 7 SUMMARY + + + 1. Type :help or press <F1> or <Help> to open a help window. + + 2. Type :help cmd to find help on cmd . + + 3. Type CTRL-W CTRL-W to jump to another window + + 4. Type :q to close the help window + + 5. Create a vimrc startup script to keep your preferred settings. + + 6. When typing a : command, press CTRL-D to see possible completions. + Press <TAB> to use one completion. + + + + + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/INSTALL b/src/INSTALL index b1aa6a879..0c01ef27d 100644 --- a/src/INSTALL +++ b/src/INSTALL @@ -88,7 +88,7 @@ that "make shadow" creates won't work.] Unix: COMPILING WITH/WITHOUT GUI These configure arguments can be used to select which GUI to use: ---enable-gui= gtk, motif, athena or auto +--enable-gui= gtk, kde, motif, athena or auto --disable-gtk-check --disable-motif-check --disable-athena-check @@ -98,19 +98,19 @@ the order of GTK, Motif, then Athena). If one is found, then is uses it and does not proceed to check any of the remaining ones. Otherwise, it moves on to the next one. ---enable-{gtk,motif,athena}-check all default to "yes", such that if +--enable-{gtk,kde,motif,athena}-check all default to "yes", such that if --enable-gui is "auto" (which it is by default), GTK, Motif, and Athena will be checked for. If you want to *exclude* a certain check, then you use ---disable-{gtk,motif,athena}-check. +--disable-{gtk,kde,motif,athena}-check. For example, if --enable-gui is set to "auto", but you don't want it look for Motif, you then also specify --disable-motif-check. This results in only checking for GTK and Athena. Lastly, if you know which one you want to use, then you can just do ---enable-gui={gtk,motif,athena}. So if you wanted to only use Motif, then +--enable-gui={gtk,kde,motif,athena}. So if you wanted to only use Motif, then you'd specify --enable-gui=motif. Once you specify what you want, the ---enable-{gtk,motif,athena}-check options are ignored. +--enable-{gtk,kde,motif,athena}-check options are ignored. For compiling with the GTK+ GUI, you need a recent version of glib and gtk+. Configure checks for at least version 1.1.16, but below 2.0. An older versions @@ -124,6 +124,9 @@ do not, you may have left-over header files and/or library files from an older auto/config.log for any error messages that may give you a hint as to what's happening. +For KDE see INSTALLkde.txt. + + Unix: COMPILING WITH MULTI-BYTE When you want to compile with the multi-byte features enabled, make sure you diff --git a/src/INSTALLkde.txt b/src/INSTALLkde.txt new file mode 100644 index 000000000..42d4a12c8 --- /dev/null +++ b/src/INSTALLkde.txt @@ -0,0 +1,101 @@ +Vim with KDE: kvim + +ON THE INTERNET +=============== + + The homepage is http://www.freehackers.org/kvim/ + The core is build around the official vim-6.x releases and patches + + KVim CVS is full and does not need extra package. Just download and compile it. + +INSTALL : +========= + We now use Vim's configure to configure, compile and install KVim. + + Don't forget, that you need to have QT and KDE headers and tools installed, otherwise it won't + work ! (these can commonly be found in kde-devel/qt-devel packages) + + Enter the 'src' directory and configure it your way (you need to add at least these flags to the configure command line : --enable-gui=kde --with-qt-dir=$QTDIR ) then make and make install as root. + We added to configure some options for KDE / QT detection, it will for example, find whether you use KDE 2.x or KDE 3.x automatically. For now, QT is _not_ autodetected. I hope to fix this soon. + From KVim 6.1, you can now use a KDE toolbar instead of Vim's Toolbar, to enable it, use the --enable-kde-toolbar configure flag. + + +=> If it fails : (yes it still can, the configure script i wrote is still experimental and probably not +perfect ;p) + or 'how to make a bug report' : + + In some cases, I can imagine it will fail, if this happens then send to marchand@kde.org : + ->auto/config.mk (important one) + ->your configure command line with your options + ->your paths : where KDE is (which version ?), where QT is (version ?), and find where your + libs are (your kdelibs, your QT libs and QT headers) + ->the output of 'kde-config --version' + ->your OS / Linux Distribution version + ->in case of a compilation error : the full error output. + ->the compiler used (gcc 2.95, 2.96, 3.1 ...) + ->any stuff you think could be usefull to me :) + + Thanks for giving KVim a try, we hope you'll enjoy it ! + + +DEVELOPMENT STATE AND KNOWN BUGS: +================================= +Most Vim GUI features are now implemented, only multibyte support is incomplete. +We are working on this and this is our primary goal after KVim 6.1 release. +We hope to get it to work before we include KVim into the core Vim which we want to +do before the end of the year 2002 if possible. + +We would be happy to hear from you if you've tried kvim. Tell us +what is missing, what you like and don't like, and what you want. + +As people have wished it for a while, Philippe developped a component for Vim. +The component is now fully usable with GVim and KVim and can be found on KDE's CVS +in the kdeextragear-1 module. + +SOURCE ACCESS: +============== +Releases and maybe snapshots are/will be found on http://freehackers.org/kvim/ +The CVS is CVSROOT=:pserver:anonymous@cvs.tuxfamily.org:/cvsroot/kvim +(with no password) +You'll find there a full vim 6.x package (with runtime files included). + +MAILING LIST: +============= +As we released KVim 6.0, we created a public mailing list, for feedback, +user help and development related discussions : "kvim-dev@freenux.org", + to subscribe send a mail to "kvim-dev-subscribe@freenux.org" with +"subscribe" as the subject and just reply to the mail you will receive. +(sorry the admin messages are in french, but the list discussions are in +english) + +THANKS : +======== +To all the guys on #kde@opn (Neil, Malte and many other) and to all the people who +tried, debugged, compiled and recompiled again KVim to bring now a much more robust KVim +and of course to all of you who send patchs and comments :) +And of course to Vim Authors :) + +CURRENT MAINTAINER: +=================== + Mickael Marchand <marchand@kde.org> + +DEVELOPERS (CVS accounts): +========== + Mickael Marchand <marchand@kde.org> (marchand) + Mark Westcott <mark@houseoffish.org> Qtopia GUI (mark) + Thomas Capricelli <orzel@kde.org> Initial KVim author (orzel) + Philippe Fremy <pfremy@chez.com> Initial KVim author (pfremy) + +AUTHORS +========= + Thomas Capricelli <orzel@kde.org> Initial KVim author + Philippe Fremy <pfremy@chez.com> Initial KVim author + +CONTRIBUTORS +============ + David Spencer Tyree <celer@scrypt.net> + Vince Negri <vince@bulbous.freeserve.co.uk> AntiAliasing support + Kailash Sethuraman (hsaliak, #netbsd@opn) NetBSD configuration/compilation fixes + Some other, see the About KVim dialog box in KVim... + + diff --git a/src/Makefile b/src/Makefile index d59f32abe..7e4c385b0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -336,6 +336,7 @@ CClink = $(CC) # use it (e.g., want a GTK-only version), then use --enable-gui=gtk. # # If the selected GUI isn't found, the GUI is disabled automatically +#CONF_OPT_GUI = --enable-gui=kde #CONF_OPT_GUI = --enable-gui=gtk #CONF_OPT_GUI = --enable-gui=gtk --disable-gtktest #CONF_OPT_GUI = --enable-gui=gtk2 @@ -1041,6 +1042,35 @@ LINKIT = @echo >/dev/null # Without a GUI install the normal way. NONE_INSTALL = install_normal +### KDE GUI interface. +KDE_DIR = $(KDE_PREFIX) +KDE_INCL = gui.h +KDE_SRC = gui.c pty.c gui_kde.cc gui_kde_x11.cc gui_kde_widget.cc gui_kde_widget_moc.cc kvim_iface_skel.cc +KDE_OBJ = objects/gui.o objects/pty.o objects/gui_kde.o objects/gui_kde_x11.o \ + objects/gui_kde_widget.o objects/gui_kde_widget_moc.o \ + objects/kvim_iface_skel.o +KDE_DEFS = -DFEAT_GUI_KDE $(NARROW_PROTO) +KDE_IPATH = $(GUI_INC_LOC) +KDE_LIBS_DIR = $(GUI_LIB_LOC) +KDE_LIBS1 = +KDE_LIBS2 = $(KDE_LIBNAME) +KDE_INSTALL = install_normal +KDE_TARGETS = installklinks installkdeicons +KDE_MAN_TARGETS = +KDE_TESTTARGET = gui + +#for KDE rename files to avoid confusion with gvim for GTK +KVIMNAME = k$(VIMNAME) +KVIMTARGET = $(KVIMNAME)$(LNKEXT) +KVIEWNAME = k$(VIEWNAME) +KVIEWTARGET = $(KVIEWNAME)$(LNKEXT) +RKVIMNAME = r$(KVIMNAME) +RKVIMTARGET = $(RKVIMNAME)$(LNKEXT) +RKVIEWNAME = r$(KVIEWNAME) +RKVIEWTARGET = $(RKVIEWNAME)$(LNKEXT) +KVIMDIFFNAME = k$(VIMDIFFNAME) +KVIMDIFFTARGET = $(KVIMDIFFNAME)$(LNKEXT) + ### GTK GUI GTK_SRC = gui.c gui_gtk.c gui_gtk_x11.c pty.c gui_gtk_f.c \ gui_beval.c @@ -1170,8 +1200,8 @@ CARBONGUI_MAN_TARGETS = CARBONGUI_TESTTARGET = # All GUI files -ALL_GUI_SRC = gui.c gui_gtk.c gui_gtk_f.c gui_motif.c gui_athena.c gui_gtk_x11.c gui_x11.c gui_at_sb.c gui_at_fs.c pty.c -ALL_GUI_PRO = gui.pro gui_gtk.pro gui_motif.pro gui_athena.pro gui_gtk_x11.pro gui_x11.pro gui_w16.pro gui_w32.pro gui_amiga.pro gui_photon.pro +ALL_GUI_SRC = gui.c gui_gtk.c gui_gtk_f.c gui_motif.c gui_athena.c gui_gtk_x11.c gui_x11.c gui_at_sb.c gui_at_fs.c pty.c gui_kde.cc gui_kde_widget.cc gui_kde_x11.cc gui_kde_widget_moc.cc +ALL_GUI_PRO = gui.pro gui_gtk.pro gui_motif.pro gui_athena.pro gui_gtk_x11.pro gui_x11.pro gui_w16.pro gui_w32.pro gui_amiga.pro gui_photon.pro gui_kde.pro gui_kde_x11.pro # }}} @@ -1307,7 +1337,7 @@ BASIC_SRC = \ SRC = $(BASIC_SRC) $(GUI_SRC) $(HANGULIN_SRC) $(PERL_SRC) $(PYTHON_SRC) \ $(TCL_SRC) $(RUBY_SRC) $(SNIFF_SRC) $(WORKSHOP_SRC) $(WSDEBUG_SRC) -TAGS_SRC = *.c *.cpp if_perl.xs +TAGS_SRC = *.c *.cpp *.cc if_perl.xs EXTRA_SRC = hangulin.c auto/if_perl.c if_perlsfio.c if_python.c if_tcl.c \ if_ruby.c if_sniff.c gui_beval.c \ @@ -1800,6 +1830,23 @@ install-languages: languages $(DEST_LANG) $(DEST_KMAP) fi # install the icons for KDE, if the directory exists and the icon doesn't. +# doesn't.<=looks strange to install icons to user's directory ;), i add my +# own install procedure, mikmak +installkdeicons: + mkdir -p $(DESTDIR)$(KDE_DIR)/share/applnk/Editors/ + mkdir -p $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/32x32/apps/ + mkdir -p $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/48x48/apps/ + mkdir -p $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/22x22/actions/ + mkdir -p $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/16x16/actions/ + mkdir -p $(DESTDIR)$(KDE_DIR)/share/apps/kvim + + cp ../runtime/KVim.desktop $(DESTDIR)$(KDE_DIR)/share/applnk/Editors/ && chmod 644 $(DESTDIR)$(KDE_DIR)/share/applnk/Editors/KVim.desktop + cp ../runtime/kvim32x32.png $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/32x32/apps/kvim.png && chmod 644 $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/32x32/apps/kvim.png + cp ../runtime/kvim48x48.png $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/48x48/apps/kvim.png && chmod 644 $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/48x48/apps/kvim.png + cp ../runtime/hi16-action-make.png $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/16x16/actions/hi16-action-make.png + cp ../runtime/hi22-action-make.png $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/22x22/actions/hi22-action-make.png + cp ../runtime/kde-tips $(DESTDIR)$(KDE_DIR)/share/apps/kvim/tips && chmod 644 $(DESTDIR)$(KDE_DIR)/share/apps/kvim/tips + ICON48PATH = $(DESTDIR)$(DATADIR)/icons/hicolor/48x48/apps ICON32PATH = $(DESTDIR)$(DATADIR)/icons/locolor/32x32/apps ICON16PATH = $(DESTDIR)$(DATADIR)/icons/locolor/16x16/apps @@ -1848,8 +1895,17 @@ installglinks: $(DEST_BIN)/$(GVIMTARGET) \ $(DEST_BIN)/$(EVIEWTARGET) \ $(INSTALLGVIMDIFF) +installklinks: $(DEST_BIN)/$(KVIMTARGET) \ + $(DEST_BIN)/$(KVIEWTARGET) \ + $(DEST_BIN)/$(RKVIMTARGET) \ + $(DEST_BIN)/$(RKVIEWTARGET) \ + $(DEST_BIN)/$(EVIMTARGET) \ + $(DEST_BIN)/$(EVIEWTARGET) \ + installkvimdiff + installvimdiff: $(DEST_BIN)/$(VIMDIFFTARGET) installgvimdiff: $(DEST_BIN)/$(GVIMDIFFTARGET) +installkvimdiff: $(DEST_BIN)/$(KVIMDIFFTARGET) $(DEST_BIN)/$(EXTARGET): cd $(DEST_BIN); ln -s $(VIMTARGET) $(EXTARGET) @@ -1863,6 +1919,12 @@ $(DEST_BIN)/$(GVIMTARGET): $(DEST_BIN)/$(GVIEWTARGET): cd $(DEST_BIN); ln -s $(VIMTARGET) $(GVIEWTARGET) +$(DEST_BIN)/$(KVIMTARGET): + cd $(DEST_BIN); ln -s $(VIMTARGET) $(KVIMTARGET) + +$(DEST_BIN)/$(KVIEWTARGET): + cd $(DEST_BIN); ln -s $(VIMTARGET) $(KVIEWTARGET) + $(DEST_BIN)/$(RVIMTARGET): cd $(DEST_BIN); ln -s $(VIMTARGET) $(RVIMTARGET) @@ -1875,12 +1937,21 @@ $(DEST_BIN)/$(RGVIMTARGET): $(DEST_BIN)/$(RGVIEWTARGET): cd $(DEST_BIN); ln -s $(VIMTARGET) $(RGVIEWTARGET) +$(DEST_BIN)/$(RKVIMTARGET): + cd $(DEST_BIN); ln -s $(VIMTARGET) $(RKVIMTARGET) + +$(DEST_BIN)/$(RKVIEWTARGET): + cd $(DEST_BIN); ln -s $(VIMTARGET) $(RKVIEWTARGET) + $(DEST_BIN)/$(VIMDIFFTARGET): cd $(DEST_BIN); ln -s $(VIMTARGET) $(VIMDIFFTARGET) $(DEST_BIN)/$(GVIMDIFFTARGET): cd $(DEST_BIN); ln -s $(VIMTARGET) $(GVIMDIFFTARGET) +$(DEST_BIN)/$(KVIMDIFFTARGET): + cd $(DEST_BIN); ln -s $(VIMTARGET) $(KVIMDIFFTARGET) + $(DEST_BIN)/$(EVIMTARGET): cd $(DEST_BIN); ln -s $(VIMTARGET) $(EVIMTARGET) @@ -1895,7 +1966,7 @@ installhelplinks: $(GUI_MAN_TARGETS) \ $(DEST_MAN)/$(RVIMNAME).1 \ $(DEST_MAN)/$(RVIEWNAME).1 -installghelplinks: $(DEST_MAN)/$(GVIMNAME).1 \ +installghelplinks installkhelplinks : $(DEST_MAN)/$(GVIMNAME).1 \ $(DEST_MAN)/$(GVIEWNAME).1 \ $(DEST_MAN)/$(RGVIMNAME).1 \ $(DEST_MAN)/$(RGVIEWNAME).1 \ @@ -1939,9 +2010,12 @@ uninstall: uninstall_runtime -rm -f $(DEST_BIN)/xxd$(EXEEXT) $(DEST_MAN)/xxd.1 -rm -f $(DEST_BIN)/$(EXTARGET) $(DEST_BIN)/$(VIEWTARGET) -rm -f $(DEST_BIN)/$(GVIMTARGET) $(DEST_BIN)/$(GVIEWTARGET) + -rm -f $(DEST_BIN)/$(KVIMTARGET) $(DEST_BIN)/$(KVIEWTARGET) -rm -f $(DEST_BIN)/$(RVIMTARGET) $(DEST_BIN)/$(RVIEWTARGET) -rm -f $(DEST_BIN)/$(RGVIMTARGET) $(DEST_BIN)/$(RGVIEWTARGET) + -rm -f $(DEST_BIN)/$(RKVIMTARGET) $(DEST_BIN)/$(RKVIEWTARGET) -rm -f $(DEST_BIN)/$(VIMDIFFTARGET) $(DEST_BIN)/$(GVIMDIFFTARGET) + -rm -f $(DEST_BIN)/$(VIMDIFFTARGET) $(DEST_BIN)/$(KVIMDIFFTARGET) -rm -f $(DEST_BIN)/$(EVIMTARGET) $(DEST_BIN)/$(EVIEWTARGET) -rm -f $(DEST_MAN)/$(EXNAME).1 $(DEST_MAN)/$(VIEWNAME).1 -rm -f $(DEST_MAN)/$(GVIMNAME).1 $(DEST_MAN)/$(GVIEWNAME).1 @@ -1984,6 +2058,7 @@ clean celan: testclean -rm -f *.o objects/* core $(VIMTARGET).core $(VIMTARGET) xxd/*.o -rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c -rm -f conftest* *~ auto/link.sed + -rm -f gui_kde_widget_moc.cc kvim_iface_skel.cc *.kidl if test -d $(PODIR); then \ cd $(PODIR); $(MAKE) prefix=$(DESTDIR)$(prefix) clean; \ fi @@ -2326,6 +2401,24 @@ objects/workshop.o: workshop.c objects/wsdebug.o: wsdebug.c $(CCC) -o $@ wsdebug.c +objects/gui_kde.o: gui_kde.cc + $(CCC) -o $@ gui_kde.cc + +objects/gui_kde_x11.o: gui_kde_x11.cc + $(CCC) -o $@ gui_kde_x11.cc + +objects/gui_kde_widget.o: gui_kde_widget.cc + $(MOC) -o gui_kde_widget_moc.cc gui_kde_widget.h + $(KDE_DIR)/bin/dcopidl kvim_iface.h > kvim_iface.kidl || ( rm -f kvim_iface.kidl ; /bin/false ) + $(KDE_DIR)/bin/dcopidl2cpp --c++-suffix cc --no-stub kvim_iface.kidl + $(CCC) -o $@ gui_kde_widget.cc + +objects/gui_kde_widget_moc.o: gui_kde_widget_moc.cc + $(CCC) -o $@ gui_kde_widget_moc.cc + +objects/kvim_iface_skel.o: kvim_iface_skel.cc + $(CCC) -o $@ kvim_iface_skel.cc + objects/netbeans.o: netbeans.c $(CCC) -o $@ netbeans.c @@ -2637,6 +2730,24 @@ objects/pty.o: pty.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \ ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \ proto/gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \ arabic.h +objects/gui_kde.o: gui_kde.cc gui_kde_widget.h kvim_iface.h vim.h \ + auto/config.h feature.h os_unix.h auto/osdef.h ascii.h keymap.h \ + term.h macros.h structs.h regexp.h gui.h option.h ex_cmds.h proto.h \ + globals.h farsi.h +objects/gui_kde_widget.o: gui_kde_widget.cc gui_kde_widget.h kvim_iface.h \ + vim.h auto/config.h feature.h os_unix.h auto/osdef.h ascii.h keymap.h \ + term.h macros.h structs.h regexp.h gui.h option.h ex_cmds.h proto.h \ + globals.h farsi.h proto/../../pixmaps/alert.xpm proto/../../pixmaps/error.xpm \ + proto/../../pixmaps/generic.xpm proto/../../pixmaps/info.xpm \ + proto/../../pixmaps/quest.xpm +objects/gui_kde_x11.o: gui_kde_x11.cc gui_kde_widget.h kvim_iface.h vim.h \ + auto/config.h feature.h os_unix.h auto/osdef.h ascii.h keymap.h \ + term.h macros.h structs.h regexp.h gui.h option.h ex_cmds.h proto.h \ + globals.h farsi.h version.h ../runtime/vim32x32.xpm +objects/gui_kde_widget_moc.o: gui_kde_widget_moc.cc gui_kde_widget.h \ + kvim_iface.h vim.h auto/config.h feature.h os_unix.h auto/osdef.h \ + ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h option.h \ + ex_cmds.h proto.h globals.h objects/hangulin.o: hangulin.c vim.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h term.h macros.h structs.h regexp.h \ gui.h gui_beval.h proto/gui_beval.pro option.h ex_cmds.h proto.h \ diff --git a/src/auto/configure b/src/auto/configure index b040a75f5..e9e5637f2 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -62,7 +62,9 @@ ac_help="$ac_help ac_help="$ac_help --with-x use the X Window System" ac_help="$ac_help - --enable-gui[=OPTS] X11 GUI [default=auto] [OPTS=auto/no/gtk/gtk2/gnome/gnome2/motif/athena/neXtaw/beos/photon/carbon]" + --enable-gui[=OPTS] X11 GUI [default=auto] [OPTS=auto/no/gtk/gtk2/gnome/gnome2/kde/motif/athena/neXtaw/beos/photon/carbon]" +ac_help="$ac_help + --enable-kde-check If auto-select GUI, check for KDE [default=no]" ac_help="$ac_help --enable-gtk-check If auto-select GUI, check for GTK [default=yes]" ac_help="$ac_help @@ -78,6 +80,24 @@ ac_help="$ac_help ac_help="$ac_help --enable-carbon-check If auto-select GUI, check for Carbon [default=yes]" ac_help="$ac_help + --with-qt-dir=DIR Specify prefix of QT files" +ac_help="$ac_help + --with-qt-includes=DIR Specify location of Qt headers" +ac_help="$ac_help + --with-qt-libs=DIR Specify location of Qt libraries" +ac_help="$ac_help + --enable-kde-toolbar if KDE GUI is selected, enable a KDE-look toolbar [default=no]" +ac_help="$ac_help + --disable-rpath Disable rpath." +ac_help="$ac_help + --with-kde-prefix=PFX Prefix where KDE is installed (optional)" +ac_help="$ac_help + --with-kde-includes=DIR Specify location of KDE headers" +ac_help="$ac_help + --with-kde-libs=DIR Specify location of KDE libraries" +ac_help="$ac_help + --disable-kdetest Do not try to compile and run a test KDE program" +ac_help="$ac_help --with-gtk-prefix=PFX Prefix where GTK is installed (optional)" ac_help="$ac_help --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)" @@ -616,7 +636,7 @@ cat >> confdefs.h <<\EOF EOF echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:620: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:640: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -646,7 +666,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:650: checking for $ac_word" >&5 +echo "configure:670: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -676,7 +696,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:680: checking for $ac_word" >&5 +echo "configure:700: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -727,7 +747,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:731: checking for $ac_word" >&5 +echo "configure:751: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -759,7 +779,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:763: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:783: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -770,12 +790,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 774 "configure" +#line 794 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -801,12 +821,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:805: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:825: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:810: checking whether we are using GNU C" >&5 +echo "configure:830: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -815,7 +835,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:819: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:839: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -834,7 +854,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:838: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:858: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -865,7 +885,7 @@ else fi fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:869: checking how to run the C preprocessor" >&5 +echo "configure:889: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -880,13 +900,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext <<EOF -#line 884 "configure" +#line 904 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:890: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:910: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -897,13 +917,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext <<EOF -#line 901 "configure" +#line 921 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:907: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:927: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -914,13 +934,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext <<EOF -#line 918 "configure" +#line 938 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:924: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:944: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -944,7 +964,7 @@ else fi echo "$ac_t""$CPP" 1>&6 cat > conftest.$ac_ext <<EOF -#line 948 "configure" +#line 968 "configure" #include "confdefs.h" EOF @@ -954,7 +974,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | fi rm -f conftest* echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 -echo "configure:958: checking for POSIXized ISC" >&5 +echo "configure:978: checking for POSIXized ISC" >&5 if test -d /etc/conf/kconfig.d && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 then @@ -978,7 +998,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:982: checking for $ac_word" >&5 +echo "configure:1002: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1010,7 +1030,7 @@ done # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1014: checking for $ac_word" >&5 +echo "configure:1034: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1039,12 +1059,12 @@ fi echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:1043: checking for Cygwin environment" >&5 +echo "configure:1063: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1048 "configure" +#line 1068 "configure" #include "confdefs.h" int main() { @@ -1055,7 +1075,7 @@ int main() { return __CYGWIN__; ; return 0; } EOF -if { (eval echo configure:1059: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1079: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -1072,19 +1092,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:1076: checking for mingw32 environment" >&5 +echo "configure:1096: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1081 "configure" +#line 1101 "configure" #include "confdefs.h" int main() { return __MINGW32__; ; return 0; } EOF -if { (eval echo configure:1088: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1108: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -1103,7 +1123,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=yes echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1107: checking for executable suffix" >&5 +echo "configure:1127: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1113,7 +1133,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:1117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1137: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj) ;; @@ -1160,14 +1180,14 @@ test "$GCC" = yes && CPP_MM=M; if test -f ./toolcheck; then echo "checking for buggy tools" 1>&6 -echo "configure:1164: checking for buggy tools" >&5 +echo "configure:1184: checking for buggy tools" >&5 sh ./toolcheck 1>&6 fi OS_EXTRA_SRC=""; OS_EXTRA_OBJ="" echo $ac_n "checking for BeOS""... $ac_c" 1>&6 -echo "configure:1171: checking for BeOS" >&5 +echo "configure:1191: checking for BeOS" >&5 case `uname` in BeOS) OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o BEOS=yes; echo "$ac_t""yes" 1>&6;; @@ -1175,7 +1195,7 @@ case `uname` in esac echo $ac_n "checking for QNX""... $ac_c" 1>&6 -echo "configure:1179: checking for QNX" >&5 +echo "configure:1199: checking for QNX" >&5 case `uname` in QNX) OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o test -z "$with_x" && with_x=no @@ -1185,12 +1205,12 @@ esac DEFAULT_VIMNAME=vim echo $ac_n "checking for Darwin (Mac OS X)""... $ac_c" 1>&6 -echo "configure:1189: checking for Darwin (Mac OS X)" >&5 +echo "configure:1209: checking for Darwin (Mac OS X)" >&5 if test "`(uname) 2>/dev/null`" = Darwin; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking --disable-darwin argument""... $ac_c" 1>&6 -echo "configure:1194: checking --disable-darwin argument" >&5 +echo "configure:1214: checking --disable-darwin argument" >&5 # Check whether --enable-darwin or --disable-darwin was given. if test "${enable_darwin+set}" = set; then enableval="$enable_darwin" @@ -1202,7 +1222,7 @@ fi if test "$enable_darwin" = "yes"; then echo "$ac_t""no" 1>&6 echo $ac_n "checking if Darwin files are there""... $ac_c" 1>&6 -echo "configure:1206: checking if Darwin files are there" >&5 +echo "configure:1226: checking if Darwin files are there" >&5 if test -f os_macosx.c; then echo "$ac_t""yes" 1>&6 else @@ -1221,17 +1241,17 @@ echo "configure:1206: checking if Darwin files are there" >&5 ac_safe=`echo "Carbon/Carbon.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for Carbon/Carbon.h""... $ac_c" 1>&6 -echo "configure:1225: checking for Carbon/Carbon.h" >&5 +echo "configure:1245: checking for Carbon/Carbon.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1230 "configure" +#line 1250 "configure" #include "confdefs.h" #include <Carbon/Carbon.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1235: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1255: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1288,7 +1308,7 @@ if test -z "$have_local_include" -a -d /usr/local/include; then fi echo $ac_n "checking --with-vim-name argument""... $ac_c" 1>&6 -echo "configure:1292: checking --with-vim-name argument" >&5 +echo "configure:1312: checking --with-vim-name argument" >&5 # Check whether --with-vim-name or --without-vim-name was given. if test "${with_vim_name+set}" = set; then withval="$with_vim_name" @@ -1299,7 +1319,7 @@ fi echo $ac_n "checking --with-ex-name argument""... $ac_c" 1>&6 -echo "configure:1303: checking --with-ex-name argument" >&5 +echo "configure:1323: checking --with-ex-name argument" >&5 # Check whether --with-ex-name or --without-ex-name was given. if test "${with_ex_name+set}" = set; then withval="$with_ex_name" @@ -1310,7 +1330,7 @@ fi echo $ac_n "checking --with-view-name argument""... $ac_c" 1>&6 -echo "configure:1314: checking --with-view-name argument" >&5 +echo "configure:1334: checking --with-view-name argument" >&5 # Check whether --with-view-name or --without-view-name was given. if test "${with_view_name+set}" = set; then withval="$with_view_name" @@ -1322,7 +1342,7 @@ fi echo $ac_n "checking --with-global-runtime argument""... $ac_c" 1>&6 -echo "configure:1326: checking --with-global-runtime argument" >&5 +echo "configure:1346: checking --with-global-runtime argument" >&5 # Check whether --with-global-runtime or --without-global-runtime was given. if test "${with_global_runtime+set}" = set; then withval="$with_global_runtime" @@ -1336,7 +1356,7 @@ fi echo $ac_n "checking --with-modified-by argument""... $ac_c" 1>&6 -echo "configure:1340: checking --with-modified-by argument" >&5 +echo "configure:1360: checking --with-modified-by argument" >&5 # Check whether --with-modified-by or --without-modified-by was given. if test "${with_modified_by+set}" = set; then withval="$with_modified_by" @@ -1350,9 +1370,9 @@ fi echo $ac_n "checking if character set is EBCDIC""... $ac_c" 1>&6 -echo "configure:1354: checking if character set is EBCDIC" >&5 +echo "configure:1374: checking if character set is EBCDIC" >&5 cat > conftest.$ac_ext <<EOF -#line 1356 "configure" +#line 1376 "configure" #include "confdefs.h" int main() { @@ -1365,7 +1385,7 @@ make an error "Character set is not EBCDIC" #endif ; return 0; } EOF -if { (eval echo configure:1369: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1389: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # TryCompile action if true cf_cv_ebcdic=yes @@ -1393,7 +1413,7 @@ esac if test "$cf_cv_ebcdic" = "yes"; then echo $ac_n "checking for OS/390 Unix""... $ac_c" 1>&6 -echo "configure:1397: checking for OS/390 Unix" >&5 +echo "configure:1417: checking for OS/390 Unix" >&5 case `uname` in OS/390) OS390Unix="yes"; if test "$CC" = "cc"; then @@ -1430,7 +1450,7 @@ fi echo $ac_n "checking --with-features argument""... $ac_c" 1>&6 -echo "configure:1434: checking --with-features argument" >&5 +echo "configure:1454: checking --with-features argument" >&5 # Check whether --with-features or --without-features was given. if test "${with_features+set}" = set; then withval="$with_features" @@ -1473,7 +1493,7 @@ esac echo $ac_n "checking --with-compiledby argument""... $ac_c" 1>&6 -echo "configure:1477: checking --with-compiledby argument" >&5 +echo "configure:1497: checking --with-compiledby argument" >&5 # Check whether --with-compiledby or --without-compiledby was given. if test "${with_compiledby+set}" = set; then withval="$with_compiledby" @@ -1485,7 +1505,7 @@ fi echo $ac_n "checking --disable-xsmp argument""... $ac_c" 1>&6 -echo "configure:1489: checking --disable-xsmp argument" >&5 +echo "configure:1509: checking --disable-xsmp argument" >&5 # Check whether --enable-xsmp or --disable-xsmp was given. if test "${enable_xsmp+set}" = set; then enableval="$enable_xsmp" @@ -1498,7 +1518,7 @@ fi if test "$enable_xsmp" = "yes"; then echo "$ac_t""no" 1>&6 echo $ac_n "checking --disable-xsmp-interact argument""... $ac_c" 1>&6 -echo "configure:1502: checking --disable-xsmp-interact argument" >&5 +echo "configure:1522: checking --disable-xsmp-interact argument" >&5 # Check whether --enable-xsmp-interact or --disable-xsmp-interact was given. if test "${enable_xsmp_interact+set}" = set; then enableval="$enable_xsmp_interact" @@ -1521,7 +1541,7 @@ else fi echo $ac_n "checking --enable-perlinterp argument""... $ac_c" 1>&6 -echo "configure:1525: checking --enable-perlinterp argument" >&5 +echo "configure:1545: checking --enable-perlinterp argument" >&5 # Check whether --enable-perlinterp or --disable-perlinterp was given. if test "${enable_perlinterp+set}" = set; then enableval="$enable_perlinterp" @@ -1536,7 +1556,7 @@ if test "$enable_perlinterp" = "yes"; then # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1540: checking for $ac_word" >&5 +echo "configure:1560: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_perl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1570,7 +1590,7 @@ fi if test "X$vi_cv_path_perl" != "X"; then echo $ac_n "checking Perl version""... $ac_c" 1>&6 -echo "configure:1574: checking Perl version" >&5 +echo "configure:1594: checking Perl version" >&5 if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then eval `$vi_cv_path_perl -V:usethreads` if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then @@ -1606,7 +1626,7 @@ echo "configure:1574: checking Perl version" >&5 -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'` echo $ac_n "checking if compile and link flags for Perl are sane""... $ac_c" 1>&6 -echo "configure:1610: checking if compile and link flags for Perl are sane" >&5 +echo "configure:1630: checking if compile and link flags for Perl are sane" >&5 cflags_save=$CFLAGS libs_save=$LIBS ldflags_save=$LDFLAGS @@ -1614,14 +1634,14 @@ echo "configure:1610: checking if compile and link flags for Perl are sane" >&5 LIBS="$LIBS $perllibs" LDFLAGS="$perlldflags $LDFLAGS" cat > conftest.$ac_ext <<EOF -#line 1618 "configure" +#line 1638 "configure" #include "confdefs.h" int main() { ; return 0; } EOF -if { (eval echo configure:1625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; perl_ok=yes else @@ -1684,7 +1704,7 @@ fi echo $ac_n "checking --enable-pythoninterp argument""... $ac_c" 1>&6 -echo "configure:1688: checking --enable-pythoninterp argument" >&5 +echo "configure:1708: checking --enable-pythoninterp argument" >&5 # Check whether --enable-pythoninterp or --disable-pythoninterp was given. if test "${enable_pythoninterp+set}" = set; then enableval="$enable_pythoninterp" @@ -1698,7 +1718,7 @@ if test "$enable_pythoninterp" = "yes"; then # Extract the first word of "python", so it can be a program name with args. set dummy python; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1702: checking for $ac_word" >&5 +echo "configure:1722: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_python'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1733,7 +1753,7 @@ fi if test "X$vi_cv_path_python" != "X"; then echo $ac_n "checking Python version""... $ac_c" 1>&6 -echo "configure:1737: checking Python version" >&5 +echo "configure:1757: checking Python version" >&5 if eval "test \"`echo '$''{'vi_cv_var_python_version'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1745,14 +1765,14 @@ fi echo "$ac_t""$vi_cv_var_python_version" 1>&6 echo $ac_n "checking Python is 1.4 or better""... $ac_c" 1>&6 -echo "configure:1749: checking Python is 1.4 or better" >&5 +echo "configure:1769: checking Python is 1.4 or better" >&5 if ${vi_cv_path_python} -c \ "import sys; sys.exit(${vi_cv_var_python_version} < 1.4)" then echo "$ac_t""yep" 1>&6 echo $ac_n "checking Python's install prefix""... $ac_c" 1>&6 -echo "configure:1756: checking Python's install prefix" >&5 +echo "configure:1776: checking Python's install prefix" >&5 if eval "test \"`echo '$''{'vi_cv_path_python_pfx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1764,7 +1784,7 @@ fi echo "$ac_t""$vi_cv_path_python_pfx" 1>&6 echo $ac_n "checking Python's execution prefix""... $ac_c" 1>&6 -echo "configure:1768: checking Python's execution prefix" >&5 +echo "configure:1788: checking Python's execution prefix" >&5 if eval "test \"`echo '$''{'vi_cv_path_python_epfx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1795,7 +1815,7 @@ fi echo $ac_n "checking Python's configuration directory""... $ac_c" 1>&6 -echo "configure:1799: checking Python's configuration directory" >&5 +echo "configure:1819: checking Python's configuration directory" >&5 if eval "test \"`echo '$''{'vi_cv_path_python_conf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1868,7 +1888,7 @@ fi PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'" echo $ac_n "checking if -pthread should be used""... $ac_c" 1>&6 -echo "configure:1872: checking if -pthread should be used" >&5 +echo "configure:1892: checking if -pthread should be used" >&5 threadsafe_flag= thread_lib= if test "x$MACOSX" != "xyes"; then @@ -1884,14 +1904,14 @@ echo "configure:1872: checking if -pthread should be used" >&5 CFLAGS="$CFLAGS $threadsafe_flag" LIBS="$LIBS $thread_lib" cat > conftest.$ac_ext <<EOF -#line 1888 "configure" +#line 1908 "configure" #include "confdefs.h" int main() { ; return 0; } EOF -if { (eval echo configure:1895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1915: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag" else @@ -1908,20 +1928,20 @@ rm -f conftest* fi echo $ac_n "checking if compile and link flags for Python are sane""... $ac_c" 1>&6 -echo "configure:1912: checking if compile and link flags for Python are sane" >&5 +echo "configure:1932: checking if compile and link flags for Python are sane" >&5 cflags_save=$CFLAGS libs_save=$LIBS CFLAGS="$CFLAGS $PYTHON_CFLAGS" LIBS="$LIBS $PYTHON_LIBS" cat > conftest.$ac_ext <<EOF -#line 1918 "configure" +#line 1938 "configure" #include "confdefs.h" int main() { ; return 0; } EOF -if { (eval echo configure:1925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; python_ok=yes else @@ -1960,7 +1980,7 @@ fi echo $ac_n "checking --enable-tclinterp argument""... $ac_c" 1>&6 -echo "configure:1964: checking --enable-tclinterp argument" >&5 +echo "configure:1984: checking --enable-tclinterp argument" >&5 # Check whether --enable-tclinterp or --disable-tclinterp was given. if test "${enable_tclinterp+set}" = set; then enableval="$enable_tclinterp" @@ -1974,7 +1994,7 @@ echo "$ac_t""$enable_tclinterp" 1>&6 if test "$enable_tclinterp" = "yes"; then echo $ac_n "checking --with-tclsh argument""... $ac_c" 1>&6 -echo "configure:1978: checking --with-tclsh argument" >&5 +echo "configure:1998: checking --with-tclsh argument" >&5 # Check whether --with-tclsh or --without-tclsh was given. if test "${with_tclsh+set}" = set; then withval="$with_tclsh" @@ -1986,7 +2006,7 @@ fi # Extract the first word of "$tclsh_name", so it can be a program name with args. set dummy $tclsh_name; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1990: checking for $ac_word" >&5 +echo "configure:2010: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_tcl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2025,7 +2045,7 @@ fi # Extract the first word of "$tclsh_name", so it can be a program name with args. set dummy $tclsh_name; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2029: checking for $ac_word" >&5 +echo "configure:2049: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_tcl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2063,7 +2083,7 @@ fi # Extract the first word of "$tclsh_name", so it can be a program name with args. set dummy $tclsh_name; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2067: checking for $ac_word" >&5 +echo "configure:2087: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_tcl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2098,14 +2118,14 @@ fi fi if test "X$vi_cv_path_tcl" != "X"; then echo $ac_n "checking Tcl version""... $ac_c" 1>&6 -echo "configure:2102: checking Tcl version" >&5 +echo "configure:2122: checking Tcl version" >&5 if echo 'exit [expr [info tclversion] < 8.0]' | $vi_cv_path_tcl - ; then tclver=`echo 'puts [info tclversion]' | $vi_cv_path_tcl -` echo "$ac_t""$tclver - OK" 1>&6; tclloc=`echo 'set l [info library];set i [string last lib $l];incr i -2;puts [string range $l 0 $i]' | $vi_cv_path_tcl -` echo $ac_n "checking for location of Tcl include""... $ac_c" 1>&6 -echo "configure:2109: checking for location of Tcl include" >&5 +echo "configure:2129: checking for location of Tcl include" >&5 if test "x$MACOSX" != "xyes"; then tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /usr/local/include" else @@ -2124,7 +2144,7 @@ echo "configure:2109: checking for location of Tcl include" >&5 fi if test -z "$SKIP_TCL"; then echo $ac_n "checking for location of tclConfig.sh script""... $ac_c" 1>&6 -echo "configure:2128: checking for location of tclConfig.sh script" >&5 +echo "configure:2148: checking for location of tclConfig.sh script" >&5 if test "x$MACOSX" != "xyes"; then tclcnf=`echo $tclinc | sed s/include/lib/g` else @@ -2142,7 +2162,7 @@ echo "configure:2128: checking for location of tclConfig.sh script" >&5 if test -z "$TCL_LIBS"; then echo "$ac_t""<not found>" 1>&6 echo $ac_n "checking for Tcl library by myself""... $ac_c" 1>&6 -echo "configure:2146: checking for Tcl library by myself" >&5 +echo "configure:2166: checking for Tcl library by myself" >&5 tcllib=`echo $tclinc | sed s/include/lib/g` for ext in .so .a ; do for ver in "" $tclver ; do @@ -2188,7 +2208,7 @@ fi echo $ac_n "checking --enable-rubyinterp argument""... $ac_c" 1>&6 -echo "configure:2192: checking --enable-rubyinterp argument" >&5 +echo "configure:2212: checking --enable-rubyinterp argument" >&5 # Check whether --enable-rubyinterp or --disable-rubyinterp was given. if test "${enable_rubyinterp+set}" = set; then enableval="$enable_rubyinterp" @@ -2203,7 +2223,7 @@ if test "$enable_rubyinterp" = "yes"; then # Extract the first word of "ruby", so it can be a program name with args. set dummy ruby; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2207: checking for $ac_word" >&5 +echo "configure:2227: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_ruby'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2237,11 +2257,11 @@ fi if test "X$vi_cv_path_ruby" != "X"; then echo $ac_n "checking Ruby version""... $ac_c" 1>&6 -echo "configure:2241: checking Ruby version" >&5 +echo "configure:2261: checking Ruby version" >&5 if $vi_cv_path_ruby -e 'VERSION >= "1.6.0" or exit 1' >/dev/null 2>/dev/null; then echo "$ac_t""OK" 1>&6 echo $ac_n "checking Ruby header files""... $ac_c" 1>&6 -echo "configure:2245: checking Ruby header files" >&5 +echo "configure:2265: checking Ruby header files" >&5 rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG["archdir"] || $hdrdir' 2>/dev/null` if test "X$rubyhdrdir" != "X"; then echo "$ac_t""$rubyhdrdir" 1>&6 @@ -2293,7 +2313,7 @@ fi echo $ac_n "checking --enable-cscope argument""... $ac_c" 1>&6 -echo "configure:2297: checking --enable-cscope argument" >&5 +echo "configure:2317: checking --enable-cscope argument" >&5 # Check whether --enable-cscope or --disable-cscope was given. if test "${enable_cscope+set}" = set; then enableval="$enable_cscope" @@ -2311,7 +2331,7 @@ EOF fi echo $ac_n "checking --enable-workshop argument""... $ac_c" 1>&6 -echo "configure:2315: checking --enable-workshop argument" >&5 +echo "configure:2335: checking --enable-workshop argument" >&5 # Check whether --enable-workshop or --disable-workshop was given. if test "${enable_workshop+set}" = set; then enableval="$enable_workshop" @@ -2336,7 +2356,7 @@ EOF fi echo $ac_n "checking --disable-netbeans argument""... $ac_c" 1>&6 -echo "configure:2340: checking --disable-netbeans argument" >&5 +echo "configure:2360: checking --disable-netbeans argument" >&5 # Check whether --enable-netbeans or --disable-netbeans was given. if test "${enable_netbeans+set}" = set; then enableval="$enable_netbeans" @@ -2348,7 +2368,7 @@ fi if test "$enable_netbeans" = "yes"; then echo "$ac_t""no" 1>&6 echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 -echo "configure:2352: checking for socket in -lsocket" >&5 +echo "configure:2372: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2356,7 +2376,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <<EOF -#line 2360 "configure" +#line 2380 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -2367,7 +2387,7 @@ int main() { socket() ; return 0; } EOF -if { (eval echo configure:2371: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2391: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2395,7 +2415,7 @@ else fi echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:2399: checking for gethostbyname in -lnsl" >&5 +echo "configure:2419: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2403,7 +2423,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <<EOF -#line 2407 "configure" +#line 2427 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -2414,7 +2434,7 @@ int main() { gethostbyname() ; return 0; } EOF -if { (eval echo configure:2418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2438: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2442,9 +2462,9 @@ else fi echo $ac_n "checking whether compiling netbeans integration is possible""... $ac_c" 1>&6 -echo "configure:2446: checking whether compiling netbeans integration is possible" >&5 +echo "configure:2466: checking whether compiling netbeans integration is possible" >&5 cat > conftest.$ac_ext <<EOF -#line 2448 "configure" +#line 2468 "configure" #include "confdefs.h" #include <stdio.h> @@ -2474,7 +2494,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2478: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -2499,7 +2519,7 @@ EOF fi echo $ac_n "checking --enable-sniff argument""... $ac_c" 1>&6 -echo "configure:2503: checking --enable-sniff argument" >&5 +echo "configure:2523: checking --enable-sniff argument" >&5 # Check whether --enable-sniff or --disable-sniff was given. if test "${enable_sniff+set}" = set; then enableval="$enable_sniff" @@ -2521,7 +2541,7 @@ EOF fi echo $ac_n "checking --enable-multibyte argument""... $ac_c" 1>&6 -echo "configure:2525: checking --enable-multibyte argument" >&5 +echo "configure:2545: checking --enable-multibyte argument" >&5 # Check whether --enable-multibyte or --disable-multibyte was given. if test "${enable_multibyte+set}" = set; then enableval="$enable_multibyte" @@ -2539,7 +2559,7 @@ EOF fi echo $ac_n "checking --enable-hangulinput argument""... $ac_c" 1>&6 -echo "configure:2543: checking --enable-hangulinput argument" >&5 +echo "configure:2563: checking --enable-hangulinput argument" >&5 # Check whether --enable-hangulinput or --disable-hangulinput was given. if test "${enable_hangulinput+set}" = set; then enableval="$enable_hangulinput" @@ -2551,7 +2571,7 @@ fi echo "$ac_t""$enable_hangulinput" 1>&6 echo $ac_n "checking --enable-xim argument""... $ac_c" 1>&6 -echo "configure:2555: checking --enable-xim argument" >&5 +echo "configure:2575: checking --enable-xim argument" >&5 # Check whether --enable-xim or --disable-xim was given. if test "${enable_xim+set}" = set; then enableval="$enable_xim" @@ -2562,7 +2582,7 @@ fi echo $ac_n "checking --enable-fontset argument""... $ac_c" 1>&6 -echo "configure:2566: checking --enable-fontset argument" >&5 +echo "configure:2586: checking --enable-fontset argument" >&5 # Check whether --enable-fontset or --disable-fontset was given. if test "${enable_fontset+set}" = set; then enableval="$enable_fontset" @@ -2582,7 +2602,7 @@ else # Extract the first word of "xmkmf", so it can be a program name with args. set dummy xmkmf; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2586: checking for $ac_word" >&5 +echo "configure:2606: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_xmkmfpath'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2620,7 +2640,7 @@ fi # Uses ac_ vars as temps to allow command line to override cache and checks. # --without-x overrides everything else, but does not touch the cache. echo $ac_n "checking for X""... $ac_c" 1>&6 -echo "configure:2624: checking for X" >&5 +echo "configure:2644: checking for X" >&5 # Check whether --with-x or --without-x was given. if test "${with_x+set}" = set; then @@ -2682,12 +2702,12 @@ if test "$ac_x_includes" = NO; then # First, try using that file with no special directory specified. cat > conftest.$ac_ext <<EOF -#line 2686 "configure" +#line 2706 "configure" #include "confdefs.h" #include <$x_direct_test_include> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2691: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2711: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2756,14 +2776,14 @@ if test "$ac_x_libraries" = NO; then ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext <<EOF -#line 2760 "configure" +#line 2780 "configure" #include "confdefs.h" int main() { ${x_direct_test_function}() ; return 0; } EOF -if { (eval echo configure:2767: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2787: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* LIBS="$ac_save_LIBS" # We can link X programs with no special library path. @@ -2869,17 +2889,17 @@ else case "`(uname -sr) 2>/dev/null`" in "SunOS 5"*) echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6 -echo "configure:2873: checking whether -R must be followed by a space" >&5 +echo "configure:2893: checking whether -R must be followed by a space" >&5 ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries" cat > conftest.$ac_ext <<EOF -#line 2876 "configure" +#line 2896 "configure" #include "confdefs.h" int main() { ; return 0; } EOF -if { (eval echo configure:2883: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2903: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_R_nospace=yes else @@ -2895,14 +2915,14 @@ rm -f conftest* else LIBS="$ac_xsave_LIBS -R $x_libraries" cat > conftest.$ac_ext <<EOF -#line 2899 "configure" +#line 2919 "configure" #include "confdefs.h" int main() { ; return 0; } EOF -if { (eval echo configure:2906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2926: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_R_space=yes else @@ -2934,7 +2954,7 @@ rm -f conftest* # libraries were built with DECnet support. And karl@cs.umb.edu says # the Alpha needs dnet_stub (dnet does not exist). echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6 -echo "configure:2938: checking for dnet_ntoa in -ldnet" >&5 +echo "configure:2958: checking for dnet_ntoa in -ldnet" >&5 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2942,7 +2962,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldnet $LIBS" cat > conftest.$ac_ext <<EOF -#line 2946 "configure" +#line 2966 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -2953,7 +2973,7 @@ int main() { dnet_ntoa() ; return 0; } EOF -if { (eval echo configure:2957: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2975,7 +2995,7 @@ fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6 -echo "configure:2979: checking for dnet_ntoa in -ldnet_stub" >&5 +echo "configure:2999: checking for dnet_ntoa in -ldnet_stub" >&5 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2983,7 +3003,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldnet_stub $LIBS" cat > conftest.$ac_ext <<EOF -#line 2987 "configure" +#line 3007 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -2994,7 +3014,7 @@ int main() { dnet_ntoa() ; return 0; } EOF -if { (eval echo configure:2998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3018: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3023,12 +3043,12 @@ fi # The nsl library prevents programs from opening the X display # on Irix 5.2, according to dickey@clark.net. echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:3027: checking for gethostbyname" >&5 +echo "configure:3047: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3032 "configure" +#line 3052 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char gethostbyname(); below. */ @@ -3051,7 +3071,7 @@ gethostbyname(); ; return 0; } EOF -if { (eval echo configure:3055: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else @@ -3072,7 +3092,7 @@ fi if test $ac_cv_func_gethostbyname = no; then echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:3076: checking for gethostbyname in -lnsl" >&5 +echo "configure:3096: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3080,7 +3100,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <<EOF -#line 3084 "configure" +#line 3104 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -3091,7 +3111,7 @@ int main() { gethostbyname() ; return 0; } EOF -if { (eval echo configure:3095: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3121,12 +3141,12 @@ fi # -lsocket must be given before -lnsl if both are needed. # We assume that if connect needs -lnsl, so does gethostbyname. echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:3125: checking for connect" >&5 +echo "configure:3145: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3130 "configure" +#line 3150 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char connect(); below. */ @@ -3149,7 +3169,7 @@ connect(); ; return 0; } EOF -if { (eval echo configure:3153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3173: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_connect=yes" else @@ -3170,7 +3190,7 @@ fi if test $ac_cv_func_connect = no; then echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 -echo "configure:3174: checking for connect in -lsocket" >&5 +echo "configure:3194: checking for connect in -lsocket" >&5 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3178,7 +3198,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <<EOF -#line 3182 "configure" +#line 3202 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -3189,7 +3209,7 @@ int main() { connect() ; return 0; } EOF -if { (eval echo configure:3193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3213: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3213,12 +3233,12 @@ fi # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. echo $ac_n "checking for remove""... $ac_c" 1>&6 -echo "configure:3217: checking for remove" >&5 +echo "configure:3237: checking for remove" >&5 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3222 "configure" +#line 3242 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char remove(); below. */ @@ -3241,7 +3261,7 @@ remove(); ; return 0; } EOF -if { (eval echo configure:3245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_remove=yes" else @@ -3262,7 +3282,7 @@ fi if test $ac_cv_func_remove = no; then echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 -echo "configure:3266: checking for remove in -lposix" >&5 +echo "configure:3286: checking for remove in -lposix" >&5 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3270,7 +3290,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lposix $LIBS" cat > conftest.$ac_ext <<EOF -#line 3274 "configure" +#line 3294 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -3281,7 +3301,7 @@ int main() { remove() ; return 0; } EOF -if { (eval echo configure:3285: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3305,12 +3325,12 @@ fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. echo $ac_n "checking for shmat""... $ac_c" 1>&6 -echo "configure:3309: checking for shmat" >&5 +echo "configure:3329: checking for shmat" >&5 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3314 "configure" +#line 3334 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char shmat(); below. */ @@ -3333,7 +3353,7 @@ shmat(); ; return 0; } EOF -if { (eval echo configure:3337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3357: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_shmat=yes" else @@ -3354,7 +3374,7 @@ fi if test $ac_cv_func_shmat = no; then echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 -echo "configure:3358: checking for shmat in -lipc" >&5 +echo "configure:3378: checking for shmat in -lipc" >&5 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3362,7 +3382,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lipc $LIBS" cat > conftest.$ac_ext <<EOF -#line 3366 "configure" +#line 3386 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -3373,7 +3393,7 @@ int main() { shmat() ; return 0; } EOF -if { (eval echo configure:3377: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3406,7 +3426,7 @@ fi # libraries we check for below, so use a different variable. # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 -echo "configure:3410: checking for IceConnectionNumber in -lICE" >&5 +echo "configure:3430: checking for IceConnectionNumber in -lICE" >&5 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3414,7 +3434,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <<EOF -#line 3418 "configure" +#line 3438 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -3425,7 +3445,7 @@ int main() { IceConnectionNumber() ; return 0; } EOF -if { (eval echo configure:3429: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3479,18 +3499,18 @@ fi echo $ac_n "checking if X11 header files can be found""... $ac_c" 1>&6 -echo "configure:3483: checking if X11 header files can be found" >&5 +echo "configure:3503: checking if X11 header files can be found" >&5 cflags_save=$CFLAGS CFLAGS="$CFLAGS $X_CFLAGS" cat > conftest.$ac_ext <<EOF -#line 3487 "configure" +#line 3507 "configure" #include "confdefs.h" #include <X11/Xlib.h> int main() { ; return 0; } EOF -if { (eval echo configure:3494: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3514: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -3516,7 +3536,7 @@ EOF LDFLAGS="-L$x_libraries $LDFLAGS" echo $ac_n "checking for _XdmcpAuthDoIt in -lXdmcp""... $ac_c" 1>&6 -echo "configure:3520: checking for _XdmcpAuthDoIt in -lXdmcp" >&5 +echo "configure:3540: checking for _XdmcpAuthDoIt in -lXdmcp" >&5 ac_lib_var=`echo Xdmcp'_'_XdmcpAuthDoIt | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3524,7 +3544,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lXdmcp -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp $LIBS" cat > conftest.$ac_ext <<EOF -#line 3528 "configure" +#line 3548 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -3535,7 +3555,7 @@ int main() { _XdmcpAuthDoIt() ; return 0; } EOF -if { (eval echo configure:3539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3559: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3557,7 +3577,7 @@ fi echo $ac_n "checking for IceOpenConnection in -lICE""... $ac_c" 1>&6 -echo "configure:3561: checking for IceOpenConnection in -lICE" >&5 +echo "configure:3581: checking for IceOpenConnection in -lICE" >&5 ac_lib_var=`echo ICE'_'IceOpenConnection | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3565,7 +3585,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <<EOF -#line 3569 "configure" +#line 3589 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -3576,7 +3596,7 @@ int main() { IceOpenConnection() ; return 0; } EOF -if { (eval echo configure:3580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3600: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3599,7 +3619,7 @@ fi LDFLAGS="$X_LIBS $ac_save_LDFLAGS" echo $ac_n "checking for XpmCreatePixmapFromData in -lXpm""... $ac_c" 1>&6 -echo "configure:3603: checking for XpmCreatePixmapFromData in -lXpm" >&5 +echo "configure:3623: checking for XpmCreatePixmapFromData in -lXpm" >&5 ac_lib_var=`echo Xpm'_'XpmCreatePixmapFromData | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3607,7 +3627,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lXpm -lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <<EOF -#line 3611 "configure" +#line 3631 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -3618,7 +3638,7 @@ int main() { XpmCreatePixmapFromData() ; return 0; } EOF -if { (eval echo configure:3622: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3640,18 +3660,18 @@ fi echo $ac_n "checking if X11 header files implicitly declare return values""... $ac_c" 1>&6 -echo "configure:3644: checking if X11 header files implicitly declare return values" >&5 +echo "configure:3664: checking if X11 header files implicitly declare return values" >&5 cflags_save=$CFLAGS CFLAGS="$CFLAGS $X_CFLAGS -Werror" cat > conftest.$ac_ext <<EOF -#line 3648 "configure" +#line 3668 "configure" #include "confdefs.h" #include <X11/Xlib.h> int main() { ; return 0; } EOF -if { (eval echo configure:3655: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3675: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""no" 1>&6 else @@ -3660,14 +3680,14 @@ else rm -rf conftest* CFLAGS="$CFLAGS -Wno-implicit-int" cat > conftest.$ac_ext <<EOF -#line 3664 "configure" +#line 3684 "configure" #include "confdefs.h" #include <X11/Xlib.h> int main() { ; return 0; } EOF -if { (eval echo configure:3671: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3691: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cflags_save="$cflags_save -Wno-implicit-int" else @@ -3691,7 +3711,7 @@ fi test "x$with_x" = xno -a "x$BEOS" != "xyes" -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no echo $ac_n "checking --enable-gui argument""... $ac_c" 1>&6 -echo "configure:3695: checking --enable-gui argument" >&5 +echo "configure:3715: checking --enable-gui argument" >&5 # Check whether --enable-gui or --disable-gui was given. if test "${enable_gui+set}" = set; then enableval="$enable_gui" @@ -3753,7 +3773,6 @@ elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then else - case "$enable_gui_canon" in no|none) echo "$ac_t""no GUI support" 1>&6 ;; yes|""|auto) echo "$ac_t""yes/auto - automatic GUI support" 1>&6 @@ -3764,6 +3783,8 @@ else SKIP_ATHENA= SKIP_NEXTAW= SKIP_CARBON=;; + kde|Kde|KDE) echo "$ac_t""KDE 2.x or 3.x GUI support" 1>&6 + SKIP_KDE=;; gtk) echo "$ac_t""GTK+ 1.x GUI support" 1>&6 SKIP_GTK=;; gtk2) echo "$ac_t""GTK+ 2.x GUI support" 1>&6 @@ -3787,9 +3808,26 @@ else fi +if test "x$SKIP_KDE" != "xYES" -a "$enable_gui_canon" != "kde"; then + echo $ac_n "checking whether or not to look for KDE""... $ac_c" 1>&6 +echo "configure:3814: checking whether or not to look for KDE" >&5 + # Check whether --enable-kde-check or --disable-kde-check was given. +if test "${enable_kde_check+set}" = set; then + enableval="$enable_kde_check" + : +else + enable_kde_check="no" +fi + + echo "$ac_t""$enable_kde_check" 1>&6; + if test "x$enable_kde_check" = "xno"; then + SKIP_KDE=YES + fi +fi + if test "x$SKIP_GTK" != "xYES" -a "$enable_gui_canon" != "gtk" -a "$enable_gui_canon" != "gtk2"; then echo $ac_n "checking whether or not to look for GTK""... $ac_c" 1>&6 -echo "configure:3793: checking whether or not to look for GTK" >&5 +echo "configure:3831: checking whether or not to look for GTK" >&5 # Check whether --enable-gtk-check or --disable-gtk-check was given. if test "${enable_gtk_check+set}" = set; then enableval="$enable_gtk_check" @@ -3808,7 +3846,7 @@ fi if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \ -a "$enable_gui_canon" != "gnome2"; then echo $ac_n "checking whether or not to look for GTK+ 2""... $ac_c" 1>&6 -echo "configure:3812: checking whether or not to look for GTK+ 2" >&5 +echo "configure:3850: checking whether or not to look for GTK+ 2" >&5 # Check whether --enable-gtk2-check or --disable-gtk2-check was given. if test "${enable_gtk2_check+set}" = set; then enableval="$enable_gtk2_check" @@ -3826,7 +3864,7 @@ fi if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome" \ -a "$enable_gui_canon" != "gnome2"; then echo $ac_n "checking whether or not to look for GNOME""... $ac_c" 1>&6 -echo "configure:3830: checking whether or not to look for GNOME" >&5 +echo "configure:3868: checking whether or not to look for GNOME" >&5 # Check whether --enable-gnome-check or --disable-gnome-check was given. if test "${enable_gnome_check+set}" = set; then enableval="$enable_gnome_check" @@ -3843,7 +3881,7 @@ fi if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then echo $ac_n "checking whether or not to look for Motif""... $ac_c" 1>&6 -echo "configure:3847: checking whether or not to look for Motif" >&5 +echo "configure:3885: checking whether or not to look for Motif" >&5 # Check whether --enable-motif-check or --disable-motif-check was given. if test "${enable_motif_check+set}" = set; then enableval="$enable_motif_check" @@ -3860,7 +3898,7 @@ fi if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then echo $ac_n "checking whether or not to look for Athena""... $ac_c" 1>&6 -echo "configure:3864: checking whether or not to look for Athena" >&5 +echo "configure:3902: checking whether or not to look for Athena" >&5 # Check whether --enable-athena-check or --disable-athena-check was given. if test "${enable_athena_check+set}" = set; then enableval="$enable_athena_check" @@ -3877,7 +3915,7 @@ fi if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then echo $ac_n "checking whether or not to look for neXtaw""... $ac_c" 1>&6 -echo "configure:3881: checking whether or not to look for neXtaw" >&5 +echo "configure:3919: checking whether or not to look for neXtaw" >&5 # Check whether --enable-nextaw-check or --disable-nextaw-check was given. if test "${enable_nextaw_check+set}" = set; then enableval="$enable_nextaw_check" @@ -3894,7 +3932,7 @@ fi if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then echo $ac_n "checking whether or not to look for Carbon""... $ac_c" 1>&6 -echo "configure:3898: checking whether or not to look for Carbon" >&5 +echo "configure:3936: checking whether or not to look for Carbon" >&5 # Check whether --enable-carbon-check or --disable-carbon-check was given. if test "${enable_carbon_check+set}" = set; then enableval="$enable_carbon_check" @@ -3909,9 +3947,359 @@ fi fi fi + +if test -z "$SKIP_KDE"; then +# Check whether --with-qt-dir or --without-qt-dir was given. +if test "${with_qt_dir+set}" = set; then + withval="$with_qt_dir" + + ROOTQT="$withval" + MOC="$withval"/bin/moc + QT_INCLUDES="$withval"/include + QT_LIBS="$withval"/lib + +fi + + +if test "x$ROOTQT" = "x"; then + if test -z "$QTDIR"; then + # Extract the first word of "moc", so it can be a program name with args. +set dummy moc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:3970: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_MOC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$MOC" in + /*) + ac_cv_path_MOC="$MOC" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_MOC="$MOC" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_MOC="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_MOC" && ac_cv_path_MOC="no" + ;; +esac +fi +MOC="$ac_cv_path_MOC" +if test -n "$MOC"; then + echo "$ac_t""$MOC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if text"x$MOC" = "x"; then + { echo "configure: error: could not find Qt directory" 1>&2; exit 1; } + else + ROOTQT=`echo $MOC | sed 's+/bin/moc++'` + fi + else + ROOTQT="$QTDIR" + fi +fi +MOC="$ROOTQT"/bin/moc +QT_INCLUDES="$ROOTQT"/include +QT_LIBS="$ROOTQT"/lib + +# Check whether --with-qt-includes or --without-qt-includes was given. +if test "${with_qt_includes+set}" = set; then + withval="$with_qt_includes" + QT_INCLUDES="$withval" + +fi + + +# Check whether --with-qt-libraries or --without-qt-libraries was given. +if test "${with_qt_libraries+set}" = set; then + withval="$with_qt_libraries" + QT_LIBS="$withval" + +fi + + +if test "x$QT_LIBS" = "x" ; then + QT_LIBS="$ROOTQT"/lib +fi +if test "x$QT_INCLUDES" = "x" ; then + QT_INCLUDES="$ROOTQT"/include +fi + +echo $ac_n "checking whether or not to use a KDE Toolbar in KVim""... $ac_c" 1>&6 +echo "configure:4040: checking whether or not to use a KDE Toolbar in KVim" >&5 +# Check whether --enable-kde-toolbar or --disable-kde-toolbar was given. +if test "${enable_kde_toolbar+set}" = set; then + enableval="$enable_kde_toolbar" + : +else + enable_kde_toolbar="no" +fi + +if test "x$enable_kde_toolbar" != "xno"; then + cat >> confdefs.h <<\EOF +#define FEAT_KDETOOLBAR 1 +EOF + +fi +echo "$ac_t""$enable_kde_toolbar" 1>&6; +fi + + +if test -z "$SKIP_KDE"; then + + +echo $ac_n "checking --disable-rpath argument""... $ac_c" 1>&6 +echo "configure:4063: checking --disable-rpath argument" >&5 +# Check whether --enable-rpath or --disable-rpath was given. +if test "${enable_rpath+set}" = set; then + enableval="$enable_rpath" + : +else + enable_rpath="yes" +fi + +if test "$enable_rpath" = "yes"; then + echo "$ac_t""no" 1>&6 +else + echo "$ac_t""yes" 1>&6 +fi + +echo $ac_n "checking --with-kde-prefix argument""... $ac_c" 1>&6 +echo "configure:4079: checking --with-kde-prefix argument" >&5 +# Check whether --with-kde-prefix or --without-kde-prefix was given. +if test "${with_kde_prefix+set}" = set; then + withval="$with_kde_prefix" + kde_config_prefix="$withval"; +echo "$ac_t""$kde_config_prefix" 1>&6 +else + kde_config_prefix="";echo "$ac_t""no" 1>&6 +fi + + +# Check whether --with-kde-includes or --without-kde-includes was given. +if test "${with_kde_includes+set}" = set; then + withval="$with_kde_includes" + KDE_INCLUDES="$withval" + +fi + + +# Check whether --with-kde-libraries or --without-kde-libraries was given. +if test "${with_kde_libraries+set}" = set; then + withval="$with_kde_libraries" + KDE_LIBS="$withval" + +fi + + +echo $ac_n "checking --disable-kdetest argument""... $ac_c" 1>&6 +echo "configure:4107: checking --disable-kdetest argument" >&5 +# Check whether --enable-kdetest or --disable-kdetest was given. +if test "${enable_kdetest+set}" = set; then + enableval="$enable_kdetest" + enable_kdetest=yes +fi + + +if test "x$enable_kdetest" = "xyes" ; then + echo "$ac_t""kde test enabled" 1>&6 +else + echo "$ac_t""kde test disabled" 1>&6 +fi + +if test "x$kde_config_prefix" != "x" ; then + kde_config_args="" + KDE_CONFIG=$kde_config_prefix/bin/kde-config +fi + +if test "X$KDE_CONFIG" = "X"; then + # Extract the first word of "kde-config", so it can be a program name with args. +set dummy kde-config; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:4130: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_KDE_CONFIG'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$KDE_CONFIG" in + /*) + ac_cv_path_KDE_CONFIG="$KDE_CONFIG" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_KDE_CONFIG="$KDE_CONFIG" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_KDE_CONFIG="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_KDE_CONFIG" && ac_cv_path_KDE_CONFIG="no" + ;; +esac +fi +KDE_CONFIG="$ac_cv_path_KDE_CONFIG" +if test -n "$KDE_CONFIG"; then + echo "$ac_t""$KDE_CONFIG" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + echo "$ac_t""Using KDE configuration program $KDE_CONFIG" 1>&6 +fi + +if test "X$KDE_CONFIG" != "X" ; then + + if test "X$KDE_CONFIG" != "X"; then + min_kde_version=2.0.0 + echo $ac_n "checking for KDE version >= $min_kde_version""... $ac_c" 1>&6 +echo "configure:4172: checking for KDE version >= $min_kde_version" >&5 + no_kde="" + if test "$KDE_CONFIG" = "no" ; then + no_kde=yes + else + KDE_PREFIX=`$KDE_CONFIG $kde_config_args --prefix` + if test "x$KDE_LIBS" = "x"; then + KDE_LIBS="$KDE_PREFIX/lib" + fi + if test "x$KDE_INCLUDES" = "x"; then + KDE_INCLUDES="$KDE_PREFIX/include" + fi + kde_major_version=`$KDE_CONFIG --version | grep KDE | \ +sed 's/KDE:\ //' | sed 's/\([0-9]*\).\([0-9]*.*\)/\1/'` + kde_minor_version=`$KDE_CONFIG --version | grep KDE | \ +sed 's/KDE:\ //' | sed 's/\([0-9]*\).\([0-9]*.*\)/\2/'` + + qt_major_version=`$KDE_CONFIG --version | grep Qt | sed -e \ +'s/Qt:\ //' | sed 's/\([0-9]*\).\([0-9]*.*\)/\1/'` + qt_minor_version=`$KDE_CONFIG --version | grep Qt | sed -e \ +'s/Qt:\ //' | sed 's/\([0-9]*\).\([0-9]*.*\)/\2/'` + + if test "x$enable-kdetest" = "xyes" ; then + ac_save_LIBS="$LIBS" + LIBS="$LIBS $KDE_LIBS" + + if test "$cross_compiling" = yes; then + echo $ac_n "cross compiling KDE ? ? how can i remove that ? :)" +else + cat > conftest.$ac_ext <<EOF +#line 4202 "configure" +#include "confdefs.h" + +#include <stdio.h> +int +main() +{ return 0; } + +EOF +if { (eval echo configure:4211: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + no_kde=yes +fi +rm -fr conftest* +fi + + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_kde" = x ; then + echo "$ac_t""found KDE $kde_major_version.$kde_minor_version" 1>&6 + GUI_LIB_LOC="-L$KDE_LIBS -lkdeui -lkdecore -lDCOP" + GUI_INC_LOC="-I$KDE_INCLUDES" + KDEDIR="$KDE_PREFIX" + else + echo "$ac_t""no" 1>&6 + KDE_LIBS="" + : + fi +else + echo "$ac_t""no" 1>&6 + KDE_LIBS="" + : +fi + + + + + if test "x$KDE_PREFIX" != "x"; then + echo $ac_n "checking for QT version $qt_major_version.x""... $ac_c" 1>&6 +echo "configure:4247: checking for QT version $qt_major_version.x" >&5 + if test "x$ROOTQT" != "x" ; then + GUI_INC_LOC="-I$QT_INCLUDES $GUI_INC_LOC" + if test $qt_major_version -lt 2; then + { echo "configure: error: Your QT version is prior to 2.0; KDE 2.x and 3.x require at least QT 2" 1>&2; exit 1; } + fi + if test "`(uname) 2>/dev/null`" = "FreeBSD"; then + CFLAGS="$CFLAGS -D_THREAD_SAFE" + CXXFLAGS="$CXXFLAGS -D_THREAD_SAFE" + GUI_LIB_LOC="$GUI_LIB_LOC -pthread" + LIBS="$LIBS -pthread" + fi + + if test "x$enable_rpath" = "xyes"; then + if test $qt_major_version = 2; then + GUI_LIB_LOC="-L$KDE_LIBS -lkfile -L$QT_LIBS -lqt $GUI_LIB_LOC \ +-Wl,--rpath -Wl,$KDE_LIBS -Wl,--rpath -Wl,$QT_LIBS" + else + GUI_LIB_LOC="-L$KDE_LIBS -lkio -L$QT_LIBS -lqt-mt $GUI_LIB_LOC \ +-Wl,--rpath -Wl,$KDE_LIBS -Wl,--rpath -Wl,$QT_LIBS" + fi + else + if test $qt_major_version = 2; then + GUI_LIB_LOC="-L$KDE_LIBS -lkfile -L$QT_LIBS -lqt $GUI_LIB_LOC" + else + GUI_LIB_LOC="-L$KDE_LIBS -lkio -L$QT_LIBS -lqt-mt $GUI_LIB_LOC" + fi + fi + + GUI_INC_LOC="`echo $GUI_INC_LOC\ | sed 's%-I/usr/include %%'`" + + echo "$ac_t""found $qt_major_version.$qt_minor_version in $ROOTQT" 1>&6 + SKIP_GTK=YES + SKIP_ATHENA=YES + SKIP_MOTIF=YES + GUITYPE=KDE + + + + + + cat >> confdefs.h <<\EOF +#define FEAT_GUI_KDE 1 +EOF + + else + { echo "configure: error: Detected QT version mismatched" 1>&2; exit 1; } + fi + else + { echo "configure: error: Could not find KDE installation prefix" 1>&2; exit 1; } + fi +fi +fi + if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then echo $ac_n "checking for Carbon GUI""... $ac_c" 1>&6 -echo "configure:3915: checking for Carbon GUI" >&5 +echo "configure:4303: checking for Carbon GUI" >&5 echo "$ac_t""yes" 1>&6; GUITYPE=CARBONGUI SKIP_GTK=YES; @@ -3933,11 +4321,10 @@ fi - if test -z "$SKIP_GTK"; then echo $ac_n "checking --with-gtk-prefix argument""... $ac_c" 1>&6 -echo "configure:3941: checking --with-gtk-prefix argument" >&5 +echo "configure:4328: checking --with-gtk-prefix argument" >&5 # Check whether --with-gtk-prefix or --without-gtk-prefix was given. if test "${with_gtk_prefix+set}" = set; then withval="$with_gtk_prefix" @@ -3948,7 +4335,7 @@ fi echo $ac_n "checking --with-gtk-exec-prefix argument""... $ac_c" 1>&6 -echo "configure:3952: checking --with-gtk-exec-prefix argument" >&5 +echo "configure:4339: checking --with-gtk-exec-prefix argument" >&5 # Check whether --with-gtk-exec-prefix or --without-gtk-exec-prefix was given. if test "${with_gtk_exec_prefix+set}" = set; then withval="$with_gtk_exec_prefix" @@ -3959,7 +4346,7 @@ fi echo $ac_n "checking --disable-gtktest argument""... $ac_c" 1>&6 -echo "configure:3963: checking --disable-gtktest argument" >&5 +echo "configure:4350: checking --disable-gtktest argument" >&5 # Check whether --enable-gtktest or --disable-gtktest was given. if test "${enable_gtktest+set}" = set; then enableval="$enable_gtktest" @@ -3986,7 +4373,7 @@ fi # Extract the first word of "gtk-config", so it can be a program name with args. set dummy gtk-config; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3990: checking for $ac_word" >&5 +echo "configure:4377: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GTK_CONFIG'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4023,7 +4410,7 @@ fi # Extract the first word of "gtk12-config", so it can be a program name with args. set dummy gtk12-config; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4027: checking for $ac_word" >&5 +echo "configure:4414: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GTK12_CONFIG'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4065,7 +4452,7 @@ fi # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4069: checking for $ac_word" >&5 +echo "configure:4456: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4107,7 +4494,7 @@ fi { min_gtk_version=2.2.0 echo $ac_n "checking for GTK - version >= $min_gtk_version""... $ac_c" 1>&6 -echo "configure:4111: checking for GTK - version >= $min_gtk_version" >&5 +echo "configure:4498: checking for GTK - version >= $min_gtk_version" >&5 no_gtk="" if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \ && $PKG_CONFIG --exists gtk+-2.0; then @@ -4148,7 +4535,7 @@ echo "configure:4111: checking for GTK - version >= $min_gtk_version" >&5 echo $ac_n "cross compiling; assumed OK... $ac_c" else cat > conftest.$ac_ext <<EOF -#line 4152 "configure" +#line 4539 "configure" #include "confdefs.h" #include <gtk/gtk.h> @@ -4180,7 +4567,7 @@ return 1; } EOF -if { (eval echo configure:4184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4571: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -4238,7 +4625,7 @@ fi { min_gtk_version=1.1.16 echo $ac_n "checking for GTK - version >= $min_gtk_version""... $ac_c" 1>&6 -echo "configure:4242: checking for GTK - version >= $min_gtk_version" >&5 +echo "configure:4629: checking for GTK - version >= $min_gtk_version" >&5 no_gtk="" if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \ && $PKG_CONFIG --exists gtk+-2.0; then @@ -4279,7 +4666,7 @@ echo "configure:4242: checking for GTK - version >= $min_gtk_version" >&5 echo $ac_n "cross compiling; assumed OK... $ac_c" else cat > conftest.$ac_ext <<EOF -#line 4283 "configure" +#line 4670 "configure" #include "confdefs.h" #include <gtk/gtk.h> @@ -4311,7 +4698,7 @@ return 1; } EOF -if { (eval echo configure:4315: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -4429,7 +4816,7 @@ fi if test "x$want_gnome" = xyes -a "0$gtk_major_version" -ge 2; then { echo $ac_n "checking for libgnomeui-2.0""... $ac_c" 1>&6 -echo "configure:4433: checking for libgnomeui-2.0" >&5 +echo "configure:4820: checking for libgnomeui-2.0" >&5 if $PKG_CONFIG --exists libgnomeui-2.0; then echo "$ac_t""yes" 1>&6 GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0` @@ -4448,7 +4835,7 @@ echo "configure:4433: checking for libgnomeui-2.0" >&5 # Extract the first word of "gnome-config", so it can be a program name with args. set dummy gnome-config; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4452: checking for $ac_word" >&5 +echo "configure:4839: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GNOME_CONFIG'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4485,7 +4872,7 @@ fi no_gnome_config="yes" else echo $ac_n "checking if $GNOME_CONFIG works""... $ac_c" 1>&6 -echo "configure:4489: checking if $GNOME_CONFIG works" >&5 +echo "configure:4876: checking if $GNOME_CONFIG works" >&5 if $GNOME_CONFIG --libs-only-l gnome >/dev/null 2>&1; then echo "$ac_t""yes" 1>&6 GNOME_LIBS="`$GNOME_CONFIG --libs-only-l gnome gnomeui`" @@ -4510,7 +4897,7 @@ echo "configure:4489: checking if $GNOME_CONFIG works" >&5 if test "$no_gnome_config" = "yes"; then echo $ac_n "checking for gnomeConf.sh file in $gnome_prefix""... $ac_c" 1>&6 -echo "configure:4514: checking for gnomeConf.sh file in $gnome_prefix" >&5 +echo "configure:4901: checking for gnomeConf.sh file in $gnome_prefix" >&5 if test -f $gnome_prefix/gnomeConf.sh; then echo "$ac_t""found" 1>&6 echo "loading gnome configuration from" \ @@ -4548,7 +4935,7 @@ if test -z "$SKIP_MOTIF"; then GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`" echo $ac_n "checking for location of Motif GUI includes""... $ac_c" 1>&6 -echo "configure:4552: checking for location of Motif GUI includes" >&5 +echo "configure:4939: checking for location of Motif GUI includes" >&5 gui_includes="`echo $x_includes|sed 's%/^/^/*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC" GUI_INC_LOC= for try in $gui_includes; do @@ -4572,7 +4959,7 @@ fi if test -z "$SKIP_MOTIF"; then echo $ac_n "checking --with-motif-lib argument""... $ac_c" 1>&6 -echo "configure:4576: checking --with-motif-lib argument" >&5 +echo "configure:4963: checking --with-motif-lib argument" >&5 # Check whether --with-motif-lib or --without-motif-lib was given. if test "${with_motif_lib+set}" = set; then withval="$with_motif_lib" @@ -4589,7 +4976,7 @@ fi GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`" echo $ac_n "checking for location of Motif GUI libs""... $ac_c" 1>&6 -echo "configure:4593: checking for location of Motif GUI libs" >&5 +echo "configure:4980: checking for location of Motif GUI libs" >&5 gui_libs="`echo $x_libraries|sed 's%/^/^/*$%%'` `echo "$gui_XXX" | sed s/XXX/lib/g` `echo "$GUI_INC_LOC" | sed s/include/lib/` $GUI_LIB_LOC" GUI_LIB_LOC= for try in $gui_libs; do @@ -4632,11 +5019,11 @@ GUI_X_LIBS= if test -z "$SKIP_ATHENA"; then echo $ac_n "checking if Athena header files can be found""... $ac_c" 1>&6 -echo "configure:4636: checking if Athena header files can be found" >&5 +echo "configure:5023: checking if Athena header files can be found" >&5 cflags_save=$CFLAGS CFLAGS="$CFLAGS $X_CFLAGS" cat > conftest.$ac_ext <<EOF -#line 4640 "configure" +#line 5027 "configure" #include "confdefs.h" #include <X11/Intrinsic.h> @@ -4645,7 +5032,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:4649: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5036: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -4664,11 +5051,11 @@ fi if test -z "$SKIP_NEXTAW"; then echo $ac_n "checking if neXtaw header files can be found""... $ac_c" 1>&6 -echo "configure:4668: checking if neXtaw header files can be found" >&5 +echo "configure:5055: checking if neXtaw header files can be found" >&5 cflags_save=$CFLAGS CFLAGS="$CFLAGS $X_CFLAGS" cat > conftest.$ac_ext <<EOF -#line 4672 "configure" +#line 5059 "configure" #include "confdefs.h" #include <X11/Intrinsic.h> @@ -4677,7 +5064,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:4681: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5068: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -4705,7 +5092,7 @@ if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then ldflags_save=$LDFLAGS LDFLAGS="$X_LIBS $LDFLAGS" echo $ac_n "checking for XShapeQueryExtension in -lXext""... $ac_c" 1>&6 -echo "configure:4709: checking for XShapeQueryExtension in -lXext" >&5 +echo "configure:5096: checking for XShapeQueryExtension in -lXext" >&5 ac_lib_var=`echo Xext'_'XShapeQueryExtension | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4713,7 +5100,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lXext -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <<EOF -#line 4717 "configure" +#line 5104 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -4724,7 +5111,7 @@ int main() { XShapeQueryExtension() ; return 0; } EOF -if { (eval echo configure:4728: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4745,7 +5132,7 @@ else fi echo $ac_n "checking for wslen in -lw""... $ac_c" 1>&6 -echo "configure:4749: checking for wslen in -lw" >&5 +echo "configure:5136: checking for wslen in -lw" >&5 ac_lib_var=`echo w'_'wslen | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4753,7 +5140,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lw $GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <<EOF -#line 4757 "configure" +#line 5144 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -4764,7 +5151,7 @@ int main() { wslen() ; return 0; } EOF -if { (eval echo configure:4768: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5155: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4785,7 +5172,7 @@ else fi echo $ac_n "checking for dlsym in -ldl""... $ac_c" 1>&6 -echo "configure:4789: checking for dlsym in -ldl" >&5 +echo "configure:5176: checking for dlsym in -ldl" >&5 ac_lib_var=`echo dl'_'dlsym | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4793,7 +5180,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <<EOF -#line 4797 "configure" +#line 5184 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -4804,7 +5191,7 @@ int main() { dlsym() ; return 0; } EOF -if { (eval echo configure:4808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5195: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4825,7 +5212,7 @@ else fi echo $ac_n "checking for XmuCreateStippledPixmap in -lXmu""... $ac_c" 1>&6 -echo "configure:4829: checking for XmuCreateStippledPixmap in -lXmu" >&5 +echo "configure:5216: checking for XmuCreateStippledPixmap in -lXmu" >&5 ac_lib_var=`echo Xmu'_'XmuCreateStippledPixmap | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4833,7 +5220,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lXmu $GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <<EOF -#line 4837 "configure" +#line 5224 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -4844,7 +5231,7 @@ int main() { XmuCreateStippledPixmap() ; return 0; } EOF -if { (eval echo configure:4848: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5235: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4866,7 +5253,7 @@ fi if test -z "$SKIP_MOTIF"; then echo $ac_n "checking for XpEndJob in -lXp""... $ac_c" 1>&6 -echo "configure:4870: checking for XpEndJob in -lXp" >&5 +echo "configure:5257: checking for XpEndJob in -lXp" >&5 ac_lib_var=`echo Xp'_'XpEndJob | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4874,7 +5261,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lXp $GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <<EOF -#line 4878 "configure" +#line 5265 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -4885,7 +5272,7 @@ int main() { XpEndJob() ; return 0; } EOF -if { (eval echo configure:4889: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4909,7 +5296,7 @@ fi LDFLAGS=$ldflags_save echo $ac_n "checking for extra X11 defines""... $ac_c" 1>&6 -echo "configure:4913: checking for extra X11 defines" >&5 +echo "configure:5300: checking for extra X11 defines" >&5 NARROW_PROTO= rm -fr conftestdir if mkdir conftestdir; then @@ -4939,17 +5326,17 @@ if test "$enable_xsmp" = "yes"; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4943: checking for $ac_hdr" >&5 +echo "configure:5330: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4948 "configure" +#line 5335 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4953: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5340: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4986,17 +5373,17 @@ if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF" -o -z "$SKIP_ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4990: checking for $ac_hdr" >&5 +echo "configure:5377: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4995 "configure" +#line 5382 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5000: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5387: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5025,9 +5412,9 @@ done if test ! "$enable_xim" = "no"; then echo $ac_n "checking for XIMText in X11/Xlib.h""... $ac_c" 1>&6 -echo "configure:5029: checking for XIMText in X11/Xlib.h" >&5 +echo "configure:5416: checking for XIMText in X11/Xlib.h" >&5 cat > conftest.$ac_ext <<EOF -#line 5031 "configure" +#line 5418 "configure" #include "confdefs.h" #include <X11/Xlib.h> EOF @@ -5058,17 +5445,17 @@ if test -z "$SKIP_ATHENA" -o -z "$SKIP_NEXTAW" -o -z "$SKIP_MOTIF"; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5062: checking for $ac_hdr" >&5 +echo "configure:5449: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5067 "configure" +#line 5454 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5072: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5459: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5104,17 +5491,17 @@ if test -z "$SKIP_MOTIF"; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5108: checking for $ac_hdr" >&5 +echo "configure:5495: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5113 "configure" +#line 5500 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5118: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5505: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5207,17 +5594,17 @@ fi echo $ac_n "checking quality of toupper""... $ac_c" 1>&6 -echo "configure:5211: checking quality of toupper" >&5 +echo "configure:5598: checking quality of toupper" >&5 if test "$cross_compiling" = yes; then { echo "configure: error: failed to compile test program" 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 5216 "configure" +#line 5603 "configure" #include "confdefs.h" #include <ctype.h> main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); } EOF -if { (eval echo configure:5221: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5608: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then cat >> confdefs.h <<\EOF #define BROKEN_TOUPPER 1 @@ -5234,16 +5621,16 @@ fi echo $ac_n "checking whether __DATE__ and __TIME__ work""... $ac_c" 1>&6 -echo "configure:5238: checking whether __DATE__ and __TIME__ work" >&5 +echo "configure:5625: checking whether __DATE__ and __TIME__ work" >&5 cat > conftest.$ac_ext <<EOF -#line 5240 "configure" +#line 5627 "configure" #include "confdefs.h" int main() { printf("(" __DATE__ " " __TIME__ ")"); ; return 0; } EOF -if { (eval echo configure:5247: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5634: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_DATE_TIME 1 @@ -5259,17 +5646,17 @@ rm -f conftest* ac_safe=`echo "elf.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for elf.h""... $ac_c" 1>&6 -echo "configure:5263: checking for elf.h" >&5 +echo "configure:5650: checking for elf.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5268 "configure" +#line 5655 "configure" #include "confdefs.h" #include <elf.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5273: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5660: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5292,7 +5679,7 @@ fi if test "$HAS_ELF" = 1; then echo $ac_n "checking for main in -lelf""... $ac_c" 1>&6 -echo "configure:5296: checking for main in -lelf" >&5 +echo "configure:5683: checking for main in -lelf" >&5 ac_lib_var=`echo elf'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5300,14 +5687,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lelf $LIBS" cat > conftest.$ac_ext <<EOF -#line 5304 "configure" +#line 5691 "configure" #include "confdefs.h" int main() { main() ; return 0; } EOF -if { (eval echo configure:5311: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5341,12 +5728,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:5345: checking for $ac_hdr that defines DIR" >&5 +echo "configure:5732: checking for $ac_hdr that defines DIR" >&5 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5350 "configure" +#line 5737 "configure" #include "confdefs.h" #include <sys/types.h> #include <$ac_hdr> @@ -5354,7 +5741,7 @@ int main() { DIR *dirp = 0; ; return 0; } EOF -if { (eval echo configure:5358: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5745: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else @@ -5379,7 +5766,7 @@ done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:5383: checking for opendir in -ldir" >&5 +echo "configure:5770: checking for opendir in -ldir" >&5 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5387,7 +5774,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <<EOF -#line 5391 "configure" +#line 5778 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -5398,7 +5785,7 @@ int main() { opendir() ; return 0; } EOF -if { (eval echo configure:5402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5789: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5420,7 +5807,7 @@ fi else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:5424: checking for opendir in -lx" >&5 +echo "configure:5811: checking for opendir in -lx" >&5 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5428,7 +5815,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <<EOF -#line 5432 "configure" +#line 5819 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -5439,7 +5826,7 @@ int main() { opendir() ; return 0; } EOF -if { (eval echo configure:5443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5830: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5463,12 +5850,12 @@ fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:5467: checking for ANSI C header files" >&5 +echo "configure:5854: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5472 "configure" +#line 5859 "configure" #include "confdefs.h" #include <stdlib.h> #include <stdarg.h> @@ -5476,7 +5863,7 @@ else #include <float.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5480: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5867: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5493,7 +5880,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 5497 "configure" +#line 5884 "configure" #include "confdefs.h" #include <string.h> EOF @@ -5511,7 +5898,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 5515 "configure" +#line 5902 "configure" #include "confdefs.h" #include <stdlib.h> EOF @@ -5532,7 +5919,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext <<EOF -#line 5536 "configure" +#line 5923 "configure" #include "confdefs.h" #include <ctype.h> #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -5543,7 +5930,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:5547: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5934: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -5567,12 +5954,12 @@ EOF fi echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:5571: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:5958: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5576 "configure" +#line 5963 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/wait.h> @@ -5588,7 +5975,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:5592: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5979: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -5611,16 +5998,16 @@ fi if test $ac_cv_header_sys_wait_h = no; then echo $ac_n "checking for sys/wait.h that defines union wait""... $ac_c" 1>&6 -echo "configure:5615: checking for sys/wait.h that defines union wait" >&5 +echo "configure:6002: checking for sys/wait.h that defines union wait" >&5 cat > conftest.$ac_ext <<EOF -#line 5617 "configure" +#line 6004 "configure" #include "confdefs.h" #include <sys/wait.h> int main() { union wait xx, yy; xx = yy ; return 0; } EOF -if { (eval echo configure:5624: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6011: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF @@ -5651,17 +6038,17 @@ for ac_hdr in stdarg.h stdlib.h string.h sys/select.h sys/utsname.h \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5655: checking for $ac_hdr" >&5 +echo "configure:6042: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5660 "configure" +#line 6047 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5665: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6052: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5693,17 +6080,17 @@ if test "x$MACOSX" != "xyes"; then do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5697: checking for $ac_hdr" >&5 +echo "configure:6084: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5702 "configure" +#line 6089 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5707: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6094: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5732,11 +6119,11 @@ done fi echo $ac_n "checking if strings.h can be included after string.h""... $ac_c" 1>&6 -echo "configure:5736: checking if strings.h can be included after string.h" >&5 +echo "configure:6123: checking if strings.h can be included after string.h" >&5 cppflags_save=$CPPFLAGS CPPFLAGS="$CPPFLAGS $X_CFLAGS" cat > conftest.$ac_ext <<EOF -#line 5740 "configure" +#line 6127 "configure" #include "confdefs.h" #if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO) @@ -5757,7 +6144,7 @@ int main() { int i; i = 0; ; return 0; } EOF -if { (eval echo configure:5761: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6148: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -5775,13 +6162,13 @@ CPPFLAGS=$cppflags_save if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:5779: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:6166: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext <<EOF -#line 5785 "configure" +#line 6172 "configure" #include "confdefs.h" #include <sgtty.h> Autoconf TIOCGETP @@ -5799,7 +6186,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext <<EOF -#line 5803 "configure" +#line 6190 "configure" #include "confdefs.h" #include <termio.h> Autoconf TCGETA @@ -5821,12 +6208,12 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:5825: checking for working const" >&5 +echo "configure:6212: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5830 "configure" +#line 6217 "configure" #include "confdefs.h" int main() { @@ -5875,7 +6262,7 @@ ccp = (char const *const *) p; ; return 0; } EOF -if { (eval echo configure:5879: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6266: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -5896,12 +6283,12 @@ EOF fi echo $ac_n "checking for mode_t""... $ac_c" 1>&6 -echo "configure:5900: checking for mode_t" >&5 +echo "configure:6287: checking for mode_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5905 "configure" +#line 6292 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -5929,12 +6316,12 @@ EOF fi echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:5933: checking for off_t" >&5 +echo "configure:6320: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5938 "configure" +#line 6325 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -5962,12 +6349,12 @@ EOF fi echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:5966: checking for pid_t" >&5 +echo "configure:6353: checking for pid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 5971 "configure" +#line 6358 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -5995,12 +6382,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:5999: checking for size_t" >&5 +echo "configure:6386: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 6004 "configure" +#line 6391 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -6028,12 +6415,12 @@ EOF fi echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:6032: checking for uid_t in sys/types.h" >&5 +echo "configure:6419: checking for uid_t in sys/types.h" >&5 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 6037 "configure" +#line 6424 "configure" #include "confdefs.h" #include <sys/types.h> EOF @@ -6062,12 +6449,12 @@ EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:6066: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:6453: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 6071 "configure" +#line 6458 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/time.h> @@ -6076,7 +6463,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:6080: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6467: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -6097,12 +6484,12 @@ EOF fi echo $ac_n "checking for ino_t""... $ac_c" 1>&6 -echo "configure:6101: checking for ino_t" >&5 +echo "configure:6488: checking for ino_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_ino_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 6106 "configure" +#line 6493 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -6130,12 +6517,12 @@ EOF fi echo $ac_n "checking for dev_t""... $ac_c" 1>&6 -echo "configure:6134: checking for dev_t" >&5 +echo "configure:6521: checking for dev_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_dev_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 6139 "configure" +#line 6526 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -6164,12 +6551,12 @@ fi echo $ac_n "checking for rlim_t""... $ac_c" 1>&6 -echo "configure:6168: checking for rlim_t" >&5 +echo "configure:6555: checking for rlim_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then echo "$ac_t""(cached) $ac_cv_type_rlim_t" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 6173 "configure" +#line 6560 "configure" #include "confdefs.h" #include <sys/types.h> @@ -6201,12 +6588,12 @@ EOF fi echo $ac_n "checking for stack_t""... $ac_c" 1>&6 -echo "configure:6205: checking for stack_t" >&5 +echo "configure:6592: checking for stack_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then echo "$ac_t""(cached) $ac_cv_type_stack_t" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 6210 "configure" +#line 6597 "configure" #include "confdefs.h" #include <sys/types.h> @@ -6236,9 +6623,9 @@ EOF fi echo $ac_n "checking whether stack_t has an ss_base field""... $ac_c" 1>&6 -echo "configure:6240: checking whether stack_t has an ss_base field" >&5 +echo "configure:6627: checking whether stack_t has an ss_base field" >&5 cat > conftest.$ac_ext <<EOF -#line 6242 "configure" +#line 6629 "configure" #include "confdefs.h" #include <sys/types.h> @@ -6253,7 +6640,7 @@ int main() { stack_t sigstk; sigstk.ss_base = 0; ; return 0; } EOF -if { (eval echo configure:6257: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6644: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_SS_BASE 1 @@ -6269,7 +6656,7 @@ rm -f conftest* olibs="$LIBS" echo $ac_n "checking --with-tlib argument""... $ac_c" 1>&6 -echo "configure:6273: checking --with-tlib argument" >&5 +echo "configure:6660: checking --with-tlib argument" >&5 # Check whether --with-tlib or --without-tlib was given. if test "${with_tlib+set}" = set; then withval="$with_tlib" @@ -6287,7 +6674,7 @@ else esac for libname in $tlibs; do echo $ac_n "checking for tgetent in -l${libname}""... $ac_c" 1>&6 -echo "configure:6291: checking for tgetent in -l${libname}" >&5 +echo "configure:6678: checking for tgetent in -l${libname}" >&5 ac_lib_var=`echo ${libname}'_'tgetent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6295,7 +6682,7 @@ else ac_save_LIBS="$LIBS" LIBS="-l${libname} $LIBS" cat > conftest.$ac_ext <<EOF -#line 6299 "configure" +#line 6686 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -6306,7 +6693,7 @@ int main() { tgetent() ; return 0; } EOF -if { (eval echo configure:6310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6338,7 +6725,7 @@ fi res="FAIL" else cat > conftest.$ac_ext <<EOF -#line 6342 "configure" +#line 6729 "configure" #include "confdefs.h" #ifdef HAVE_TERMCAP_H @@ -6346,7 +6733,7 @@ else #endif main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); } EOF -if { (eval echo configure:6350: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6737: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then res="OK" else @@ -6368,12 +6755,12 @@ fi fi if test "x$olibs" != "x$LIBS"; then echo $ac_n "checking whether we talk terminfo""... $ac_c" 1>&6 -echo "configure:6372: checking whether we talk terminfo" >&5 +echo "configure:6759: checking whether we talk terminfo" >&5 if test "$cross_compiling" = yes; then { echo "configure: error: failed to compile test program." 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 6377 "configure" +#line 6764 "configure" #include "confdefs.h" #ifdef HAVE_TERMCAP_H @@ -6382,7 +6769,7 @@ else main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); } EOF -if { (eval echo configure:6386: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then echo "$ac_t""no -- we are in termcap land" 1>&6 else @@ -6403,12 +6790,12 @@ fi if test "x$olibs" != "x$LIBS"; then echo $ac_n "checking what tgetent() returns for an unknown terminal""... $ac_c" 1>&6 -echo "configure:6407: checking what tgetent() returns for an unknown terminal" >&5 +echo "configure:6794: checking what tgetent() returns for an unknown terminal" >&5 if test "$cross_compiling" = yes; then { echo "configure: error: failed to compile test program." 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 6412 "configure" +#line 6799 "configure" #include "confdefs.h" #ifdef HAVE_TERMCAP_H @@ -6417,7 +6804,7 @@ else main() {char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); } EOF -if { (eval echo configure:6421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then echo "$ac_t""zero" 1>&6; cat >> confdefs.h <<\EOF #define TGETENT_ZERO_ERR 0 @@ -6435,9 +6822,9 @@ fi fi echo $ac_n "checking whether termcap.h contains ospeed""... $ac_c" 1>&6 -echo "configure:6439: checking whether termcap.h contains ospeed" >&5 +echo "configure:6826: checking whether termcap.h contains ospeed" >&5 cat > conftest.$ac_ext <<EOF -#line 6441 "configure" +#line 6828 "configure" #include "confdefs.h" #ifdef HAVE_TERMCAP_H @@ -6448,7 +6835,7 @@ int main() { ospeed = 20000 ; return 0; } EOF -if { (eval echo configure:6452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_OSPEED 1 @@ -6460,9 +6847,9 @@ else rm -rf conftest* echo "$ac_t""no" 1>&6 echo $ac_n "checking whether ospeed can be extern""... $ac_c" 1>&6 -echo "configure:6464: checking whether ospeed can be extern" >&5 +echo "configure:6851: checking whether ospeed can be extern" >&5 cat > conftest.$ac_ext <<EOF -#line 6466 "configure" +#line 6853 "configure" #include "confdefs.h" #ifdef HAVE_TERMCAP_H @@ -6474,7 +6861,7 @@ int main() { ospeed = 20000 ; return 0; } EOF -if { (eval echo configure:6478: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define OSPEED_EXTERN 1 @@ -6492,9 +6879,9 @@ fi rm -f conftest* echo $ac_n "checking whether termcap.h contains UP, BC and PC""... $ac_c" 1>&6 -echo "configure:6496: checking whether termcap.h contains UP, BC and PC" >&5 +echo "configure:6883: checking whether termcap.h contains UP, BC and PC" >&5 cat > conftest.$ac_ext <<EOF -#line 6498 "configure" +#line 6885 "configure" #include "confdefs.h" #ifdef HAVE_TERMCAP_H @@ -6505,7 +6892,7 @@ int main() { if (UP == 0 && BC == 0) PC = 1 ; return 0; } EOF -if { (eval echo configure:6509: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6896: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_UP_BC_PC 1 @@ -6517,9 +6904,9 @@ else rm -rf conftest* echo "$ac_t""no" 1>&6 echo $ac_n "checking whether UP, BC and PC can be extern""... $ac_c" 1>&6 -echo "configure:6521: checking whether UP, BC and PC can be extern" >&5 +echo "configure:6908: checking whether UP, BC and PC can be extern" >&5 cat > conftest.$ac_ext <<EOF -#line 6523 "configure" +#line 6910 "configure" #include "confdefs.h" #ifdef HAVE_TERMCAP_H @@ -6531,7 +6918,7 @@ int main() { if (UP == 0 && BC == 0) PC = 1 ; return 0; } EOF -if { (eval echo configure:6535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6922: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define UP_BC_PC_EXTERN 1 @@ -6549,9 +6936,9 @@ fi rm -f conftest* echo $ac_n "checking whether tputs() uses outfuntype""... $ac_c" 1>&6 -echo "configure:6553: checking whether tputs() uses outfuntype" >&5 +echo "configure:6940: checking whether tputs() uses outfuntype" >&5 cat > conftest.$ac_ext <<EOF -#line 6555 "configure" +#line 6942 "configure" #include "confdefs.h" #ifdef HAVE_TERMCAP_H @@ -6562,7 +6949,7 @@ int main() { extern int xx(); tputs("test", 1, (outfuntype)xx) ; return 0; } EOF -if { (eval echo configure:6566: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6953: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_OUTFUNTYPE 1 @@ -6577,9 +6964,9 @@ fi rm -f conftest* echo $ac_n "checking whether sys/select.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:6581: checking whether sys/select.h and sys/time.h may both be included" >&5 +echo "configure:6968: checking whether sys/select.h and sys/time.h may both be included" >&5 cat > conftest.$ac_ext <<EOF -#line 6583 "configure" +#line 6970 "configure" #include "confdefs.h" #include <sys/types.h> @@ -6589,7 +6976,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6593: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6980: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF @@ -6606,7 +6993,7 @@ rm -f conftest* echo $ac_n "checking for /dev/ptc""... $ac_c" 1>&6 -echo "configure:6610: checking for /dev/ptc" >&5 +echo "configure:6997: checking for /dev/ptc" >&5 if test -r /dev/ptc; then cat >> confdefs.h <<\EOF #define HAVE_DEV_PTC 1 @@ -6618,17 +7005,17 @@ else fi echo $ac_n "checking for SVR4 ptys""... $ac_c" 1>&6 -echo "configure:6622: checking for SVR4 ptys" >&5 +echo "configure:7009: checking for SVR4 ptys" >&5 if test -c /dev/ptmx ; then cat > conftest.$ac_ext <<EOF -#line 6625 "configure" +#line 7012 "configure" #include "confdefs.h" int main() { ptsname(0);grantpt(0);unlockpt(0); ; return 0; } EOF -if { (eval echo configure:6632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7019: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_SVR4_PTYS 1 @@ -6646,14 +7033,14 @@ else fi echo $ac_n "checking for ptyranges""... $ac_c" 1>&6 -echo "configure:6650: checking for ptyranges" >&5 +echo "configure:7037: checking for ptyranges" >&5 if test -d /dev/ptym ; then pdir='/dev/ptym' else pdir='/dev' fi cat > conftest.$ac_ext <<EOF -#line 6657 "configure" +#line 7044 "configure" #include "confdefs.h" #ifdef M_UNIX yes; @@ -6687,13 +7074,13 @@ else fi echo $ac_n "checking default tty permissions/group""... $ac_c" 1>&6 -echo "configure:6691: checking default tty permissions/group" >&5 +echo "configure:7078: checking default tty permissions/group" >&5 rm -f conftest_grp if test "$cross_compiling" = yes; then { echo "configure: error: failed to compile test program" 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 6697 "configure" +#line 7084 "configure" #include "confdefs.h" #include <sys/types.h> @@ -6725,7 +7112,7 @@ main() } EOF -if { (eval echo configure:6729: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7116: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then if test -f conftest_grp; then @@ -6756,12 +7143,12 @@ rm -f conftest_grp echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:6760: checking return type of signal handlers" >&5 +echo "configure:7147: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 6765 "configure" +#line 7152 "configure" #include "confdefs.h" #include <sys/types.h> #include <signal.h> @@ -6778,7 +7165,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:6782: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7169: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -6810,9 +7197,9 @@ EOF fi echo $ac_n "checking for struct sigcontext""... $ac_c" 1>&6 -echo "configure:6814: checking for struct sigcontext" >&5 +echo "configure:7201: checking for struct sigcontext" >&5 cat > conftest.$ac_ext <<EOF -#line 6816 "configure" +#line 7203 "configure" #include "confdefs.h" #include <signal.h> @@ -6826,7 +7213,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:6830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7217: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF @@ -6842,12 +7229,12 @@ fi rm -f conftest* echo $ac_n "checking getcwd implementation""... $ac_c" 1>&6 -echo "configure:6846: checking getcwd implementation" >&5 +echo "configure:7233: checking getcwd implementation" >&5 if test "$cross_compiling" = yes; then { echo "configure: error: failed to compile test program" 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 6851 "configure" +#line 7238 "configure" #include "confdefs.h" char *dagger[] = { "IFS=pwd", 0 }; @@ -6859,7 +7246,7 @@ main() return getcwd(buffer, 500) ? 0 : 1; } EOF -if { (eval echo configure:6863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7250: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then echo "$ac_t""it is usable" 1>&6 else @@ -6884,12 +7271,12 @@ for ac_func in bcmp fchdir fchown fseeko fsync ftello getcwd getpseudotty \ strnicmp strpbrk strtol tgetent towlower towupper usleep utime utimes do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:6888: checking for $ac_func" >&5 +echo "configure:7275: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 6893 "configure" +#line 7280 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -6912,7 +7299,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:6916: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7303: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -6938,9 +7325,9 @@ done echo $ac_n "checking for st_blksize""... $ac_c" 1>&6 -echo "configure:6942: checking for st_blksize" >&5 +echo "configure:7329: checking for st_blksize" >&5 cat > conftest.$ac_ext <<EOF -#line 6944 "configure" +#line 7331 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/stat.h> @@ -6952,7 +7339,7 @@ int main() { n = (int)st.st_blksize; ; return 0; } EOF -if { (eval echo configure:6956: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7343: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_ST_BLKSIZE 1 @@ -6967,18 +7354,18 @@ fi rm -f conftest* echo $ac_n "checking whether stat() ignores a trailing slash""... $ac_c" 1>&6 -echo "configure:6971: checking whether stat() ignores a trailing slash" >&5 +echo "configure:7358: checking whether stat() ignores a trailing slash" >&5 if test "$cross_compiling" = yes; then { echo "configure: error: failed to compile test program" 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 6976 "configure" +#line 7363 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/stat.h> main() {struct stat st; exit(stat("configure/", &st) != 0); } EOF -if { (eval echo configure:6982: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define STAT_IGNORES_SLASH 1 @@ -6995,11 +7382,11 @@ fi echo $ac_n "checking for iconv_open()""... $ac_c" 1>&6 -echo "configure:6999: checking for iconv_open()" >&5 +echo "configure:7386: checking for iconv_open()" >&5 save_LIBS="$LIBS" LIBS="$LIBS -liconv" cat > conftest.$ac_ext <<EOF -#line 7003 "configure" +#line 7390 "configure" #include "confdefs.h" #ifdef HAVE_ICONV_H @@ -7010,7 +7397,7 @@ int main() { iconv_open("fr", "to"); ; return 0; } EOF -if { (eval echo configure:7014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes; with -liconv" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_ICONV 1 @@ -7022,7 +7409,7 @@ else rm -rf conftest* LIBS="$save_LIBS" cat > conftest.$ac_ext <<EOF -#line 7026 "configure" +#line 7413 "configure" #include "confdefs.h" #ifdef HAVE_ICONV_H @@ -7033,7 +7420,7 @@ int main() { iconv_open("fr", "to"); ; return 0; } EOF -if { (eval echo configure:7037: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7424: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_ICONV 1 @@ -7051,9 +7438,9 @@ rm -f conftest* echo $ac_n "checking for nl_langinfo(CODESET)""... $ac_c" 1>&6 -echo "configure:7055: checking for nl_langinfo(CODESET)" >&5 +echo "configure:7442: checking for nl_langinfo(CODESET)" >&5 cat > conftest.$ac_ext <<EOF -#line 7057 "configure" +#line 7444 "configure" #include "confdefs.h" #ifdef HAVE_LANGINFO_H @@ -7064,7 +7451,7 @@ int main() { char *cs = nl_langinfo(CODESET); ; return 0; } EOF -if { (eval echo configure:7068: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_NL_LANGINFO_CODESET 1 @@ -7079,7 +7466,7 @@ fi rm -f conftest* echo $ac_n "checking --disable-acl argument""... $ac_c" 1>&6 -echo "configure:7083: checking --disable-acl argument" >&5 +echo "configure:7470: checking --disable-acl argument" >&5 # Check whether --enable-acl or --disable-acl was given. if test "${enable_acl+set}" = set; then enableval="$enable_acl" @@ -7091,7 +7478,7 @@ fi if test "$enable_acl" = "yes"; then echo "$ac_t""no" 1>&6 echo $ac_n "checking for acl_get_file in -lposix1e""... $ac_c" 1>&6 -echo "configure:7095: checking for acl_get_file in -lposix1e" >&5 +echo "configure:7482: checking for acl_get_file in -lposix1e" >&5 ac_lib_var=`echo posix1e'_'acl_get_file | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7099,7 +7486,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lposix1e $LIBS" cat > conftest.$ac_ext <<EOF -#line 7103 "configure" +#line 7490 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -7110,7 +7497,7 @@ int main() { acl_get_file() ; return 0; } EOF -if { (eval echo configure:7114: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7501: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7129,7 +7516,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for acl_get_file in -lacl""... $ac_c" 1>&6 -echo "configure:7133: checking for acl_get_file in -lacl" >&5 +echo "configure:7520: checking for acl_get_file in -lacl" >&5 ac_lib_var=`echo acl'_'acl_get_file | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7137,7 +7524,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lacl $LIBS" cat > conftest.$ac_ext <<EOF -#line 7141 "configure" +#line 7528 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -7148,7 +7535,7 @@ int main() { acl_get_file() ; return 0; } EOF -if { (eval echo configure:7152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7165,7 +7552,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="$LIBS -lacl" echo $ac_n "checking for fgetxattr in -lattr""... $ac_c" 1>&6 -echo "configure:7169: checking for fgetxattr in -lattr" >&5 +echo "configure:7556: checking for fgetxattr in -lattr" >&5 ac_lib_var=`echo attr'_'fgetxattr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7173,7 +7560,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lattr $LIBS" cat > conftest.$ac_ext <<EOF -#line 7177 "configure" +#line 7564 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -7184,7 +7571,7 @@ int main() { fgetxattr() ; return 0; } EOF -if { (eval echo configure:7188: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7212,9 +7599,9 @@ fi echo $ac_n "checking for POSIX ACL support""... $ac_c" 1>&6 -echo "configure:7216: checking for POSIX ACL support" >&5 +echo "configure:7603: checking for POSIX ACL support" >&5 cat > conftest.$ac_ext <<EOF -#line 7218 "configure" +#line 7605 "configure" #include "confdefs.h" #include <sys/types.h> @@ -7228,7 +7615,7 @@ acl = acl_get_file("foo", ACL_TYPE_ACCESS); acl_free(acl); ; return 0; } EOF -if { (eval echo configure:7232: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7619: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_POSIX_ACL 1 @@ -7243,9 +7630,9 @@ fi rm -f conftest* echo $ac_n "checking for Solaris ACL support""... $ac_c" 1>&6 -echo "configure:7247: checking for Solaris ACL support" >&5 +echo "configure:7634: checking for Solaris ACL support" >&5 cat > conftest.$ac_ext <<EOF -#line 7249 "configure" +#line 7636 "configure" #include "confdefs.h" #ifdef HAVE_SYS_ACL_H @@ -7256,7 +7643,7 @@ acl("foo", GETACLCNT, 0, NULL); ; return 0; } EOF -if { (eval echo configure:7260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7647: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_SOLARIS_ACL 1 @@ -7271,9 +7658,9 @@ fi rm -f conftest* echo $ac_n "checking for AIX ACL support""... $ac_c" 1>&6 -echo "configure:7275: checking for AIX ACL support" >&5 +echo "configure:7662: checking for AIX ACL support" >&5 cat > conftest.$ac_ext <<EOF -#line 7277 "configure" +#line 7664 "configure" #include "confdefs.h" #ifdef HAVE_SYS_ACL_H @@ -7295,7 +7682,7 @@ aclsize = sizeof(struct acl); ; return 0; } EOF -if { (eval echo configure:7299: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7686: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_AIX_ACL 1 @@ -7313,7 +7700,7 @@ else fi echo $ac_n "checking --disable-gpm argument""... $ac_c" 1>&6 -echo "configure:7317: checking --disable-gpm argument" >&5 +echo "configure:7704: checking --disable-gpm argument" >&5 # Check whether --enable-gpm or --disable-gpm was given. if test "${enable_gpm+set}" = set; then enableval="$enable_gpm" @@ -7326,13 +7713,13 @@ fi if test "$enable_gpm" = "yes"; then echo "$ac_t""no" 1>&6 echo $ac_n "checking for gpm""... $ac_c" 1>&6 -echo "configure:7330: checking for gpm" >&5 +echo "configure:7717: checking for gpm" >&5 if eval "test \"`echo '$''{'vi_cv_have_gpm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else olibs="$LIBS" ; LIBS="-lgpm" cat > conftest.$ac_ext <<EOF -#line 7336 "configure" +#line 7723 "configure" #include "confdefs.h" #include <gpm.h> #include <linux/keyboard.h> @@ -7340,7 +7727,7 @@ int main() { Gpm_GetLibVersion(NULL); ; return 0; } EOF -if { (eval echo configure:7344: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7731: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* vi_cv_have_gpm=yes else @@ -7367,12 +7754,12 @@ else fi echo $ac_n "checking for vsnprintf()""... $ac_c" 1>&6 -echo "configure:7371: checking for vsnprintf()" >&5 +echo "configure:7758: checking for vsnprintf()" >&5 if test "$cross_compiling" = yes; then { echo "configure: error: failed to compile test program" 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 7376 "configure" +#line 7763 "configure" #include "confdefs.h" #include <stdio.h> @@ -7393,7 +7780,7 @@ else } EOF -if { (eval echo configure:7397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7784: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then cat >> confdefs.h <<\EOF #define HAVE_VSNPRINTF 1 @@ -7411,16 +7798,16 @@ fi echo $ac_n "checking for rename""... $ac_c" 1>&6 -echo "configure:7415: checking for rename" >&5 +echo "configure:7802: checking for rename" >&5 cat > conftest.$ac_ext <<EOF -#line 7417 "configure" +#line 7804 "configure" #include "confdefs.h" #include <stdio.h> int main() { rename("this", "that") ; return 0; } EOF -if { (eval echo configure:7424: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_RENAME 1 @@ -7435,9 +7822,9 @@ fi rm -f conftest* echo $ac_n "checking for sysctl""... $ac_c" 1>&6 -echo "configure:7439: checking for sysctl" >&5 +echo "configure:7826: checking for sysctl" >&5 cat > conftest.$ac_ext <<EOF -#line 7441 "configure" +#line 7828 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/sysctl.h> @@ -7452,7 +7839,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:7456: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7843: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_SYSCTL 1 @@ -7467,9 +7854,9 @@ fi rm -f conftest* echo $ac_n "checking for sysinfo""... $ac_c" 1>&6 -echo "configure:7471: checking for sysinfo" >&5 +echo "configure:7858: checking for sysinfo" >&5 cat > conftest.$ac_ext <<EOF -#line 7473 "configure" +#line 7860 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/sysinfo.h> @@ -7482,7 +7869,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:7486: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7873: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_SYSINFO 1 @@ -7497,9 +7884,9 @@ fi rm -f conftest* echo $ac_n "checking for sysconf""... $ac_c" 1>&6 -echo "configure:7501: checking for sysconf" >&5 +echo "configure:7888: checking for sysconf" >&5 cat > conftest.$ac_ext <<EOF -#line 7503 "configure" +#line 7890 "configure" #include "confdefs.h" #include <unistd.h> int main() { @@ -7508,7 +7895,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:7512: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7899: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_SYSCONF 1 @@ -7524,7 +7911,7 @@ rm -f conftest* echo $ac_n "checking size of int""... $ac_c" 1>&6 -echo "configure:7528: checking size of int" >&5 +echo "configure:7915: checking size of int" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7532,7 +7919,7 @@ else { echo "configure: error: failed to compile test program" 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 7536 "configure" +#line 7923 "configure" #include "confdefs.h" #include <stdio.h> main() @@ -7543,7 +7930,7 @@ else exit(0); } EOF -if { (eval echo configure:7547: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7934: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_int=`cat conftestval` else @@ -7564,7 +7951,7 @@ EOF echo $ac_n "checking whether memmove/bcopy/memcpy handle overlaps""... $ac_c" 1>&6 -echo "configure:7568: checking whether memmove/bcopy/memcpy handle overlaps" >&5 +echo "configure:7955: checking whether memmove/bcopy/memcpy handle overlaps" >&5 bcopy_test_prog=' main() { char buf[10]; @@ -7584,11 +7971,11 @@ if test "$cross_compiling" = yes; then { echo "configure: error: failed to compile test program" 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 7588 "configure" +#line 7975 "configure" #include "confdefs.h" #define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog EOF -if { (eval echo configure:7592: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then cat >> confdefs.h <<\EOF #define USEMEMMOVE 1 @@ -7602,11 +7989,11 @@ else { echo "configure: error: failed to compile test program" 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 7606 "configure" +#line 7993 "configure" #include "confdefs.h" #define mch_memmove(s,d,l) bcopy(d,s,l) $bcopy_test_prog EOF -if { (eval echo configure:7610: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then cat >> confdefs.h <<\EOF #define USEBCOPY 1 @@ -7620,11 +8007,11 @@ else { echo "configure: error: failed to compile test program" 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 7624 "configure" +#line 8011 "configure" #include "confdefs.h" #define mch_memmove(s,d,l) memcpy(d,s,l) $bcopy_test_prog EOF -if { (eval echo configure:7628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8015: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then cat >> confdefs.h <<\EOF #define USEMEMCPY 1 @@ -7656,19 +8043,19 @@ if test "$enable_multibyte" = "yes"; then CFLAGS="$CFLAGS -I$x_includes" LDFLAGS="$X_LIBS $LDFLAGS -lX11" echo $ac_n "checking whether X_LOCALE needed""... $ac_c" 1>&6 -echo "configure:7660: checking whether X_LOCALE needed" >&5 +echo "configure:8047: checking whether X_LOCALE needed" >&5 cat > conftest.$ac_ext <<EOF -#line 7662 "configure" +#line 8049 "configure" #include "confdefs.h" #include <X11/Xlocale.h> int main() { ; return 0; } EOF -if { (eval echo configure:7669: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:8056: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat > conftest.$ac_ext <<EOF -#line 7672 "configure" +#line 8059 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -7679,7 +8066,7 @@ int main() { _Xsetlocale() ; return 0; } EOF -if { (eval echo configure:7683: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF @@ -7706,7 +8093,7 @@ rm -f conftest* fi echo $ac_n "checking for _xpg4_setrunelocale in -lxpg4""... $ac_c" 1>&6 -echo "configure:7710: checking for _xpg4_setrunelocale in -lxpg4" >&5 +echo "configure:8097: checking for _xpg4_setrunelocale in -lxpg4" >&5 ac_lib_var=`echo xpg4'_'_xpg4_setrunelocale | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7714,7 +8101,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lxpg4 $LIBS" cat > conftest.$ac_ext <<EOF -#line 7718 "configure" +#line 8105 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -7725,7 +8112,7 @@ int main() { _xpg4_setrunelocale() ; return 0; } EOF -if { (eval echo configure:7729: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8116: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7747,7 +8134,7 @@ fi echo $ac_n "checking how to create tags""... $ac_c" 1>&6 -echo "configure:7751: checking how to create tags" >&5 +echo "configure:8138: checking how to create tags" >&5 test -f tags && mv tags tags.save if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&5 2>&1; then TAGPRG="ctags" @@ -7764,7 +8151,7 @@ test -f tags.save && mv tags.save tags echo "$ac_t""$TAGPRG" 1>&6 echo $ac_n "checking how to run man with a section nr""... $ac_c" 1>&6 -echo "configure:7768: checking how to run man with a section nr" >&5 +echo "configure:8155: checking how to run man with a section nr" >&5 MANDEF="man" (eval man -s 2 read) < /dev/null > /dev/null 2>&5 && MANDEF="man -s" echo "$ac_t""$MANDEF" 1>&6 @@ -7776,7 +8163,7 @@ EOF fi echo $ac_n "checking --disable-nls argument""... $ac_c" 1>&6 -echo "configure:7780: checking --disable-nls argument" >&5 +echo "configure:8167: checking --disable-nls argument" >&5 # Check whether --enable-nls or --disable-nls was given. if test "${enable_nls+set}" = set; then enableval="$enable_nls" @@ -7791,7 +8178,7 @@ if test "$enable_nls" = "yes"; then # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7795: checking for $ac_word" >&5 +echo "configure:8182: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_MSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7818,19 +8205,19 @@ else fi echo $ac_n "checking for NLS""... $ac_c" 1>&6 -echo "configure:7822: checking for NLS" >&5 +echo "configure:8209: checking for NLS" >&5 if test -f po/Makefile; then have_gettext="no" if test -n "$MSGFMT"; then cat > conftest.$ac_ext <<EOF -#line 7827 "configure" +#line 8214 "configure" #include "confdefs.h" #include <libintl.h> int main() { gettext("Test"); ; return 0; } EOF -if { (eval echo configure:7834: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8221: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""gettext() works" 1>&6; have_gettext="yes" else @@ -7840,14 +8227,14 @@ else olibs=$LIBS LIBS="$LIBS -lintl" cat > conftest.$ac_ext <<EOF -#line 7844 "configure" +#line 8231 "configure" #include "confdefs.h" #include <libintl.h> int main() { gettext("Test"); ; return 0; } EOF -if { (eval echo configure:7851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""gettext() works with -lintl" 1>&6; have_gettext="yes" else @@ -7873,12 +8260,12 @@ EOF for ac_func in bind_textdomain_codeset do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7877: checking for $ac_func" >&5 +echo "configure:8264: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 7882 "configure" +#line 8269 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -7901,7 +8288,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:7905: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8292: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7926,9 +8313,9 @@ fi done echo $ac_n "checking for _nl_msg_cat_cntr""... $ac_c" 1>&6 -echo "configure:7930: checking for _nl_msg_cat_cntr" >&5 +echo "configure:8317: checking for _nl_msg_cat_cntr" >&5 cat > conftest.$ac_ext <<EOF -#line 7932 "configure" +#line 8319 "configure" #include "confdefs.h" #include <libintl.h> extern int _nl_msg_cat_cntr; @@ -7936,7 +8323,7 @@ int main() { ++_nl_msg_cat_cntr; ; return 0; } EOF -if { (eval echo configure:7940: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8327: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF #define HAVE_NL_MSG_CAT_CNTR 1 @@ -7959,17 +8346,17 @@ fi ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6 -echo "configure:7963: checking for dlfcn.h" >&5 +echo "configure:8350: checking for dlfcn.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 7968 "configure" +#line 8355 "configure" #include "confdefs.h" #include <dlfcn.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:7973: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:8360: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -7990,17 +8377,17 @@ else echo "$ac_t""no" 1>&6 ac_safe=`echo "dl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for dl.h""... $ac_c" 1>&6 -echo "configure:7994: checking for dl.h" >&5 +echo "configure:8381: checking for dl.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 7999 "configure" +#line 8386 "configure" #include "confdefs.h" #include <dl.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:8004: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:8391: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -8029,9 +8416,9 @@ if test x${DLL} = xdlfcn.h; then EOF echo $ac_n "checking for dlopen()""... $ac_c" 1>&6 -echo "configure:8033: checking for dlopen()" >&5 +echo "configure:8420: checking for dlopen()" >&5 cat > conftest.$ac_ext <<EOF -#line 8035 "configure" +#line 8422 "configure" #include "confdefs.h" int main() { @@ -8041,7 +8428,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:8045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF @@ -8054,11 +8441,11 @@ else rm -rf conftest* echo "$ac_t""no" 1>&6; echo $ac_n "checking for dlopen() in -ldl""... $ac_c" 1>&6 -echo "configure:8058: checking for dlopen() in -ldl" >&5 +echo "configure:8445: checking for dlopen() in -ldl" >&5 olibs=$LIBS LIBS="$LIBS -ldl" cat > conftest.$ac_ext <<EOF -#line 8062 "configure" +#line 8449 "configure" #include "confdefs.h" int main() { @@ -8068,7 +8455,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:8072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF @@ -8086,9 +8473,9 @@ rm -f conftest* fi rm -f conftest* echo $ac_n "checking for dlsym()""... $ac_c" 1>&6 -echo "configure:8090: checking for dlsym()" >&5 +echo "configure:8477: checking for dlsym()" >&5 cat > conftest.$ac_ext <<EOF -#line 8092 "configure" +#line 8479 "configure" #include "confdefs.h" int main() { @@ -8098,7 +8485,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:8102: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF @@ -8111,11 +8498,11 @@ else rm -rf conftest* echo "$ac_t""no" 1>&6; echo $ac_n "checking for dlsym() in -ldl""... $ac_c" 1>&6 -echo "configure:8115: checking for dlsym() in -ldl" >&5 +echo "configure:8502: checking for dlsym() in -ldl" >&5 olibs=$LIBS LIBS="$LIBS -ldl" cat > conftest.$ac_ext <<EOF -#line 8119 "configure" +#line 8506 "configure" #include "confdefs.h" int main() { @@ -8125,7 +8512,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:8129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF @@ -8148,9 +8535,9 @@ elif test x${DLL} = xdl.h; then EOF echo $ac_n "checking for shl_load()""... $ac_c" 1>&6 -echo "configure:8152: checking for shl_load()" >&5 +echo "configure:8539: checking for shl_load()" >&5 cat > conftest.$ac_ext <<EOF -#line 8154 "configure" +#line 8541 "configure" #include "confdefs.h" int main() { @@ -8160,7 +8547,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:8164: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8551: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF @@ -8173,11 +8560,11 @@ else rm -rf conftest* echo "$ac_t""no" 1>&6; echo $ac_n "checking for shl_load() in -ldld""... $ac_c" 1>&6 -echo "configure:8177: checking for shl_load() in -ldld" >&5 +echo "configure:8564: checking for shl_load() in -ldld" >&5 olibs=$LIBS LIBS="$LIBS -ldld" cat > conftest.$ac_ext <<EOF -#line 8181 "configure" +#line 8568 "configure" #include "confdefs.h" int main() { @@ -8187,7 +8574,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:8191: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF @@ -8209,17 +8596,17 @@ for ac_hdr in setjmp.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:8213: checking for $ac_hdr" >&5 +echo "configure:8600: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 8218 "configure" +#line 8605 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:8223: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:8610: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -8256,7 +8643,7 @@ fi if test "x$MACOSX" = "xyes" && test "x$CARBON" = "xyes" \ && test "x$GUITYPE" != "xCARBONGUI"; then echo $ac_n "checking whether we need -framework Carbon""... $ac_c" 1>&6 -echo "configure:8260: checking whether we need -framework Carbon" >&5 +echo "configure:8647: checking whether we need -framework Carbon" >&5 if test "x$enable_multibyte" = "xyes" || test "x$features" == "xbig" \ || test "x$features" = "xhuge"; then LIBS="$LIBS -framework Carbon" @@ -8454,6 +8841,14 @@ s%@X_PRE_LIBS@%$X_PRE_LIBS%g s%@X_LIBS@%$X_LIBS%g s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g s%@X_LIB@%$X_LIB%g +s%@MOC@%$MOC%g +s%@KDE_CONFIG@%$KDE_CONFIG%g +s%@KDE_LIBS@%$KDE_LIBS%g +s%@KDE_INCLUDES@%$KDE_INCLUDES%g +s%@KDE_PREFIX@%$KDE_PREFIX%g +s%@QT_LIBS@%$QT_LIBS%g +s%@QT_INCLUDES@%$QT_INCLUDES%g +s%@ROOTQT@%$ROOTQT%g s%@GTK_CONFIG@%$GTK_CONFIG%g s%@GTK12_CONFIG@%$GTK12_CONFIG%g s%@PKG_CONFIG@%$PKG_CONFIG%g diff --git a/src/config.h.in b/src/config.h.in index bba26623c..1c888f470 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -312,6 +312,9 @@ /* Define if you use GTK and want GNOME support. */ #undef FEAT_GUI_GNOME +/* Define if you use KDE and want KDE Toolbar support. */ +#undef FEAT_KDETOOLBAR + /* Define if GTK+ 2 is available. */ #undef HAVE_GTK2 diff --git a/src/config.mk.in b/src/config.mk.in index 046649921..b5af74b53 100644 --- a/src/config.mk.in +++ b/src/config.mk.in @@ -124,6 +124,8 @@ NARROW_PROTO = @NARROW_PROTO@ GUI_X_LIBS = @GUI_X_LIBS@ MOTIF_LIBNAME = @MOTIF_LIBNAME@ GTK_LIBNAME = @GTK_LIBNAME@ +KDE_PREFIX = @KDE_PREFIX@ +MOC = @MOC@ ### Any OS dependent extra source and object file OS_EXTRA_SRC = @OS_EXTRA_SRC@ diff --git a/src/configure.in b/src/configure.in index 2c23e0611..1ebf82c18 100644 --- a/src/configure.in +++ b/src/configure.in @@ -982,7 +982,7 @@ test "x$with_x" = xno -a "x$BEOS" != "xyes" -a "x$MACOSX" != "xyes" -a "x$QNX" ! AC_MSG_CHECKING(--enable-gui argument) AC_ARG_ENABLE(gui, - [ --enable-gui[=OPTS] X11 GUI [default=auto] [OPTS=auto/no/gtk/gtk2/gnome/gnome2/motif/athena/neXtaw/beos/photon/carbon]], , enable_gui="auto") + [ --enable-gui[=OPTS] X11 GUI [default=auto] [OPTS=auto/no/gtk/gtk2/gnome/gnome2/kde/motif/athena/neXtaw/beos/photon/carbon]], , enable_gui="auto") dnl Canonicalize the --enable-gui= argument so that it can be easily compared. dnl Do not use character classes for portability with old tools. @@ -1039,7 +1039,6 @@ elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then else - case "$enable_gui_canon" in no|none) AC_MSG_RESULT(no GUI support) ;; yes|""|auto) AC_MSG_RESULT(yes/auto - automatic GUI support) @@ -1050,6 +1049,8 @@ else SKIP_ATHENA= SKIP_NEXTAW= SKIP_CARBON=;; + kde|Kde|KDE) AC_MSG_RESULT(KDE 2.x or 3.x GUI support) + SKIP_KDE=;; gtk) AC_MSG_RESULT(GTK+ 1.x GUI support) SKIP_GTK=;; gtk2) AC_MSG_RESULT(GTK+ 2.x GUI support) @@ -1073,6 +1074,17 @@ else fi +if test "x$SKIP_KDE" != "xYES" -a "$enable_gui_canon" != "kde"; then + AC_MSG_CHECKING(whether or not to look for KDE) + AC_ARG_ENABLE(kde-check, + [ --enable-kde-check If auto-select GUI, check for KDE [default=no]], + ,enable_kde_check="no") + AC_MSG_RESULT($enable_kde_check); + if test "x$enable_kde_check" = "xno"; then + SKIP_KDE=YES + fi +fi + if test "x$SKIP_GTK" != "xYES" -a "$enable_gui_canon" != "gtk" -a "$enable_gui_canon" != "gtk2"; then AC_MSG_CHECKING(whether or not to look for GTK) AC_ARG_ENABLE(gtk-check, @@ -1153,6 +1165,247 @@ if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then fi fi +dnl --------------------------------------------------------------------------- +dnl we use the kde-config script included in KDE since 2.x to check which +dnl version of KDE, we'll use. We'll use additional args in configure to +dnl obtain the QT directory (includes and libs) as qt does not give any +dnl config script ! (shame on the trolls ! ;p) +dnl --------------------------------------------------------------------------- + +if test -z "$SKIP_KDE"; then +dnl ------------------ +dnl now, take care of QT +dnl ----------------- +AC_ARG_WITH(qt-dir, + [ --with-qt-dir=DIR Specify prefix of QT files], + [ + ROOTQT="$withval" + MOC="$withval"/bin/moc + QT_INCLUDES="$withval"/include + QT_LIBS="$withval"/lib + ]) + +if test "x$ROOTQT" = "x"; then + if test -z "$QTDIR"; then + dnl Find the Qt directory by looking for the "moc" program. + dnl It's better than nothing. + AC_PATH_PROG(MOC, moc, no) + if text"x$MOC" = "x"; then + AC_MSG_ERROR(could not find Qt directory) + else + ROOTQT=`echo $MOC | sed 's+/bin/moc++'` + fi + else + ROOTQT="$QTDIR" + fi +fi +MOC="$ROOTQT"/bin/moc +QT_INCLUDES="$ROOTQT"/include +QT_LIBS="$ROOTQT"/lib + +AC_ARG_WITH(qt-includes, + [ --with-qt-includes=DIR Specify location of Qt headers], + [QT_INCLUDES="$withval"] + ) + +AC_ARG_WITH(qt-libraries, + [ --with-qt-libs=DIR Specify location of Qt libraries], + [QT_LIBS="$withval"] + ) + +if test "x$QT_LIBS" = "x" ; then + QT_LIBS="$ROOTQT"/lib +fi +if test "x$QT_INCLUDES" = "x" ; then + QT_INCLUDES="$ROOTQT"/include +fi +dnl we should get QT's version from here and compare with what kde-config +dnl says + +AC_MSG_CHECKING(whether or not to use a KDE Toolbar in KVim) +AC_ARG_ENABLE(kde-toolbar, + [ --enable-kde-toolbar if KDE GUI is selected, enable a KDE-look toolbar [default=no]], + , enable_kde_toolbar="no") +if test "x$enable_kde_toolbar" != "xno"; then + AC_DEFINE(FEAT_KDETOOLBAR) +fi +AC_MSG_RESULT($enable_kde_toolbar); +fi + +dnl ------------------- +dnl so, first, look up at the kde-config script +dnl ------------------ + +if test -z "$SKIP_KDE"; then +AC_DEFUN(AM_PATH_KDE, +[ + if test "X$KDE_CONFIG" != "X"; then + min_kde_version=ifelse([$1], ,2.0,[$1]) + AC_MSG_CHECKING(for KDE version >= $min_kde_version) + no_kde="" + if test "$KDE_CONFIG" = "no" ; then + no_kde=yes + else + KDE_PREFIX=`$KDE_CONFIG $kde_config_args --prefix` + if test "x$KDE_LIBS" = "x"; then + KDE_LIBS="$KDE_PREFIX/lib" + fi + if test "x$KDE_INCLUDES" = "x"; then + KDE_INCLUDES="$KDE_PREFIX/include" + fi + kde_major_version=`$KDE_CONFIG --version | grep KDE | \ +sed 's/KDE:\ //' | sed 's/\([[0-9]]*\).\([[0-9]]*.*\)/\1/'` + kde_minor_version=`$KDE_CONFIG --version | grep KDE | \ +sed 's/KDE:\ //' | sed 's/\([[0-9]]*\).\([[0-9]]*.*\)/\2/'` + + qt_major_version=`$KDE_CONFIG --version | grep Qt | sed -e \ +'s/Qt:\ //' | sed 's/\([[0-9]]*\).\([[0-9]]*.*\)/\1/'` + qt_minor_version=`$KDE_CONFIG --version | grep Qt | sed -e \ +'s/Qt:\ //' | sed 's/\([[0-9]]*\).\([[0-9]]*.*\)/\2/'` + + dnl maybe in a near future we'll get these ones : QT_PREFIX, QT_LIBS, + dnl QT_INCLUDES + dnl but for now we need configure options to get them ... + if test "x$enable-kdetest" = "xyes" ; then + ac_save_LIBS="$LIBS" + LIBS="$LIBS $KDE_LIBS" + + dnl fake test + AC_TRY_RUN([ +#include <stdio.h> +int +main() +{ return 0; } + ],, no_kde=yes,[echo $ac_n "cross compiling KDE ? ? how can i remove that ? :)"]) + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_kde" = x ; then + AC_MSG_RESULT(found KDE $kde_major_version.$kde_minor_version) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + KDE_LIBS="" + ifelse([$3], , :, [$3]) + fi +else + AC_MSG_RESULT(no) + KDE_LIBS="" + ifelse([$3], , :, [$3]) +fi +AC_SUBST(KDE_LIBS) +AC_SUBST(KDE_INCLUDES) +AC_SUBST(KDE_PREFIX) +]) + +dnl Check all the KDE stuff +AC_MSG_CHECKING(--disable-rpath argument) +AC_ARG_ENABLE(rpath, + [ --disable-rpath Disable rpath.], + , enable_rpath="yes") +if test "$enable_rpath" = "yes"; then + AC_MSG_RESULT(no) +else + AC_MSG_RESULT(yes) +fi + +AC_MSG_CHECKING(--with-kde-prefix argument) +AC_ARG_WITH(kde-prefix,[ --with-kde-prefix=PFX Prefix where KDE is installed (optional)],kde_config_prefix="$withval"; +AC_MSG_RESULT($kde_config_prefix), kde_config_prefix="";AC_MSG_RESULT(no)) + +AC_ARG_WITH(kde-includes, + [ --with-kde-includes=DIR Specify location of KDE headers], + [KDE_INCLUDES="$withval"] + ) + +AC_ARG_WITH(kde-libraries, + [ --with-kde-libs=DIR Specify location of KDE libraries], + [KDE_LIBS="$withval"] + ) + +AC_MSG_CHECKING(--disable-kdetest argument) +AC_ARG_ENABLE(kdetest, + [ --disable-kdetest Do not try to compile and run a test KDE program], + enable_kdetest=yes) + +if test "x$enable_kdetest" = "xyes" ; then + AC_MSG_RESULT(kde test enabled) +else + AC_MSG_RESULT(kde test disabled) +fi + +if test "x$kde_config_prefix" != "x" ; then + kde_config_args="" + KDE_CONFIG=$kde_config_prefix/bin/kde-config +fi + +if test "X$KDE_CONFIG" = "X"; then + AC_PATH_PROG(KDE_CONFIG, kde-config, no) +else + AC_MSG_RESULT(Using KDE configuration program $KDE_CONFIG) +fi + +if test "X$KDE_CONFIG" != "X" ; then + AM_PATH_KDE(2.0.0, + [GUI_LIB_LOC="-L$KDE_LIBS -lkdeui -lkdecore -lDCOP" + GUI_INC_LOC="-I$KDE_INCLUDES" + KDEDIR="$KDE_PREFIX"], ) + if test "x$KDE_PREFIX" != "x"; then + AC_MSG_CHECKING(for QT version $qt_major_version.x) + if test "x$ROOTQT" != "x" ; then + GUI_INC_LOC="-I$QT_INCLUDES $GUI_INC_LOC" + if test $qt_major_version -lt 2; then + AC_MSG_ERROR(Your QT version is prior to 2.0; KDE 2.x and 3.x require at least QT 2) + fi + dnl hack for FreeBSD + if test "`(uname) 2>/dev/null`" = "FreeBSD"; then + CFLAGS="$CFLAGS -D_THREAD_SAFE" + CXXFLAGS="$CXXFLAGS -D_THREAD_SAFE" + GUI_LIB_LOC="$GUI_LIB_LOC -pthread" + LIBS="$LIBS -pthread" + fi + + dnl check the version + if test "x$enable_rpath" = "xyes"; then + if test $qt_major_version = 2; then + GUI_LIB_LOC="-L$KDE_LIBS -lkfile -L$QT_LIBS -lqt $GUI_LIB_LOC \ +-Wl,--rpath -Wl,$KDE_LIBS -Wl,--rpath -Wl,$QT_LIBS" + else + GUI_LIB_LOC="-L$KDE_LIBS -lkio -L$QT_LIBS -lqt-mt $GUI_LIB_LOC \ +-Wl,--rpath -Wl,$KDE_LIBS -Wl,--rpath -Wl,$QT_LIBS" + fi + else + if test $qt_major_version = 2; then + GUI_LIB_LOC="-L$KDE_LIBS -lkfile -L$QT_LIBS -lqt $GUI_LIB_LOC" + else + GUI_LIB_LOC="-L$KDE_LIBS -lkio -L$QT_LIBS -lqt-mt $GUI_LIB_LOC" + fi + fi + + dnl Remove "-I/usr/include " from GUI_* + GUI_INC_LOC="`echo $GUI_INC_LOC\ | sed 's%-I/usr/include %%'`" +dnl GUI_LIB_LOC="`echo $GUI_LIB_LOC\ | sed 's% -L/usr/lib%%'`" + + AC_MSG_RESULT(found $qt_major_version.$qt_minor_version in $ROOTQT) + SKIP_GTK=YES + SKIP_ATHENA=YES + SKIP_MOTIF=YES + GUITYPE=KDE + AC_SUBST(KDE_PREFIX) + AC_SUBST(QT_LIBS) + AC_SUBST(QT_INCLUDES) + AC_SUBST(ROOTQT) + AC_SUBST(MOC) + AC_DEFINE(FEAT_GUI_KDE) + else + AC_MSG_ERROR(Detected QT version mismatched) + fi + else + AC_MSG_ERROR(Could not find KDE installation prefix) + fi +fi +fi + if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then AC_MSG_CHECKING(for Carbon GUI) dnl already did this @@ -1170,7 +1423,6 @@ if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then SKIP_CARBON=YES fi - dnl dnl Get the cflags and libraries from the gtk-config script dnl diff --git a/src/edit.c b/src/edit.c index 7619a5555..1adcda414 100644 --- a/src/edit.c +++ b/src/edit.c @@ -270,6 +270,23 @@ edit(cmdchar, startln, count) ins_compl_clear(); /* clear stuff for CTRL-X mode */ #endif +#ifdef FEAT_AUTOCMD + /* + * Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx". + */ + if (cmdchar != 'r' && cmdchar != 'v') + { + if (cmdchar == 'R') + ptr = (char_u *)"r"; + else if (cmdchar == 'V') + ptr = (char_u *)"v"; + else + ptr = (char_u *)"i"; + set_vim_var_string(VV_INSERTMODE, ptr, 1); + apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf); + } +#endif + #ifdef FEAT_MOUSE /* * When doing a paste with the middle mouse button, Insstart is set to @@ -725,6 +742,12 @@ edit(cmdchar, startln, count) break; } #endif +#ifdef FEAT_AUTOCMD + set_vim_var_string(VV_INSERTMODE, + (char_u *)((State & REPLACE_FLAG) ? "i" : + replaceState == VREPLACE ? "v" : "r"), 1); + apply_autocmds(EVENT_INSERTCHANGE, NULL, NULL, FALSE, curbuf); +#endif if (State & REPLACE_FLAG) State = INSERT | (State & LANGMAP); else @@ -859,7 +882,14 @@ doESCkey: o_lnum = curwin->w_cursor.lnum; if (ins_esc(&count, cmdchar)) + { +#ifdef FEAT_AUTOCMD + if (cmdchar != 'r' && cmdchar != 'v') + apply_autocmds(EVENT_INSERTLEAVE, NULL, NULL, + FALSE, curbuf); +#endif return (c == Ctrl_O); + } continue; /* diff --git a/src/eval.c b/src/eval.c index ce7bf0999..5e405157f 100644 --- a/src/eval.c +++ b/src/eval.c @@ -231,6 +231,7 @@ struct vimvar {"throwpoint", sizeof("throwpoint") - 1, NULL, VAR_STRING, VV_RO}, {"register", sizeof("register") - 1, NULL, VAR_STRING, VV_RO}, {"cmdbang", sizeof("cmdbang") - 1, NULL, VAR_NUMBER, VV_RO}, + {"insertmode", sizeof("insertmode") - 1, NULL, VAR_STRING, VV_RO}, }; static int eval0 __ARGS((char_u *arg, VAR retvar, char_u **nextcmd, int evaluate)); @@ -4877,6 +4878,9 @@ f_has(argvars, retvar) #ifdef FEAT_GUI_BEOS "gui_beos", #endif +#ifdef FEAT_GUI_KDE + "gui_kde", +#endif #ifdef FEAT_GUI_GTK "gui_gtk", # ifdef HAVE_GTK2 diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 67134820d..f9bd48773 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -447,7 +447,13 @@ dbg_parsearg(arg) vim_free(q); if (p == NULL) return FAIL; - bp->dbg_name = p; + if (*p != '*') + { + bp->dbg_name = fix_fname(p); + vim_free(p); + } + else + bp->dbg_name = p; #ifdef MACOS_CLASSIC if (bp->dbg_name != NULL) slash_n_colon_adjust(bp->dbg_name); diff --git a/src/ex_docmd.c b/src/ex_docmd.c index af8d3fc7c..27f4b9d3a 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -197,7 +197,7 @@ static void ex_tearoff __ARGS((exarg_T *eap)); #else # define ex_tearoff ex_ni #endif -#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU) +#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_KDE) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU) static void ex_popup __ARGS((exarg_T *eap)); #else # define ex_popup ex_ni @@ -205,11 +205,11 @@ static void ex_popup __ARGS((exarg_T *eap)); #ifndef FEAT_GUI_MSWIN # define ex_simalt ex_ni #endif -#if !defined(FEAT_GUI_MSWIN) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) +#if !defined(FEAT_GUI_MSWIN) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) && !defined(FEAT_GUI_KDE) # define gui_mch_find_dialog ex_ni # define gui_mch_replace_dialog ex_ni #endif -#ifndef FEAT_GUI_GTK +#if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_KDE) # define ex_helpfind ex_ni #endif #ifndef FEAT_CSCOPE @@ -258,7 +258,7 @@ static void ex_wincmd __ARGS((exarg_T *eap)); #else # define ex_wincmd ex_ni #endif -#if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) +#if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) static void ex_winpos __ARGS((exarg_T *eap)); #else # define ex_winpos ex_ni @@ -6719,7 +6719,7 @@ ex_tearoff(eap) } #endif -#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU) +#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_KDE) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU) static void ex_popup(eap) exarg_T *eap; @@ -7108,7 +7108,7 @@ ex_wincmd(eap) } #endif -#if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) +#if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) /* * ":winpos". */ @@ -7122,8 +7122,12 @@ ex_winpos(eap) if (*arg == NUL) { -# ifdef FEAT_GUI +# if defined(FEAT_GUI) || defined(MSWIN) +# ifdef FEAT_GUI if (gui.in_use && gui_mch_get_winpos(&x, &y) != FAIL) +# else + if (mch_get_winpos(&x, &y) != FAIL) +# endif { sprintf((char *)IObuff, _("Window position: X %d, Y %d"), x, y); msg(IObuff); @@ -7155,6 +7159,10 @@ ex_winpos(eap) # ifdef HAVE_TGETENT else # endif +# else +# ifdef MSWIN + mch_set_winpos(x, y); +# endif # endif # ifdef HAVE_TGETENT if (*T_CWP) diff --git a/src/feature.h b/src/feature.h index 725c0710a..8ebe94fd3 100644 --- a/src/feature.h +++ b/src/feature.h @@ -689,13 +689,16 @@ * always has it). But only if menus are enabled. */ #if defined(FEAT_NORMAL) && defined(FEAT_MENU) \ - && (defined(FEAT_GUI_GTK) \ + && (defined(FEAT_GUI_KDE) \ + || defined(FEAT_GUI_GTK) \ || defined(FEAT_GUI_MSWIN) \ || ((defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) \ && defined(HAVE_XPM)) \ || defined(FEAT_GUI_PHOTON)) # define FEAT_TOOLBAR #endif + + #if defined(FEAT_TOOLBAR) && !defined(FEAT_MENU) # define FEAT_MENU #endif @@ -706,7 +709,7 @@ * BROWSE_CURRBUF Open file browser in the directory of the current * buffer, instead of the current directory. */ -#if defined(FEAT_NORMAL) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC)) +#if defined(FEAT_NORMAL) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_KDE) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC)) # define FEAT_BROWSE #endif #if defined(FEAT_NORMAL) && defined(FEAT_GUI_MSWIN) @@ -724,7 +727,8 @@ || defined(FEAT_GUI_GTK) \ || defined(FEAT_GUI_PHOTON) \ || defined(FEAT_GUI_MSWIN) \ - || defined(FEAT_GUI_MAC) + || defined(FEAT_GUI_MAC) \ + || defined(FEAT_GUI_KDE) # define FEAT_CON_DIALOG # define FEAT_GUI_DIALOG # else @@ -732,13 +736,13 @@ # endif #endif #if !defined(FEAT_GUI_DIALOG) && (defined(FEAT_GUI_MOTIF) \ - || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK)) + || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) /* need a dialog to show error messages when starting from the desktop */ # define FEAT_GUI_DIALOG #endif #if defined(FEAT_GUI_DIALOG) && \ (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \ - || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN) \ + || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)|| defined(FEAT_GUI_MSWIN) \ || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC)) # define FEAT_GUI_TEXTDIALOG #endif @@ -931,7 +935,7 @@ * +X11 Unix only. Include code for xterm title saving and X * clipboard. Only works if HAVE_X11 is also defined. */ -#if defined(FEAT_NORMAL) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) +#if (defined(FEAT_NORMAL) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) # define WANT_X11 #endif @@ -1057,7 +1061,7 @@ # define MCH_CURSOR_SHAPE # endif # if defined(FEAT_GUI_W32) || defined(FEAT_GUI_W16) || defined(FEAT_GUI_MOTIF) \ - || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) \ + || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)\ || defined(FEAT_GUI_PHOTON) # define FEAT_MOUSESHAPE # endif diff --git a/src/fileio.c b/src/fileio.c index ce5ce41e0..92c1e98bb 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -6651,6 +6651,9 @@ static struct event_name {"FocusLost", EVENT_FOCUSLOST}, {"FuncUndefined", EVENT_FUNCUNDEFINED}, {"GUIEnter", EVENT_GUIENTER}, + {"InsertChange", EVENT_INSERTCHANGE}, + {"InsertEnter", EVENT_INSERTENTER}, + {"InsertLeave", EVENT_INSERTLEAVE}, {"RemoteReply", EVENT_REMOTEREPLY}, {"StdinReadPost", EVENT_STDINREADPOST}, {"StdinReadPre", EVENT_STDINREADPRE}, diff --git a/src/globals.h b/src/globals.h index 6f53317a6..8a59f1ccb 100644 --- a/src/globals.h +++ b/src/globals.h @@ -722,6 +722,10 @@ EXTERN int* (*iconv_errno) (void); #endif /* FEAT_MBYTE */ #ifdef FEAT_XIM +# ifdef FEAT_GUI_KDE +EXTERN colnr_T preedit_start_col INIT(= MAXCOL); +EXTERN char *draw_feedback INIT(= NULL); +# endif # ifdef FEAT_GUI_GTK # ifdef HAVE_GTK2 EXTERN GtkIMContext *xic INIT(= NULL); @@ -1112,6 +1116,10 @@ EXTERN guint32 gtk_socket_id INIT(= 0); EXTERN int echo_wid_arg INIT(= FALSE); /* --echo-wid argument */ #endif +#ifdef FEAT_GUI_KDE +EXTERN int echo_wid_arg INIT(= FALSE); +# endif + #ifdef FEAT_CLIENTSERVER EXTERN char_u *serverName INIT(= NULL); /* name of the server */ EXTERN int received_from_client INIT(= FALSE); /* received text from @@ -1321,7 +1329,7 @@ EXTERN char_u e_sandbox[] INIT(=N_("E48: Not allowed in sandbox")); #endif EXTERN char_u e_secure[] INIT(=N_("E523: Not allowed here")); #if defined(AMIGA) || defined(MACOS) || defined(MSWIN) || defined(RISCOS) \ - || defined(UNIX) || defined(VMS) + || defined(UNIX) || defined(VMS) || defined(OS2) EXTERN char_u e_screenmode[] INIT(=N_("E359: Screen mode setting not supported")); #endif EXTERN char_u e_scroll[] INIT(=N_("E49: Invalid scroll size")); @@ -97,7 +97,7 @@ gui_start() vim_free(old_term); -#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) +#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_KDE) if (gui.in_use) /* Display error messages in a dialog now. */ display_errors(); @@ -531,7 +531,7 @@ gui_init() /* Our GUI can't do bidi. */ p_tbidi = FALSE; #endif -#ifdef FEAT_GUI_GTK +#if defined FEAT_GUI_GTK || defined FEAT_GUI_KDE /* Give GTK+ a chance to put all widget's into place. */ gui_mch_update(); /* Now make sure the shell fits on the screen. */ @@ -575,7 +575,7 @@ gui_exit(rc) gui_mch_exit(rc); } -#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_MSWIN) \ +#if defined(FEAT_GUI_KDE) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_MSWIN) \ || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC) || defined(PROTO) /* * Called when the GUI shell is closed by the user. If there are no changed @@ -1058,7 +1058,7 @@ gui_update_cursor(force, clear_selection) void gui_position_menu() { -# if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) +# if !defined(FEAT_GUI_KDE) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) if (gui.menu_is_active && gui.in_use) gui_mch_set_menu_pos(0, 0, gui.menu_width, gui.menu_height); # endif @@ -1164,6 +1164,7 @@ gui_get_base_height() if (gui.menu_is_active) base_height += gui.menu_height; # endif +#ifndef FEAT_GUI_KDE # ifdef FEAT_TOOLBAR if (vim_strchr(p_go, GO_TOOLBAR) != NULL) # if defined(FEAT_GUI_MSWIN) && defined(FEAT_TOOLBAR) @@ -1172,6 +1173,7 @@ gui_get_base_height() base_height += gui.toolbar_height; # endif # endif +#endif # ifdef FEAT_FOOTER if (vim_strchr(p_go, GO_FOOTER) != NULL) base_height += gui.footer_height; @@ -1680,7 +1682,7 @@ gui_write(s, len) * We need to make sure this is cleared since Athena doesn't tell us when * he is done dragging. Do the same for GTK. */ -#if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) +#if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) gui.dragged_sb = SBAR_NONE; #endif @@ -2071,7 +2073,7 @@ gui_outstr_nowrap(s, len, flags, fg, bg, back) if (back != 0 && ((draw_flags & DRAW_BOLD) || (highlight_mask & HL_ITALIC))) return FAIL; -#if defined(RISCOS) || defined(HAVE_GTK2) +#if defined(RISCOS) || defined(HAVE_GTK2) || defined(FEAT_GUI_KDE) /* If there's no italic font, then fake it. * For GTK2, we don't need a different font for italic style. */ if (hl_mask_todo & HL_ITALIC) @@ -2141,7 +2143,7 @@ gui_outstr_nowrap(s, len, flags, fg, bg, back) /* 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) +# 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 @@ -2173,8 +2175,9 @@ gui_outstr_nowrap(s, len, flags, fg, bg, back) start += cl; } -# if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) - /* No fontset: draw a space to fill the gap after a wide char */ +# if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) + /* No fontset: draw a space to fill the gap after a wide char + * */ if (cn > 1 && (draw_flags & DRAW_TRANSP) == 0 # ifdef FEAT_XFONTSET && fontset == NOFONTSET @@ -4056,8 +4059,9 @@ gui_get_color(name) if (*name == NUL) return INVALCOLOR; t = gui_mch_get_color(name); + if (t == INVALCOLOR -#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) +#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) && gui.in_use #endif ) @@ -4183,7 +4187,6 @@ gui_mouse_moved(x, y) add_to_input_buf(st, 8); st[3] = (char_u)MOUSE_RELEASE; add_to_input_buf(st, 8); - #ifdef FEAT_GUI_GTK /* Need to wake up the main loop */ if (gtk_main_level() > 0) @@ -4301,7 +4304,7 @@ ex_gui(eap) } #if ((defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) \ - || defined(FEAT_GUI_PHOTON)) && defined(FEAT_TOOLBAR)) || defined(PROTO) + || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_KDE)) && defined(FEAT_TOOLBAR)) || defined(PROTO) /* * This is shared between Athena, Motif and GTK. */ @@ -4364,7 +4367,7 @@ gui_find_iconfile(name, buffer, ext) # endif #endif -#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(PROTO) +#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) || defined(FEAT_GUI_X11) || defined(PROTO) void display_errors() { @@ -4410,7 +4413,7 @@ no_console_input() #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MOTIF) \ || defined(MSWIN_FIND_REPLACE) || defined(FEAT_SUN_WORKSHOP) \ - || defined(PROTO) + || defined(PROTO) || defined(FEAT_GUI_KDE) /* * Update the current window and the screen. */ @@ -4428,7 +4431,7 @@ gui_update_screen() #endif #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MOTIF) \ - || defined(MSWIN_FIND_REPLACE) || defined(PROTO) + || defined(MSWIN_FIND_REPLACE) || defined(PROTO) || defined(FEAT_GUI_KDE) static void concat_esc __ARGS((garray_T *gap, char_u *text, int what)); /* @@ -30,6 +30,23 @@ # include "gui_beval.h" #endif +#ifdef FEAT_GUI_KDE +# include <X11/Intrinsic.h> + +/* used only as pointer to, so casting to int is ok */ +# ifdef __cplusplus +class QScrollBar; +class QPopupMenu; +class QFont; +class VimWidget; +# else +# define QScrollBar int +# define QPopupMenu int +# define QFont int +# define VimWidget int +# endif +#endif + #ifdef FEAT_GUI_GTK # include <X11/Intrinsic.h> # include <gtk/gtk.h> @@ -85,7 +102,7 @@ * GUIs that support dropping files on a running Vim. */ #if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MAC) \ - || defined(FEAT_GUI_BEOS) || defined(FEAT_GUI_GTK) + || defined(FEAT_GUI_BEOS) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) # define HAVE_DROP_FILE #endif @@ -152,7 +169,7 @@ #define DRAW_TRANSP 0x01 /* draw with transparant bg */ #define DRAW_BOLD 0x02 /* draw bold text */ #define DRAW_UNDERL 0x04 /* draw underline text */ -#if defined(RISCOS) || defined(HAVE_GTK2) +#if defined(RISCOS) || defined(HAVE_GTK2) || defined (FEAT_GUI_KDE) # define DRAW_ITALIC 0x08 /* draw italic text */ #endif #define DRAW_CURSOR 0x10 /* drawing block cursor (win32) */ @@ -171,7 +188,7 @@ #endif #define TOOLBAR_BORDER_HEIGHT 12 /* room above+below buttons for MSWindows */ -#if defined(NO_CONSOLE) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) +#if defined(NO_CONSOLE) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) || defined(FEAT_GUI_X11) # define NO_CONSOLE_INPUT /* use no_console_input() to check if there is no console input possible */ #endif @@ -195,6 +212,9 @@ typedef struct GuiScrollbar int width; /* Current width of scroll bar in cols */ #endif int status_height; /* Height of status line */ +#ifdef FEAT_GUI_KDE + QScrollBar *w; +#endif #ifdef FEAT_GUI_X11 Widget id; /* Id of real scroll bar */ #endif @@ -231,6 +251,12 @@ typedef long guicolor_T; /* handle for a GUI color; for X11 this should displays there is a tiny chance this is an actual color */ +#ifdef FEAT_GUI_KDE + typedef QFont *GuiFont; + typedef QFont *GuiFontset; +# define NOFONT (GuiFont)NULL +# define NOFONTSET (GuiFontset)NULL +#endif #ifdef FEAT_GUI_GTK # ifdef HAVE_GTK2 typedef PangoFontDescription *GuiFont; /* handle for a GUI font */ @@ -254,10 +280,12 @@ typedef long guicolor_T; /* handle for a GUI color; for X11 this should # define NOFONT (GuiFont)0 # define NOFONTSET (GuiFontset)0 # else +# if !defined(FEAT_GUI_KDE) typedef long_u GuiFont; /* handle for a GUI font */ typedef long_u GuiFontset; /* handle for a GUI fontset */ # define NOFONT (GuiFont)0 # define NOFONTSET (GuiFontset)0 +# endif # endif # endif #endif @@ -375,6 +403,13 @@ typedef struct Gui Bool color_approx; /* Some color was approximated */ #endif +#ifdef FEAT_GUI_KDE + VimWidget *w; /* Vim widget */ + Display *dpy; /* X display */ + QFont *current_font; + char_u *fontname; /* font name from font selection dialog */ +#endif + #ifdef FEAT_GUI_GTK int visibility; /* Is shell partially/fully obscured? */ GdkCursor *blank_pointer; /* Blank pointer */ @@ -507,7 +542,7 @@ typedef enum } gui_win_pos_T; -#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ +#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) \ || defined(MSWIN_FIND_REPLACE) /* * Flags used to distinguish the different contexts in which the diff --git a/src/gui_kde.cc b/src/gui_kde.cc new file mode 100644 index 000000000..772e45792 --- /dev/null +++ b/src/gui_kde.cc @@ -0,0 +1,587 @@ +/* vi:set ts=8 sts=0 sw=8: + * + * VIM - Vi IMproved by Bram Moolenaar + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + */ + +/* + * Porting to KDE(2) was done by + * + * (C) 2000 by Thomas Capricelli <orzel@freehackers.org> + * + * Please visit http://freehackers.org/kvim for other vim- or + * kde-related coding. + * + * $Id$ + * + */ +#include <assert.h> +#include <errno.h> +#include <string.h> +#include <kmenubar.h> +#include <kfiledialog.h> +#include <kiconloader.h> + +#include <qscrollbar.h> +#include <qcursor.h> +#include <qmessagebox.h> +#include <qiconset.h> +#include <qtextcodec.h> +#include "gui_kde_widget.h" + +extern "C" { +#include "vim.h" +} + +#undef dbf +#undef db +#undef mputs + +#if 1 +#define dbf( format, args... ) { printf( "%s" " : " format "\n" , __FUNCTION__ , ## args ); fflush(stdout); } +#define db() { printf( "%s\n", __FUNCTION__ );fflush(stdout); } +#else +#define dbf(format, args... ) +#define db() +#endif + + +#ifdef FEAT_TOOLBAR +#ifndef FEAT_KDETOOLBAR +/* + * Icons used by the toolbar code. + *///{{{ +#include "../pixmaps/tb_new.xpm" +#include "../pixmaps/tb_open.xpm" +#include "../pixmaps/tb_close.xpm" +#include "../pixmaps/tb_save.xpm" +#include "../pixmaps/tb_print.xpm" +#include "../pixmaps/tb_cut.xpm" +#include "../pixmaps/tb_copy.xpm" +#include "../pixmaps/tb_paste.xpm" +#include "../pixmaps/tb_find.xpm" +#include "../pixmaps/tb_find_next.xpm" +#include "../pixmaps/tb_find_prev.xpm" +#include "../pixmaps/tb_find_help.xpm" +#include "../pixmaps/tb_exit.xpm" +#include "../pixmaps/tb_undo.xpm" +#include "../pixmaps/tb_redo.xpm" +#include "../pixmaps/tb_help.xpm" +#include "../pixmaps/tb_macro.xpm" +#include "../pixmaps/tb_make.xpm" +#include "../pixmaps/tb_save_all.xpm" +#include "../pixmaps/tb_jump.xpm" +#include "../pixmaps/tb_ctags.xpm" +#include "../pixmaps/tb_load_session.xpm" +#include "../pixmaps/tb_save_session.xpm" +#include "../pixmaps/tb_new_session.xpm" +#include "../pixmaps/tb_blank.xpm" +#include "../pixmaps/tb_maximize.xpm" +#include "../pixmaps/tb_split.xpm" +#include "../pixmaps/tb_minimize.xpm" +#include "../pixmaps/tb_shell.xpm" +#include "../pixmaps/tb_replace.xpm" +#include "../pixmaps/tb_vsplit.xpm" +#include "../pixmaps/tb_maxwidth.xpm" +#include "../pixmaps/tb_minwidth.xpm" +//}}} +/* + * These are the pixmaps used for the default buttons. + * Order must exactly match toolbar_names[] in menu.c! + *///{{{ +static char **(built_in_pixmaps[]) = +{ + tb_new_xpm, + tb_open_xpm, + tb_save_xpm, + tb_undo_xpm, + tb_redo_xpm, + tb_cut_xpm, + tb_copy_xpm, + tb_paste_xpm, + tb_print_xpm, + tb_help_xpm, + tb_find_xpm, + tb_save_all_xpm, + tb_save_session_xpm, + tb_new_session_xpm, + tb_load_session_xpm, + tb_macro_xpm, + tb_replace_xpm, + tb_close_xpm, + tb_maximize_xpm, + tb_minimize_xpm, + tb_split_xpm, + tb_shell_xpm, + tb_find_prev_xpm, + tb_find_next_xpm, + tb_find_help_xpm, + tb_make_xpm, + tb_jump_xpm, + tb_ctags_xpm, + tb_vsplit_xpm, + tb_maxwidth_xpm, + tb_minwidth_xpm, + tb_exit_xpm +};//}}} +#else +const char *kdeicons[] = { + "filenew", + "fileopen", + "filesave", + "undo", + "redo", + "editcut", + "editcopy", + "editpaste", + "fileprint", + "contents2", + "filefind", + "save_all", + "fileexport", + "filenew", + "fileimport", + "run", + "edit", + "fileclose", + "", + "", + "split", + "openterm", + "previous", + "next", + "help", + "make", + "goto", + "run", + "vsplit", + "maxwidth", + "minwidth", + "quit" +}; +#endif +/* + * creates a blank pixmap using tb_blank + */ + QPixmap +pixmap_create_from_xpm(char **xpm)//{{{ +{ + return(QPixmap((const char **)xpm)); +}//}}} + +/* + * creates a pixmap by using a built-in number + */ + QPixmap +pixmap_create_by_num(int pixmap_num)//{{{ +{ +#ifdef FEAT_KDETOOLBAR + if (pixmap_num >= 0 && (unsigned)pixmap_num < (sizeof(kdeicons) + / sizeof(kdeicons[0])) - 1) { + + KIconLoader *il = kapp->iconLoader(); //new KIconLoader(); + QString icon; + icon=QString(kdeicons[pixmap_num]); + return il->loadIcon(icon,KIcon::MainToolbar); + } + return QPixmap(); +#else + if (pixmap_num >= 0 && (unsigned)pixmap_num < (sizeof(built_in_pixmaps) + / sizeof(built_in_pixmaps[0])) - 1) + return pixmap_create_from_xpm(built_in_pixmaps[pixmap_num]); + else return QPixmap(); +#endif +}//}}} + +/* + * Creates a pixmap by using the pixmap "name" found in 'runtimepath'/bitmaps/ + */ + QPixmap +pixmap_create_by_dir(char_u *name)//{{{ +{ + char_u full_pathname[MAXPATHL + 1]; + + if (gui_find_bitmap(name, full_pathname, "xpm") == OK) { + return QPixmap((const char *)full_pathname); + } + else return QPixmap(); +}//}}} + + + QPixmap +pixmap_create_from_file(char_u *file) +{ + return QPixmap((const char*)file); +} +#endif + + void +gui_mch_add_menu(vimmenu_T * menu, int idx)//{{{ +{ +#ifdef FEAT_MENU + QPopupMenu *me; + vimmenu_T *parent = menu->parent; + + if (menu_is_popup(menu->name)) { + menu->widget = new QPopupMenu(vmw , (const char *) menu->name); + QObject::connect( menu->widget, SIGNAL(activated(int)), vmw, SLOT(menu_activated(int)) ); + return; + } + + if (!menu_is_menubar(menu->name)) + 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); + } else { + me = new QPopupMenu(vmw->menuBar() , (const char *) menu->name); + vmw->menuBar()->insertItem( QString((const char *)menu->name), me , (int) me, idx); + } + + me->setCaption((const char*)( menu->dname )); + if (vmw->have_tearoff) me->insertTearOffHandle(0,0); + QObject::connect( me, SIGNAL(activated(int)), vmw, SLOT(menu_activated(int)) ); + menu->widget = me; +#endif +}//}}} + + + void +gui_mch_add_menu_item(vimmenu_T * menu, int idx)//{{{ +{ +#ifdef FEAT_MENU + vimmenu_T *parent = menu->parent; +#ifdef FEAT_TOOLBAR + if (menu_is_toolbar(parent->name)) { + QPixmap pix; + if ( menu_is_separator(menu->name) ) + { + vmw->toolBar()->insertSeparator(); + return; + } + if (menu->iconfile != NULL) { + pix = pixmap_create_from_file(menu->iconfile); + } + if (!menu->icon_builtin) { + pix = pixmap_create_by_dir(menu->name); + } + if (pix.isNull() && menu->iconidx >= 0) { + pix = pixmap_create_by_num(menu->iconidx); + } +#ifndef FEAT_KDETOOLBAR + if (pix.isNull()) { + pix = pixmap_create_from_xpm(tb_blank_xpm); + } +#endif + if (pix.isNull()) return; // failed + vmw->toolBar()->insertButton ( + pix, + (int) menu , // id + true, + (char *) (menu->strings[MENU_INDEX_TIP]) , // tooltip or text + idx + ); + menu->parent=parent; + return; + } +#endif // FEAT_TOOLBAR + + idx++; + if ( menu_is_separator(menu->name) ) { + parent->widget->insertSeparator(); + return; + } + parent->widget->insertItem(QString((const char *)menu->name), (int)menu, idx ); +#endif +}//}}} + + + void +gui_mch_set_text_area_pos(int x, int y, int w, int h)//{{{ +{ + int X = 0; + int Y = 0; + if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled() +#if QT_VERSION>=300 + && !vmw->menuBar()->isTopLevelMenu() +#endif + ) + Y += vmw->menuBar()->height(); +#ifdef FEAT_TOOLBAR + if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() && + vmw->toolBar()->barPos()==KToolBar::Top) + Y += vmw->toolBar()->height(); + + if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() && + vmw->toolBar()->barPos()==KToolBar::Left) + X += vmw->toolBar()->width(); +#endif // FEAT_TOOLBAR + + gui.w->setGeometry(x+X,y+Y,w,h); +}//}}} + + +#if defined(FEAT_MENU) || defined(PROTO) +/* + * Enable or disable mnemonics for the toplevel menus. + */ + void +gui_gtk_set_mnemonics(int enable)//{{{ // TO BE REMOVED +{ +}//}}} + + void +toggle_tearoffs(vimmenu_T *menu, int enable)//{{{ +{ + while (menu != NULL) { + if (!menu_is_popup(menu->name)) { + if (menu->widget != 0) { + if (enable) menu->widget->insertTearOffHandle(0,0); + else menu->widget->removeItem(0); + } + toggle_tearoffs(menu->children, enable); + } + menu = menu->next; + } +}//}}} + + void +gui_mch_toggle_tearoffs(int enable)//{{{ +{ + vmw->have_tearoff=enable; + toggle_tearoffs(root_menu, enable); +}//}}} +#endif + + +#if defined(FEAT_MENU) || defined(PROTO) +/* + * Destroy the machine specific menu widget. + */ + void +gui_mch_destroy_menu(vimmenu_T * menu)//{{{ +{ +#ifdef FEAT_TOOLBAR + if (menu->parent && menu_is_toolbar(menu->parent->name)) { + vmw->toolBar()->removeItem( (int) menu ); + return; + } +#endif + if(menu->parent){ + menu->parent->widget->removeItem((int)menu ); + } + if (menu->widget){ + delete menu->widget; + } + menu->widget = 0; +}//}}} +#endif /* FEAT_MENU */ + + +/* + * Scrollbar stuff. + */ + + void +gui_mch_set_scrollbar_thumb(scrollbar_T * sb, long val, long size, long max)//{{{ +{ + if (!sb->w) return; + + sb->w->setRange(0, max+1-size); + sb->w->setValue(val); + + sb->w->setLineStep(1); + sb->w->setPageStep(size); +}//}}} + + void +gui_mch_set_scrollbar_pos(scrollbar_T * sb, int x, int y, int w, int h)//{{{ +{ + if (!sb->w) return; + //we add the menubar and toolbar height/width + int X = 0; + int Y = 0; + + if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled() +#if QT_VERSION>=300 + && !vmw->menuBar()->isTopLevelMenu() +#endif + ) + Y += vmw->menuBar()->height(); +#ifdef FEAT_TOOLBAR + if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() && + vmw->toolBar()->barPos()==KToolBar::Top) + Y += vmw->toolBar()->height(); + + if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() && + vmw->toolBar()->barPos()==KToolBar::Left) + X += vmw->toolBar()->width(); +#endif //FEAT_TOOLBAR + if (sb->w->orientation() == Qt::Vertical) { + bool leftscroll=gui.which_scrollbars[SBAR_LEFT]; + bool rightscroll=gui.which_scrollbars[SBAR_RIGHT]; + if (x<20) leftscroll=true; + else rightscroll=true; + if (x<20) sb->w->setGeometry(X,y+Y,w,h); + else sb->w->setGeometry(vmw->width()-w-1+X, y+Y,w,h); + } else { + sb->w->setGeometry(x+X,y+Y,w,h); + } +}//}}} + +/* SBAR_VERT or SBAR_HORIZ */ + void +gui_mch_create_scrollbar(scrollbar_T * sb, int orient)//{{{ +{ + sbpool->create(sb,orient); + if (orient==SBAR_VERT) + gui.scrollbar_width = sb->w->sizeHint().width(); + else + gui.scrollbar_height = sb->w->sizeHint().height(); +}//}}} + + void +gui_mch_destroy_scrollbar(scrollbar_T * sb)//{{{ +{ + sbpool->destroy(sb); +}//}}} + +#if defined(FEAT_BROWSE) || defined(PROTO) +/* + * Implementation of the file selector related stuff + */ + +/* + * Put up a file requester. + * Returns the selected name in allocated memory, or NULL for Cancel. + * saving, select file to write + * title title for the window + * dflt default name + * ext not used (extension added) + * initdir initial directory, NULL for current dir + * filter not used (file name filter) + */ +/*ARGSUSED*/ +char_u * +gui_mch_browse(int saving,//{{{ + char_u * title, + char_u * dflt, + char_u * ext, + char_u * initdir, + char_u * filter) +{ + char * filt_glob; + if (filter != (char_u *) 0x0 ) { + filter = vim_strsave(filter); + strtok((char *) filter, "("); + filt_glob = strtok(0L, ")"); + } else + filt_glob = (char *) filter; + + gui_mch_mousehide(FALSE); + + QString s; + if (! saving) + s = KFileDialog::getOpenFileName( (char *) initdir, (char *) filt_glob, vmw, (char *) title ); + else + s = KFileDialog::getSaveFileName( ); + + if (filter) + vim_free(filter); + + if (s.isNull()) + return NULL; + QCString unistring = vmw->codec->fromUnicode(s); + char_u * s2 = (char_u *)(const char*)unistring; + if (s2) + s2 = vim_strsave( s2 ); + + return s2; +}//}}} + +#endif /* FEAT_BROWSE */ + +#ifdef FEAT_GUI_DIALOG + +/* ARGSUSED */ +int +gui_mch_dialog(int type, /* type of dialog *///{{{ + char_u * title, /* title of dialog */ + char_u * message, /* message text */ + char_u * buttons, /* names of buttons */ + int def_but, /* default button */ + char_u *textfield) +{ + gui_mch_mousehide(FALSE); + VimDialog vd(type, title, message, buttons, def_but,textfield); + int ret = vd.exec(); + return ret; +}//}}} + + +#endif /* FEAT_GUI_DIALOG */ + +#if defined(FEAT_MENU) || defined(PROTO) + void +gui_mch_show_popupmenu(vimmenu_T * menu)//{{{ +{ + menu->widget->popup(QCursor::pos()); +}//}}} + +void +gui_make_popup (char_u *pathname) {//{{{ + vimmenu_T *menu = gui_find_menu(pathname); + + if (menu != NULL) { + menu->widget->popup(QCursor::pos()); + } +}//}}} +#endif + + + +/* Find and Replace implementations */ + void +gui_mch_find_dialog(exarg_T * eap)//{{{ +{ + // char_u* entry_text; + //int exact_word=FALSE; + // entry_text = get_find_dialog_text(eap->arg,&exact_word); + + vmw->finddlg->setCaseSensitive(true); + + /* if(entry_text!=NULL) { + vmw->finddlg->setText(QString((char*)entry_text)); + // exact match should go there, hopefully KDE old KEdFind/KEdReplace will be replaced in KDE 4 as pple wanted KDE 3's Find/Replace to be kept + }*/ // Don't use it, KDE keeps old search in memory and vim give \\Csearch, which is difficult to handle + // vim_free(entry_text); + + vmw->finddlg->show(); +}//}}} + + void +gui_mch_replace_dialog(exarg_T * eap)//{{{ +{ + // char_u* entry_text; + //int exact_word=FALSE; + + // entry_text = get_find_dialog_text(eap->arg,&exact_word); + + /* if(entry_text!=NULL) { + vmw->repldlg->setText(QString((char*)entry_text)); + // exact match should go there, hopefully KDE old KEdFind/KEdReplace will be replaced in KDE 4 as pple wanted KDE 3's Find/Replace to be kept + }*/ + //vim_free(entry_text); + + vmw->repldlg->show(); +}//}}} + + void +ex_helpfind(exarg_T *eap)//{{{ +{ + do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp"); +}//}}} diff --git a/src/gui_kde_widget.cc b/src/gui_kde_widget.cc new file mode 100644 index 000000000..c2e9e7ca8 --- /dev/null +++ b/src/gui_kde_widget.cc @@ -0,0 +1,1396 @@ +/* vi:set ts=8 sts=4 sw=4: + * + * VIM - Vi IMproved by Bram Moolenaar + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + */ + +/* + * Porting to KDE(2) was done by + * + * (C) 2000 by Thomas Capricelli <orzel@freehackers.org> + * + * Please visit http://freehackers.org/kvim for other vim- or + * kde-related coding. + * + * $Id$ + * + */ + +#include <assert.h> +#include <qpainter.h> +#include <qevent.h> +#include <qpushbutton.h> +#include <qscrollbar.h> +#include <qlayout.h> +#include <qclipboard.h> +#include <qdragobject.h> +#include <qstrlist.h> +#include <qmenubar.h> +#include <qtextcodec.h> +#if QT_VERSION>=300 +#include <qptrlist.h> +#include <ktip.h> +#endif +#include <kglobal.h> +#include <kconfig.h> +#include <kaboutapplication.h> +#include <dcopclient.h> +#include <kaboutkde.h> +#include <kbugreport.h> +#include <kurldrag.h> +#include <kmenubar.h> +#include <ktoolbar.h> +#include <kstandarddirs.h> +#include "gui_kde_widget.h" +#include <qxembed.h> + +extern "C" { +#include "version.h" +} + +// Pixmap for dialog +#ifdef FEAT_GUI_DIALOG +# include "../../pixmaps/alert.xpm" +# include "../../pixmaps/error.xpm" +# include "../../pixmaps/generic.xpm" +# include "../../pixmaps/info.xpm" +# include "../../pixmaps/quest.xpm" +#endif + +/** + * Keycodes recognized by vim. + */ +struct special_key {//{{{ + int qtkey; + char_u code0; + 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_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'}, + /* End of list marker: */ + { 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); +#endif +void gui_keypress(QKeyEvent *e); + +/* + * Return OK if the key with the termcap name "name" is supported. + */ + int +gui_mch_haskey(char_u * name)//{{{ +{ + for (int i=0; special_keys[i].qtkey != 0; i++) + if (name[0] == special_keys[i].code0 && + name[1] == special_keys[i].code1) + return OK; + return FAIL; +}//}}} + +/* + * custom Frame for drawing ... + */ +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)//{{{ +{ + 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->setFont( *(gui.current_font) ); + painter->drawText( x, y, s, len); +}//}}} + +void VimWidget::mousePressEvent(QMouseEvent *event)//{{{ +{ + int button=0; + int modifiers=0; + ButtonState state = event->state(); + ButtonState buttons = event->button(); + + //Look at button states + if(buttons & QMouseEvent::LeftButton) { + button|=MOUSE_LEFT; + } + if(buttons & QMouseEvent::RightButton) { + button|=MOUSE_RIGHT; + } + if(buttons & QMouseEvent::MidButton) { + button|=MOUSE_MIDDLE; + } + //Look for keyboard modifiers + if(state & QMouseEvent::ShiftButton) { + modifiers|=MOUSE_SHIFT; + } + if(state & QMouseEvent::ControlButton){ + modifiers|=MOUSE_CTRL; + } + if(state & QMouseEvent::AltButton){ + modifiers|=MOUSE_ALT; + } + 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); +#endif + event->accept(); +}//}}} + +#if defined(FEAT_SESSION) +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' + //when restoring app, we source this file +#if 0 //disabled for release + QString filename = KGlobal::dirs()->localkdedir() + KGlobal::dirs()->kde_default("config") + kapp->randomString(10); + QString cmd("mksession "); + cmd+=filename; + do_cmdline_cmd((char_u*)cmd.latin1()); + conf->writePathEntry("sessionfile", filename); + conf->sync(); +#endif +} + +void VimMainWindow::readGlobalProperties (KConfig *conf) +{ +#if 0 + QString filename = conf->readPathEntry("sessionfile"); + if (filename.isNull()) return; + QString cmd("source "); + cmd+=filename; + do_cmdline_cmd((char_u*)cmd.latin1()); +#endif +} +#endif + +void VimMainWindow::wheelEvent (QWheelEvent *event)//{{{ +{ + ButtonState state = event->state(); + int button=0; + int modifiers=0; + + if (event->delta()>0) + button|=MOUSE_4; + else button|=MOUSE_5; + + if(state & ShiftButton) + modifiers|=MOUSE_SHIFT; + if(state & ControlButton) + modifiers|=MOUSE_CTRL; + if(state & AltButton) + modifiers|=MOUSE_ALT; + + 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); +#endif + event->accept(); +}//}}} + +void VimWidget::mouseDoubleClickEvent(QMouseEvent *event)//{{{ +{ + ButtonState state = event->state(); + ButtonState buttons = event->button(); + int modifiers=0; + int button=0; + + //Look at button states + if(buttons & LeftButton) + button|=MOUSE_LEFT; + if(buttons & RightButton) + button|=MOUSE_RIGHT; + if(buttons & MidButton) + button|=MOUSE_MIDDLE; + + //Look for keyboard modifiers + if(state & ShiftButton) + modifiers|=MOUSE_SHIFT; + if(state & ControlButton) + modifiers|=MOUSE_CTRL; + if(state & AltButton) + modifiers|=MOUSE_ALT; + + 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); +#endif + event->accept(); +}//}}} + +void VimWidget::mouseMoveEvent(QMouseEvent *event){//{{{ + ButtonState state = event->state(); + 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; + + //Look for keyboard modifiers + if(state & ShiftButton) + modifiers|=MOUSE_SHIFT; + if(state & ControlButton) + modifiers|=MOUSE_CTRL; + if(state & AltButton) + 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); +}//}}} + +void VimWidget::mouseReleaseEvent(QMouseEvent *event)//{{{ +{ + ButtonState state = event->state(); + int modifiers=0; + + //Look for keyboard modifiers + if(state & ShiftButton) + modifiers|=MOUSE_SHIFT; + if(state & ControlButton) + modifiers|=MOUSE_CTRL; + if(state & AltButton) + modifiers|=MOUSE_ALT; + + 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") +{ + //to be able to show/hide the cursor when moving the mouse + setMouseTracking(true); + painter=new QPainter(this); + + setKeyCompression(true); + 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() )); +}//}}} + +void VimWidget::execNormal(QString command)//{{{ +{ + QString cmd("execute 'normal "); + 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)//{{{ +{ + QString cmd("execute 'normal i"); + 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)//{{{ +{ + QString cmd("execute '"); + 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)//{{{ +{ + QCString unistring = vmw->codec->fromUnicode(command); + do_cmdline_cmd((char_u *)(const char*)unistring); + gui_update_screen(); +}//}}} + +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)); + return val; +#else + return QString::null; +#endif +}//}}} + +void VimWidget::wait(long wtime)//{{{ +{ + if ( wait_timer.isActive() ) wait_timer.stop(); + wait_done = false; + wait_timer.start( wtime, true); +}//}}} + +void VimWidget::wait_timeout() //{{{ +{ + wait_done = true; +}//}}} + +void VimWidget::dragEnterEvent (QDragEnterEvent *e)//{{{ +{ +#if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO) + e->accept(QUriDrag::canDecode(e)); +#else + e->ignore(); +#endif +}//}}} + +void VimWidget::dropEvent (QDropEvent *e) // {{{ +{ +#if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO) + QStrList urls; + + char_u **fnames; + int redo_dirs = FALSE; + int i; + int n; + int nfiles; + int url = FALSE; + + /* Count how many items there may be and normalize delimiters. */ + + if (QUriDrag::decode(e, urls)) { + n = urls.count(); + fnames = (char_u **)lalloc((n+1) * sizeof(char_u *), TRUE); + nfiles = 0; +#if QT_VERSION>=300 + QPtrListIterator<char> it(urls); + for( ; it.current(); ++it ) { + KURL u(*it); +#else + for (i=0;i<urls.count();++i) { + KURL u(urls.at(i)); +#endif + if ( !u.isLocalFile() ) + url = TRUE; + else { + fnames[nfiles] = (char_u *)strdup((const char *)u.path()); + ++nfiles; + } + } + /* Real files (i.e. not http and not ftp) */ + if (url == FALSE) + { + if (nfiles == 1) + { + if (mch_isdir(fnames[0])) + { + /* Handle dropping a directory on Vim. */ + if (mch_chdir((char *)fnames[0]) == 0) + { + free(fnames[0]); + fnames[0] = NULL; + redo_dirs = TRUE; + } + } + } else { + /* Ignore any directories */ + for (i = 0; i < nfiles; ++i) + { + if (mch_isdir(fnames[i])) + { + vim_free(fnames[i]); + fnames[i] = NULL; + } + } + } + + if (0) + { + /* Shift held down, change to first file's directory */ + if (fnames[0] != NULL && vim_chdirfile(fnames[0]) == OK) + redo_dirs = 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) + { + s = shorten_fname(fnames[i], dirname); + if (s != NULL && (s = vim_strsave(s)) != NULL) + { + vim_free(fnames[i]); + fnames[i] = s; + } + } + } + } + + /* Handle the drop, :edit or :split to get to the file */ + handle_drop(nfiles, fnames, FALSE); + + if (redo_dirs) + shorten_fnames(TRUE); + } + + /* Update the screen display */ + update_screen(NOT_VALID); +#ifdef FEAT_MENU + gui_update_menus(0); +#endif + setcursor(); + out_flush(); + gui_update_cursor(FALSE, FALSE); + gui_mch_flush(); +#endif +} // }}} + +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; + Qt::ButtonState state = e->state(); + + 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(); + + // 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 ) { + e->ignore(); + return; + } + +#ifdef FEAT_MBYTE + if (input_conv.vc_type != CONV_NONE) + { + mch_memmove(string2, string, len); + len = convert_input(string2, len, sizeof(string2)); + s = string2; + } + else +#endif + s = string; + d = string; + for (i = 0; i < len; ++i) + { + *d++ = s[i]; + if (d[-1] == CSI && d + 2 < string + sizeof(string)) + { + /* Turn CSI into K_CSI. */ + *d++ = KS_EXTRA; + *d++ = (int)KE_CSI; + } + } + len = d - string; + + + // change shift-tab (backtab) into S_TAB + 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 ) { + string[0] = NUL; + len = 1; + } + else if (len == 0 && (key == Qt::Key_Space || key == Qt::Key_Tab)) + { + /* When there are modifiers, these keys get zero length; we need the + * original key here to be able to add a modifier below. */ + string[0] = (key & 0xff); + len = 1; + } + /* Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character + * that already has the 8th bit set. + * Don't do this for <S-M-Tab>, that should become K_S_TAB with ALT. */ + if (len == 1 + && (key != Qt::Key_BackSpace && key != Qt::Key_Delete) + && (string[0] & 0x80) == 0 + && (state & Qt::AltButton) + && !(key == Qt::Key_Tab && (state & Qt::ShiftButton))) + { + string[0] |= 0x80; +#ifdef FEAT_MBYTE + if (enc_utf8) // convert to utf-8 + { + string[1] = string[0] & 0xbf; + string[0] = ((unsigned)string[0] >> 6) + 0xc0; + if (string[1] == CSI) + { + string[2] = KS_EXTRA; + string[3] = (int)KE_CSI; + len = 4; + } + else + len = 2; + } +#endif + } + + /* 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++; + if (special_keys[i].qtkey != 0) { + 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++) + { + if (special_keys[i].qtkey == key ) { + string[0] = CSI; + string[1] = special_keys[i].code0; + string[2] = special_keys[i].code1; + len = -3; + break; + } + }*/ + } + + if (len == 0) { + //no need to dump that, that's a QT problem, we can't do anything + //dbf("Unrecognised Key : %X %s", key, e->text().latin1()); + e->ignore(); + return; + } + + + /* 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) { + + 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; + + /* + * For some keys a shift modifier is translated into another key + * code. Do we need to handle the case where len != 1 and + * string[0] != CSI? + */ + if (len == -3) + key = TO_SPECIAL(string[1], string[2]); + else + key = string[0]; + + key = simplify_key(key, &modifiers); + if (key == CSI) key=K_CSI; + + if (IS_SPECIAL(key)) { + string[0] = CSI; + string[1] = K_SECOND(key); + string[2] = K_THIRD(key); + len = 3; + } else { + string[0] = key; + len = 1; + } + + + if (modifiers!=0) { + uchar string2[10]; + string2[0] = CSI; + string2[1] = KS_MODIFIER; + string2[2] = modifiers; + add_to_input_buf(string2, 3); + } + + } /* special keys */ + + if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts) + || (string[0] == intr_char && intr_char != Ctrl_C))) + { + trash_input_buf(); + got_int = TRUE; + } + + add_to_input_buf(string, len); + if (p_mh) { + gui_mch_mousehide(TRUE); + } + //DCOP Embedding stuff + //if we are here then the user has type something in the window, thus we can easily imagine that : + // 1 - text has changed (emit textChanged()) + // 2 - characters were interactively inserted (emit charactersInteractivelyInserted()) + // 3 - cursor position has changed ( emit cursorPositionChanged() ) + // 4 - selection has changed ? dunno yet //XXX + // 5 - undo changed too ? (each character typed in makes the undo changes anyway) + // conclusion : this makes a lot of things to send to the vim kpart, maybe too much + // for now i'll just send : keyboardEvent to the kpart with the event string as parameter, + // with current current position + // i'll do the same for mouseEvents +#if QT_VERSION>=300 + 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); +#endif + e->ignore(); +} // }}} + +#ifdef FEAT_CLIENTSERVER +void VimWidget::serverActivate(WId id) //{{{ +{ + if (serverName == NULL && serverDelayedStartName != NULL) { + commWindow = id; + (void)serverRegisterName(qt_xdisplay(), serverDelayedStartName); + } else { + serverChangeRegisteredWindow( qt_xdisplay(), id ); + } +}//}}} +#endif + +#ifdef FEAT_XIM +void VimWidget::imStartEvent(QIMEvent *e) { + e->accept(); +} + +void VimWidget::imEndEvent(QIMEvent *e) { + uchar string[256]; + + 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(string, len); + e->accept(); +} + +void VimWidget::imComposeEvent(QIMEvent *e) { + //i should do something here, displaying the text somewhere ... (status area ?) + e->accept(); +} +#endif + + +void VimMainWindow::lock() +{ + locked=true; +} + +void VimMainWindow::unlock() +{ + locked=false; +} + +bool VimMainWindow::isLocked() +{ + return locked; +} + +// ->resize VimWidget if not locked +// +void VimMainWindow::resizeEvent ( QResizeEvent *e ) //{{{ +{ + if ( vmw->isLocked() ) return; + //remove toolbar and menubar height + int height = e->size().height(); + int width = e->size().width(); + + if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled() +#if QT_VERSION>=300 + && !vmw->menuBar()->isTopLevelMenu() +#endif + ) + height -= vmw->menuBar()->height(); +#ifdef FEAT_TOOLBAR + 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)) + width -= vmw->toolBar()->width(); +#endif + height = ( ((int)(height/gui.char_height))*gui.char_height ); + if (!vmw->isLocked()) gui_resize_shell(width,height); +}//}}} + +void VimWidget::focusInEvent( QFocusEvent * fe ) // {{{ +{ + gui_focus_change(true); + + if (blink_state == BLINK_NONE) + gui_mch_start_blink(); +} // }}} + +void VimWidget::focusOutEvent( QFocusEvent * fe )//{{{ +{ + gui_focus_change(false); + + if (blink_state != BLINK_NONE) + gui_mch_stop_blink(); +}//}}} + +void VimWidget::set_blink_time( long wait, long on, long off)//{{{ +{ + blink_wait_time = wait; + blink_on_time = on; + blink_off_time = off; +}//}}} + +void VimWidget::start_cursor_blinking()//{{{ +{ + if (blink_timer.isActive()) blink_timer.stop(); + + /* Only switch blinking on if none of the times is zero */ + if (blink_wait_time && blink_on_time && blink_off_time && gui.in_focus) { + blink_state = BLINK_ON; + gui_update_cursor(TRUE, FALSE); + // The first blink appears after wait_time + blink_timer.start( blink_wait_time, true); + } +}//}}} + +void VimWidget::blink_cursor()//{{{ +{ + if (blink_state == BLINK_ON) { + // set cursor off + gui_undraw_cursor(); + blink_state = BLINK_OFF; + blink_timer.start( blink_off_time, true); + } else { + // set cursor on + gui_update_cursor(TRUE, FALSE); + blink_state = BLINK_ON; + blink_timer.start( blink_on_time, true); + } +}//}}} + +void VimWidget::stop_cursor_blinking()//{{{ +{ + if (blink_timer.isActive()) blink_timer.stop(); + + if (blink_state == BLINK_OFF) + gui_update_cursor(TRUE, FALSE); + + blink_state = BLINK_NONE; +}//}}} + +void VimWidget::flash()//{{{ +{ + QPainter p(this); + + p.setRasterOp(Qt::XorROP); + p.fillRect(geometry(),QColor(0xFF,0xFF,0xFF)); + p.flush(); + //FIXME: Make this a little smarter. Maybe add a timer or something + usleep(19000); + p.fillRect(geometry(),QColor(0xFF,0xFF,0xFF)); + p.flush(); + p.end(); +}//}}} + + +/* + * The main Window + */ + VimMainWindow::VimMainWindow ( const char *name , WFlags f)//{{{ +:KMainWindow(0L, name,f) +{ +#ifdef FEAT_CLIENTSERVER + oldFilter = qt_set_x11_event_filter( kvim_x11_event_filter ); +#endif + if (echo_wid_arg== 1) { + fprintf(stderr, "WID: %ld\n", (long)winId()); + fflush(stderr); + } + + w = new VimWidget(this, "main vim widget"); + gui.w = w; + setFocusProxy(w); + w->setFocus(); + have_tearoff=0; + + finddlg=new KEdFind (this,0,false); + repldlg=new KEdReplace (this,0,false); + QObject::connect( finddlg, SIGNAL(search()), this, SLOT(slotSearch()) ); + QObject::connect( repldlg, SIGNAL(find()), this, SLOT(slotFind()) ); + QObject::connect( repldlg, SIGNAL(replace()), this, SLOT(slotReplace()) ); + QObject::connect( repldlg, SIGNAL(replaceAll()), this, SLOT(slotReplaceAll()) ); + +#ifdef FEAT_TOOLBAR + connect(toolBar(), SIGNAL(clicked(int)), this, SLOT(menu_activated(int))); +#endif +#ifdef FEAT_CLIENTSERVER + w->serverActivate(winId()); + + if (serverName!=NULL) + kapp->dcopClient()->registerAs(QCString((const char*)serverName),false); + else if (serverDelayedStartName!=NULL) + kapp->dcopClient()->registerAs(QCString((const char*)serverDelayedStartName),false); + else if (argServerName!=NULL) + kapp->dcopClient()->registerAs(argServerName->utf8(),false); +#else + if (argServerName!=NULL) + kapp->dcopClient()->registerAs(argServerName->utf8(),false); +#endif + QXEmbed::initialize(); + +}//{{{ + +bool VimMainWindow::queryClose()//{{{ +{ + gui_shell_closed(); + return true; +}//}}} + +bool VimMainWindow::queryExit()//{{{ +{ + return true; +}//}}} + +void VimMainWindow::menu_activated(int dx)//{{{ +{ +#ifdef FEAT_MENU + if (!dx) { // tearoff + return; + } + gui_mch_set_foreground(); + gui_menu_cb((VimMenu *) dx); +#endif +}//}}} + + +void VimMainWindow::clipboard_selection_update(){//{{{ + if(kapp->clipboard()->ownsSelection()) { + clip_own_selection(&clip_star); + } else { + clip_lose_selection(&clip_star); + } +}//}}} + +void VimMainWindow::clipboard_data_update(){//{{{ +#if QT_VERSION>=300 + if (kapp->clipboard()->ownsClipboard()) { + clip_own_selection(&clip_plus); + } else { + clip_lose_selection(&clip_plus); + } +#else + if (kapp->clipboard()->ownsSelection()) { + clip_own_selection(&clip_star); + } else { + clip_lose_selection(&clip_star); + } +#endif +}//}}} + +void VimMainWindow::slotSearch()//{{{ +{ + QString find_text; + bool direction_down = TRUE; + bool casesensitive = TRUE; + int flags = FRD_FINDNEXT; + + find_text = finddlg->getText(); + direction_down = !(finddlg->get_direction()); + casesensitive = finddlg->case_sensitive(); + // if (casesensitive) find_text = "\\C" + find_text; + // else find_text = "\\c" + find_text; + if (casesensitive) flags|=FRD_MATCH_CASE; + QCString unistring = vmw->codec->fromUnicode(find_text); + gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL,(int)direction_down); +}//}}} + +void VimMainWindow::slotFind()//{{{ +{ + QString find_text; + bool direction_down=TRUE; + bool casesensitive = TRUE; + int flags = FRD_R_FINDNEXT; + + find_text=repldlg->getText(); + direction_down = !(repldlg->get_direction()); + casesensitive = repldlg->case_sensitive(); + // if (casesensitive) find_text = "\\C" + find_text; + // else find_text = "\\c" + find_text; + if (casesensitive) flags|=FRD_MATCH_CASE; + + QCString unistring = vmw->codec->fromUnicode(find_text); + gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL,(int)direction_down); +}//}}} + +void VimMainWindow::slotReplace()//{{{ +{ + QString find_text; + QString repl_text; + bool direction_down=TRUE; + bool casesensitive = TRUE; + int flags = FRD_REPLACE; + + find_text=repldlg->getText(); + repl_text=repldlg->getReplaceText(); + direction_down = !(repldlg->get_direction()); + //if (casesensitive) find_text = "\\C" + find_text; + //else find_text = "\\c" + find_text; + if (casesensitive) flags|=FRD_MATCH_CASE; + + QCString unistring = vmw->codec->fromUnicode(find_text); + QCString unistring2 = vmw->codec->fromUnicode(repl_text); + gui_do_findrepl(flags, (char_u *)(const char *)unistring,(char_u *)(const char*)unistring2,(int)direction_down); +}//}}} + +void VimMainWindow::slotReplaceAll()//{{{ +{ + QString find_text; + QString repl_text; + bool direction_down=TRUE; + bool casesensitive = TRUE; + int flags = FRD_REPLACEALL; + + find_text=repldlg->getText(); + repl_text=repldlg->getReplaceText(); + direction_down = !(repldlg->get_direction()); + casesensitive = repldlg->case_sensitive(); + // if (casesensitive) find_text = "\\C" + find_text; + // else find_text = "\\c" + find_text; + if (casesensitive) flags|=FRD_MATCH_CASE; + QCString unistring = vmw->codec->fromUnicode(find_text); + QCString unistring2 = vmw->codec->fromUnicode(repl_text); + gui_do_findrepl(flags, (char_u *)(const char *)unistring,(char_u *)(const char*)unistring2,(int)direction_down); +}//}}} + +void VimMainWindow::showAboutKDE() +{ + KAboutKDE *kde = new KAboutKDE(this); + kde->show(); +} + +void VimMainWindow::showAboutApplication()//{{{ +{ + KAboutData *aboutData = new KAboutData ( + "kvim" + , I18N_NOOP("KVim") + , VIM_VERSION_SHORT + , I18N_NOOP("Vim in a KDE interface") + , 0 + , "(c) Vim Team, \":help credits\" for more infos.\nType \":help iccf\" to see how you can help the children in Uganda" + , 0l + , "http://freehackers.org/kvim" + , "kvim-dev@freenux.org" + ); + + aboutData->addAuthor("Bram Moolenaar", + I18N_NOOP("Main vim author"), + "Bram@vim.org", + "http://www.vim.org/"); + aboutData->addAuthor("Thomas Capricelli", + I18N_NOOP("KDE porting"), + "orzel@freehackers.org", + "http://orzel.freehackers.org"); + aboutData->addAuthor("Philippe Fremy", + I18N_NOOP("KDE porting"), + "pfremy@chez.com", + "http://www.freehackers.org/kvim"); + aboutData->addAuthor("Mark Westcott", + I18N_NOOP("Qtopia porting, maintainer of the Qtopia part"), + "mark@houseoffish.org", + "http://houseoffish.org"); + aboutData->addAuthor("Mickael Marchand", + I18N_NOOP("KDE porting, maintainer"), + "marchand@kde.org", + "http://freenux.org"); + aboutData->addAuthor("Many other people", + I18N_NOOP("type :help credits for more infos") + ); + aboutData->addCredit("Vince Negri", + I18N_NOOP("Antialiasing support, Color fixes"), + "vnegri@asl-electronics.co.uk"); + aboutData->addCredit("Malte Starostik", + I18N_NOOP("Patch for performance improvement"), + "malte@kde.org"); + aboutData->addCredit("Mark Stosberg", + I18N_NOOP("Provided a FreeBSD box to debug KVim on BSD"), + "mark@summersault.com" + ); + aboutData->addCredit("Henrik Skott", + I18N_NOOP("Font patch when KDE not configured"), + "henrik.skott@hem.utfors.se" + ); + aboutData->addCredit("Kailash Sethuraman", + I18N_NOOP("NetBSD configure/compilation fixes") + ); + aboutData->setLicenseText( +"KVim as an extension of Vim follows Vim license : \n\ +Vim is Charityware. You can use and copy it as much as you like, but you are\n\ +encouraged to make a donation to orphans in Uganda. Please read the file\n\ +runtime/doc/uganda.txt for details.\n\ +\n\ +There are no restrictions on distributing an unmodified copy of Vim. Parts of\n\ +Vim may also be distributed, but this text must always be included. You are\n\ +allowed to include executables that you made from the unmodified Vim sources,\n\ +your own usage examples and Vim scripts.\n\ +\n\ +If you distribute a modified version of Vim, you are encouraged to send the\n\ +maintainer a copy, including the source code. Or make it available to the\n\ +maintainer through ftp; let him know where it can be found. If the number of\n\ +changes is small (e.g., a modified Makefile) e-mailing the diffs will do.\n\ +When the maintainer asks for it (in any way) you must make your changes,\n\ +including source code, available to him.\n\ +\n\ +The maintainer reserves the right to include any changes in the official\n\ +version of Vim. This is negotiable. You are not allowed to distribute a\n\ +modified version of Vim when you are not willing to make the source code\n\ +available to the maintainer.\n\ +\n\ +The current maintainer is Bram Moolenaar <Bram@vim.org>. If this changes, it\n\ +will be announced in appropriate places (most likely www.vim.org and\n\ +comp.editors). When it is completely impossible to contact the maintainer,\n\ +the obligation to send him modified source code ceases.\n\ +\n\ +It is not allowed to remove these restrictions from the distribution of the\n\ +Vim sources or parts of it. These restrictions may also be used for previous\n\ +Vim releases instead of the text that was included with it."); + + KAboutApplication *about = new KAboutApplication(aboutData); + about->show(); +}//}}} + +void VimMainWindow::showTipOfTheDay() { +#if QT_VERSION>=300 + KTipDialog::showTip (vmw,QString::null,true); +#endif +} + +void VimMainWindow::buffersToolbar() { + +} + +void VimMainWindow::showBugReport() { + KBugReport *bug= new KBugReport(this,true); + bug->show(); +} +/* + * Vim Dialog + * + * Returns: + * 0: Cancel + * 1- : nb of the pressed button + */ + +VimDialog::VimDialog (int type, /* type of dialog *///{{{ + char_u * title, /* title of dialog */ + char_u * message, /* message text */ + char_u * buttons, /* names of buttons */ + int def_but, /* default button */ + char_u *textfield ) /* input field */ +:QDialog(vmw, "vim generic dialog", true), // true is for "modal" + mapper(this, "dialog signal mapper") +{ + /* + * Create Icon + */ + char ** icon_data; + switch (type) { + case VIM_GENERIC: + icon_data = generic_xpm; + break; + case VIM_ERROR: + icon_data = error_xpm; + break; + case VIM_WARNING: + icon_data = alert_xpm; + break; + case VIM_INFO: + icon_data = info_xpm; + break; + case VIM_QUESTION: + icon_data = quest_xpm; + break; + default: + icon_data = generic_xpm; + }; + QLabel * icon = new QLabel( this ); + icon->setPixmap( QPixmap( (const char **) icon_data ) ); + icon->setFixedSize( icon->sizeHint() ); + + QLabel * text = new QLabel( (const char *)message, this ); + text->setAlignment( AlignHCenter | AlignVCenter | ExpandTabs ); + + QStringList buttonText = QStringList::split( DLG_BUTTON_SEP, (char *) buttons); + int butNb = buttonText.count(); + + /* + * Layout + */ + + QVBoxLayout * vly = new QVBoxLayout( this, 5, 5 ); + QHBoxLayout * hly1 = new QHBoxLayout( vly, 5); + hly1->addWidget( icon ); + hly1->addWidget( text ); + QHBoxLayout * hly3 = new QHBoxLayout ( vly , 5); + if (textfield!=NULL) { + entry = new QLineEdit((const char *)textfield,this); + entry->setText((const char *)textfield); + hly3->addWidget( entry ); + ret=textfield; + } else entry=NULL; + + QHBoxLayout * hly2 = new QHBoxLayout( vly, 15); + QString s; + QPushButton * pushButton = 0L; + for( int i=0; i<butNb; i++) { + s = buttonText[i]; + pushButton = new QPushButton(s, this ); + if (s.find('&') != -1) { + pushButton->setAccel( s.at(s.find('&')+1).latin1() ); + } + + hly2->addWidget( pushButton ); + if (i == def_but-1) { + pushButton->setDefault( true ); + pushButton->setAutoDefault( true ); + setResult( i+1 ); + } + connect(pushButton, SIGNAL(clicked()), &mapper, SLOT(map())); + mapper.setMapping(pushButton, i+1); + } + connect( &mapper, SIGNAL(mapped(int)), this, SLOT(done(int))); + + setCaption((const char *) title); + + vly->activate(); +}//}}} + +void VimDialog::done(int r) { + if (entry!=NULL) { + if (r) { + QCString unistring=vmw->codec->fromUnicode(entry->text()); + STRCPY(ret,(const char*)unistring); + } else + *ret=NUL; + } + QDialog::done(r); +} + +/* + * ScrollBar pool handling + */ +SBPool::SBPool(void)//{{{ + :mapper(this, "SBPool signal mapper") +{ + connect(&mapper, SIGNAL(mapped(int)), this, SLOT(sbUsed(int))); +}//}}} + + +void SBPool::create(GuiScrollbar * sb, int orient)//{{{ +{ + switch(orient) { + case SBAR_HORIZ: + sb->w = new QScrollBar(QScrollBar::Horizontal, vmw); + break; + case SBAR_VERT: + sb->w = new QScrollBar(QScrollBar::Vertical, vmw); + break; + default: + sb->w = 0; + return; + } + + connect(sb->w, SIGNAL(valueChanged(int)), &mapper, SLOT(map())); + mapper.setMapping(sb->w, (int)sb); +}//}}} + + +void SBPool::sbUsed(int who)//{{{ +{ + GuiScrollbar *sb = (GuiScrollbar*)who; + gui_drag_scrollbar( sb, sb->w->value(), FALSE); +}//}}} + + +void SBPool::destroy(GuiScrollbar * sb)//{{{ +{ + if (!sb->w) return; + + delete sb->w; + sb->w = 0; +}//}}} + +#ifdef FEAT_CLIENTSERVER +static int kvim_x11_event_filter( XEvent* e)//{{{ +{ + if (e->xproperty.type == PropertyNotify + && e->xproperty.atom == commProperty + && e->xproperty.window == commWindow + && e->xproperty.state == PropertyNewValue ) { + serverEventProc(qt_xdisplay(), e); + } + + if (oldFilter) return oldFilter( e ); + return FALSE; +}//}}} +#endif + +//add some QT 3 fonts usefull functions +#if QT_VERSION<300 +QString KVimUtils::toString(QFont *f) +{ + QStringList l; + l.append(f->family()); + l.append(QString::number(f->pointSize())); + l.append(QString::number(f->pixelSize())); + l.append(QString::number((int)f->styleHint())); + l.append(QString::number(f->weight())); + l.append(QString::number((int)f->italic())); + l.append(QString::number((int)f->underline())); + l.append(QString::number((int)f->strikeOut())); + l.append(QString::number((int)f->fixedPitch())); + l.append(QString::number((int)f->rawMode())); + return l.join(","); +} + +bool KVimUtils::fromString(QFont *f, QString descrip) +{ + QStringList l(QStringList::split(',', descrip)); + + int count = l.count(); + if (count != 10 && count != 9) { + return FALSE; + } + + f->setFamily(l[0]); + f->setPointSize(l[1].toInt()); + if ( count == 9 ) { + f->setStyleHint((QFont::StyleHint) l[2].toInt()); + f->setWeight(l[3].toInt()); + f->setItalic(l[4].toInt()); + f->setUnderline(l[5].toInt()); + f->setStrikeOut(l[6].toInt()); + f->setFixedPitch(l[7].toInt()); + f->setRawMode(l[8].toInt()); + } else { + f->setPixelSize(l[2].toInt()); + f->setStyleHint((QFont::StyleHint) l[3].toInt()); + f->setWeight(l[4].toInt()); + f->setItalic(l[5].toInt()); + f->setUnderline(l[6].toInt()); + f->setStrikeOut(l[7].toInt()); + f->setFixedPitch(l[8].toInt()); + f->setRawMode(l[9].toInt()); + } + return TRUE; +} +#endif + +QString KVimUtils::convertEncodingName(QString name) +{ + if (name.startsWith("ucs") || name.startsWith("utf-16")) return QString("utf16"); + if (name=="cp950") return QString("Big5"); + return QString(); +} diff --git a/src/gui_kde_widget.h b/src/gui_kde_widget.h new file mode 100644 index 000000000..f2e9c3f85 --- /dev/null +++ b/src/gui_kde_widget.h @@ -0,0 +1,234 @@ +/* vi:set ts=8 sts=0 sw=8: + * + * VIM - Vi IMproved by Bram Moolenaar + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + */ + +/* + * Porting to KDE(2) was done by + * + * (C) 2000 by Thomas Capricelli <orzel@freehackers.org> + * + * Please visit http://freehackers.org/kvim for other vim- or + * kde-related coding. + * + * $Id$ + * + */ + +#ifndef GUI_KDE_WIDGET +#define GUI_KDE_WIDGET + +#if 1 +#define dbf( format, args... ) { printf( "%s" " : " format "\n" , __FUNCTION__ , ## args ); fflush(stdout); } +#define db() { printf( "%s\n", __FUNCTION__ );fflush(stdout); } +#else +#define dbf(format, args... ) +#define db() +#endif + +#define UNIX // prevent a warning : a symbol is defined twice in X and Qt + +#include <qdialog.h> +#include <qlabel.h> +#include <qsignalmapper.h> +#include <qtimer.h> +#include <qmainwindow.h> +#include <qapplication.h> +#include <qevent.h> +#include <qlineedit.h> +#include <qpainter.h> +#include <qwidget.h> +#include <qpopupmenu.h> +#include <klocale.h> +#include <kapp.h> +#include <kcmdlineargs.h> +#include <kaboutdata.h> +#include <keditcl.h> +#include <kaboutdata.h> +#if (KDE_VERSION>=290) +#include <kmainwindow.h> +#else +#include <ktmainwindow.h> +#endif +#include <kparts/part.h> +#include <kurl.h> +#include "kvim_iface.h" + +#undef UNIX // prevent a warning +extern "C" { +#include "vim.h" +} + +class QPushButton; +class QDialog; +class QLineEdit; +class QSignalMapper; +class QPaintEvent; + +enum BlinkState { + BLINK_NONE, + BLINK_ON, + BLINK_OFF +}; + +class VimWidget : public QWidget, virtual public KVim +{ + Q_OBJECT + +public: + VimWidget( QWidget *parent=0, const char *name=0, WFlags f=0 ); + virtual void paintEvent( QPaintEvent *); + void draw_string(int x, int y, QString s, int len, int flags); + + /** Init the blinking time */ + void set_blink_time( long, long, long ); + void start_cursor_blinking(); + void stop_cursor_blinking(); + void wait(long); +#ifdef FEAT_CLIENTSERVER + void serverActivate(WId id); +#endif + void flash(); + + /** DCOP */ + void execNormal(QString command); + void execInsert(QString command); + void execRaw(QString command); + void execCmd(QString command); + QString eval(QString expr); + + bool wait_done; + BlinkState blink_state; + QPainter *painter; + QPopupMenu *menu; + +protected: + virtual void keyPressEvent( QKeyEvent * ); + virtual void mousePressEvent( QMouseEvent *); + virtual void mouseDoubleClickEvent( QMouseEvent *); + virtual void mouseReleaseEvent( QMouseEvent *); + virtual void mouseMoveEvent( QMouseEvent *); + virtual void focusInEvent( QFocusEvent * ); + virtual void focusOutEvent( QFocusEvent * ); + virtual void dragEnterEvent (QDragEnterEvent *); + virtual void dropEvent (QDropEvent *); +#ifdef FEAT_XIM + virtual void imStartEvent ( QIMEvent * ); + virtual void imEndEvent ( QIMEvent * ); + virtual void imComposeEvent ( QIMEvent * ); +#endif + + /* cursor blinking stuff */ + QTimer blink_timer; + long blink_wait_time, blink_on_time, blink_off_time; + + /* wait for input */ + QTimer wait_timer; + +public slots: + void blink_cursor(); + void wait_timeout(); +}; + +class VimMainWindow : public KMainWindow +{ + Q_OBJECT + +public: + VimMainWindow ( const char *name = 0L, WFlags f = WDestructiveClose ); + + /** called when the widget closes */ +// bool close(bool alsoDelete); + VimWidget *w; + KEdFind *finddlg; + KEdReplace *repldlg; + int have_tearoff; + QTextCodec *codec; + +public slots: + void menu_activated(int dx); + void clipboard_selection_update(); + void clipboard_data_update(); + void slotSearch(); + void slotFind(); + void slotReplace(); + void slotReplaceAll(); + void showAboutApplication(); + void showAboutKDE(); + void showBugReport(); + void showTipOfTheDay(); + void buffersToolbar(); + bool isLocked(); + void lock(); + void unlock(); + +protected: + virtual void wheelEvent (QWheelEvent *); + virtual void resizeEvent ( QResizeEvent *e ); + +#if defined(FEAT_SESSION) + void saveGlobalProperties (KConfig *conf); + void readGlobalProperties (KConfig *conf); +#endif + bool queryClose(); + bool queryExit(); + bool locked; +}; + + +class VimDialog : public QDialog +{ + Q_OBJECT +public: + VimDialog (int type, /* type of dialog */ + unsigned char * title, /* title of dialog */ + unsigned char * message, /* message text */ + unsigned char * buttons, /* names of buttons */ + int def_but, /* default button */ + char_u *textfield); /* input text */ +private: + QSignalMapper mapper; + QLineEdit *entry; + char_u *ret; + int butNb; + +protected slots: + void done(int); +}; + + +/* + * QScrollBar pool + */ +struct GuiScrollbar; + +class SBPool : public QObject +{ + Q_OBJECT +public: + SBPool(void); + void create(GuiScrollbar * sb, int orient); + void destroy(GuiScrollbar * sb); +public slots: + void sbUsed(int who); +private: + QSignalMapper mapper; +}; + +class KVimUtils { +public: + static QString convertEncodingName(QString); +#if QT_VERSION<300 + static bool fromString(QFont*,QString); + static QString toString(QFont*); +#endif +}; + +extern VimMainWindow *vmw; +extern SBPool *sbpool; +extern QString *argServerName; + +#endif // GUI_KDE_WIDGET diff --git a/src/gui_kde_x11.cc b/src/gui_kde_x11.cc new file mode 100644 index 000000000..b3f3aa12c --- /dev/null +++ b/src/gui_kde_x11.cc @@ -0,0 +1,1307 @@ +/* vi:set ts=8 sts=4 sw=4: + * + * VIM - Vi IMproved by Bram Moolenaar + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + */ + +/* + * Porting to KDE(2) was done by + * + * (C) 2000 by Thomas Capricelli <orzel@freehackers.org> + * + * Please visit http://freehackers.org/kvim for other vim- or + * kde-related coding. + * + * $Id$ + * + */ + +#include <qscrollbar.h> +#include <qcstring.h> +#include <qdatetime.h> +#include <qcursor.h> +#include <qfontmetrics.h> +#include <qpaintdevice.h> +#include <qclipboard.h> +#include <qregexp.h> +#include <kaboutkde.h> +#include <kiconloader.h> +#include <kfontdialog.h> +#include <kmessagebox.h> +#include <dcopclient.h> +#include <kwin.h> +#include <kmenubar.h> +#include <kconfig.h> +#if (QT_VERSION>=300) +#include <qnamespace.h> +#include <ktip.h> +#endif +#include <qpopupmenu.h> +#include <qpainter.h> +#include <qtextcodec.h> +#include <qfontmetrics.h> +#include <qfont.h> + + +#include "gui_kde_widget.h" + + +extern "C" { +#include "vim.h" +#include "version.h" +} + +#include <stdio.h> + +/* + * global variable for KDE, we can't put them in Gui, cause there are C++ types + */ +VimMainWindow *vmw=0; +SBPool *sbpool=0; +QString *argServerName=0; + +#ifdef FEAT_MOUSESHAPE +/* The last set mouse pointer shape is remembered, to be used when it goes + * from hidden to not hidden. */ +static int last_shape = 0; +#endif + +/* + * Arguments handled by KDE internally. + */ + +#if QT_VERSION>=300 +static int tip=0; // 1 no dialog, 0 use it if enabled in conf, 2 force the tip +#endif +static int reverse=0; // 0 bg : white, 1 : bg : black +QString *startfont; +QSize *startsize; +static int gui_argc = 0; +static char **gui_argv = NULL; + +/* + * Parse the GUI related command-line arguments. Any arguments used are + * deleted from argv, and *argc is decremented accordingly. This is called + * when vim is started, whether or not the GUI has been started. + */ + void +gui_mch_prepare(int *argc, char **argv)// {{{ +{ + //copy args for KDE/Qt + gui_argc = 0; + //this one is not really good as all options are not for KDE/Qt ... + gui_argv = (char **)lalloc((long_u)(*argc * sizeof(char *)), FALSE); + if (gui_argv == NULL) + return; + gui_argv[gui_argc++] = argv[0]; + + int found = 0; + for (int i = 1; i < *argc ; i++) + { + if (found!=2) + found = 0; + else { + found=0; + //remove from the list of argv + if (--*argc>i) { + mch_memmove(&argv[i], &argv[i + 1], + (*argc - i) * sizeof(char *)); + } + i--; + continue; + } + + if (strcmp(argv[i],"--servername")==0) { + argServerName = new QString(argv[i+1]); // to get the serverName now + } +#if QT_VERSION>+300 + if (strcmp(argv[i],"-tip")==0 ) { + tip=2; + found=1; + } + if (strcmp(argv[i],"-notip")==0 ) { + tip=1; + found=1; + } +#endif + if (strcmp(argv[i],"-black")==0 ) { + reverse=1; + found=1; + } + /* replaced by -black */ +/* if (strcmp(argv[i],"-rv")==0 ) { + reverse=1; + found=1; + }*/ + if (strcmp(argv[i],"-font")==0 || strcmp(argv[i], "-fn")==0 ) { + startfont=new QString(argv[i+1]); + found=2; + } + if (strcmp(argv[i],"-geometry")==0 || strcmp (argv[i],"-geom")==0 ) { + found=2; + QString text(argv[i+1]); + QStringList list = QStringList::split(QChar('x'), text); + startsize = new QSize(list[0].toInt(),list[1].toInt()); + } + if (strcmp (argv[i],"-display")==0 ) { //XXX: this does not work, + // too many -display options in main.c ! + // ask Bram ... + gui_argv[gui_argc++] = strdup("--display"); + gui_argv[gui_argc++] = argv[i+1]; + found=0; + } + if (strcmp (argv[i],"--display")==0 ) { + gui_argv[gui_argc++] = argv[i]; + gui_argv[gui_argc++] = argv[i+1]; + found=2; + } + //KDE/Qt options with no args + if (strcmp(argv[i],"--help-kde")==0 || strcmp (argv[i],"--help-qt")==0 + || strcmp(argv[i], "--help-all")==0 + || strcmp(argv[i], "--reverse")==0 + || strcmp(argv[i], "--author")==0 +// || strcmp(argv[i], "--version")==0 //disabled we need these for kcmvim +// || strcmp(argv[i], "-v")==0 + || strcmp(argv[i], "--license")==0 + || strcmp(argv[i], "--cmap")==0 + || strcmp(argv[i], "--nograb")==0 + || strcmp(argv[i], "--dograb")==0 + || strcmp(argv[i], "--sync")==0 + || strcmp(argv[i], "--noxim")==0 + || strcmp(argv[i], "--nocrashhandler")==0 + || strcmp(argv[i], "--waitforwm")==0 + ) { + gui_argv[gui_argc++] = argv[i]; + found=1; + } + //this outputs KDE and Vim versions :) + if (strcmp(argv[i],"--version")==0 + || strcmp (argv[i],"-v")==0 + ) { + gui_argv[gui_argc++] = argv[i]; + } + + + //KDE/Qt options with one arg + if ( strcmp(argv[i],"--session")==0 + || strcmp(argv[i],"--ncols")==0 + || strcmp(argv[i],"--bg")==0 + || strcmp(argv[i],"--background")==0 + || strcmp(argv[i],"--fg")==0 + || strcmp(argv[i],"--foreground")==0 + || strcmp(argv[i],"--btn")==0 + || strcmp(argv[i],"--name")==0 + || strcmp(argv[i],"--title")==0 + || strcmp(argv[i],"--inputstyle")==0 + || strcmp(argv[i],"--im")==0 + || strcmp(argv[i],"--caption")==0 + || strcmp(argv[i],"--icon")==0 + || strcmp(argv[i],"--miniicon")==0 + || strcmp(argv[i],"--config")==0 + || strcmp(argv[i],"--dcopserver")==0 + || strcmp(argv[i],"--style")==0 + || strcmp(argv[i],"--geometry")==0 + || strcmp(argv[i],"--smkey")==0 + || strcmp(argv[i],"-smkey")==0 + || strcmp(argv[i],"-session")==0 + ) { + gui_argv[gui_argc++] = argv[i]; + gui_argv[gui_argc++] = argv[i+1]; + found=2; + } + + //remove from the list of argv + if (found >= 1 && --*argc>i) { + mch_memmove(&argv[i], &argv[i + 1], + (*argc - i) * sizeof(char *)); + i--; + } + } + KCmdLineArgs::init( gui_argc,gui_argv,"kvim", I18N_NOOP("Vim inside KDE"),VIM_VERSION_SHORT); +}// }}} + +/**************************************************************************** + * Focus handlers: + */ + +/* + * Initialises time intervals for the cursor blinking + */ + void +gui_mch_set_blinking(long waittime, long on, long off)//{{{ +{ + gui.w->set_blink_time( waittime, on, off ); +}//}}} + +/* + * Stop the cursor blinking. Show the cursor if it wasn't shown. + */ + void +gui_mch_stop_blink()//{{{ +{ + gui.w->stop_cursor_blinking(); +}//}}} + +/* + * Start the cursor blinking. If it was already blinking, this restarts the + * waiting time and shows the cursor. + */ + void +gui_mch_start_blink()//{{{ +{ + gui.w->start_cursor_blinking(); +}//}}} + +/* + * Check if the GUI can be started. Called before gvimrc is sourced. + * Return OK or FAIL. + */ + int +gui_mch_init_check(void)//{{{ +{ + gui.dpy = qt_xdisplay(); + return OK; +}//}}} + +/* + * Initialise the X GUI. Create all the windows, set up all the call-backs etc. + * Returns OK for success, FAIL when the GUI can't be started. + */ + int +gui_mch_init()//{{{ +{ + (void) new KApplication(); + KApplication::kApplication()->dcopClient()->registerAs(KApplication::kApplication()->name(),false); +// dbf("%s %s",KGlobal::locale()->language().latin1(),KLocale::defaultLanguage().latin1()); + + vmw = new VimMainWindow("KVim",0); + vmw->setFrameBorderWidth(0); + kapp->setMainWidget(vmw); + kapp->setTopWidget(vmw); + + sbpool = new SBPool; + +#if QT_VERSION>=300 + vmw->connect(kapp->clipboard(),SIGNAL(selectionChanged()),vmw,SLOT(clipboard_selection_update())); +#endif + vmw->connect(kapp->clipboard(),SIGNAL(dataChanged()),vmw,SLOT(clipboard_data_update())); + clip_lose_selection(&clip_plus); + clip_lose_selection(&clip_star); + + gui.in_focus = FALSE; // will be updated + + if (reverse) { + gui.def_norm_pixel = gui_get_color((char_u *)"White"); + gui.def_back_pixel = gui_get_color((char_u *)"Black"); +#if QT_VERSION>=300 + gui.w->setEraseColor ( QColor(Qt::black) ); +#else + gui.w->setBackgroundColor ( QColor(Qt::black) ); +#endif + } else { + gui.def_norm_pixel = gui_get_color((char_u *)"Black"); + gui.def_back_pixel = gui_get_color((char_u *)"White"); +#if QT_VERSION>=300 + gui.w->setEraseColor ( QColor(Qt::white) ); +#else + gui.w->setBackgroundColor ( QColor(Qt::white) ); +#endif + } + + gui.norm_pixel = gui.def_norm_pixel; + gui.back_pixel = gui.def_back_pixel; + + gui.border_width = 1; + gui.border_offset = 1;//gui.border_width; + gui.scrollbar_width=SB_DEFAULT_WIDTH; + gui.scrollbar_height=SB_DEFAULT_WIDTH; + + //gui.menu_height=vmw->menuBar()->height()+1; + //gui.toolbar_height=vmw->toolBar()->height(); + + return OK; +}//}}} + + +/* + * Called when the foreground or background color has been changed. + */ + void +gui_mch_new_colors()//{{{ +{ + QColor rgb; + rgb.setRgb(gui.back_pixel); +#if QT_VERSION>=300 + gui.w->setEraseColor(rgb); +#else + gui.w->setBackgroundColor(rgb); +#endif +}//}}} + +/* + * Open the GUI window which was created by a call to gui_mch_init(). + */ + int +gui_mch_open()//{{{ +{ + gui.dpy=qt_xdisplay(); + set_normal_colors(); + + /* Check that none of the colors are the same as the background color */ + gui_check_colors(); + + /* Get the colors for the highlight groups (gui_check_colors() might have + * changed them). + */ + highlight_gui_started(); /* re-init colors and fonts */ +#ifdef FEAT_MENU + vmw->w->menu = new QPopupMenu(vmw); + +#if QT_VERSION>=300 + vmw->w->menu->insertItem(SmallIcon("ktip"), i18n("&Tip of the day..."), vmw, SLOT(showTipOfTheDay())); + vmw->w->menu->insertSeparator(); +#endif + if (vmw->have_tearoff) vmw->w->menu->insertTearOffHandle(0,0); + vmw->w->menu->insertItem(i18n("&Report Bug ..."), vmw, SLOT(showBugReport())); + vmw->w->menu->insertSeparator(); + vmw->w->menu->insertItem(SmallIcon("kvim"), i18n("&About KVim..."), vmw, SLOT(showAboutApplication())); + vmw->w->menu->insertItem(SmallIcon("about_kde"), i18n("About &KDE..."), vmw, SLOT(showAboutKDE())); + vmw->menuBar()->insertItem("&KVim", vmw->w->menu); +#endif + if (startfont!=NULL) + gui_mch_init_font((char_u*)startfont->latin1(),0); + + if (startsize!=NULL) + vmw->resize(startsize->width(), startsize->height()); + + gui_mch_update_codec(); + + if (kapp->isRestored()) + if (KMainWindow::canBeRestored(1)) + vmw->restore(1); + + vmw->show(); +#if QT_VERSION>=300 + if (tip==2) KTipDialog::showTip (vmw,QString::null,true); + else if (tip==0) KTipDialog::showTip (vmw); +#endif + + return OK; +}//}}} + + void +gui_mch_exit(int rc)//{{{ +{ + kapp->quit(); +}//}}} + +/* + * Get the position of the top left corner of the window. + */ + int +gui_mch_get_winpos(int *x, int *y)//{{{ +{ + *x = vmw->x(); + *y = vmw->y(); + return OK; +}//}}} + +/* + * Set the position of the top left corner of the window to the given + * coordinates. + */ + void +gui_mch_set_winpos(int x, int y)//{{{ +{ + vmw->move(x,y); +}//}}} + +/* + * Set the windows size. + * ->resize VimWidget + * ->resize vmw (block any events generated from here) + */ +void +gui_mch_set_shellsize(int width, int height,//{{{ + int min_width, int min_height, + int base_width, int base_height) +{ + //resize VimWidget + vmw->w->resize(width,height); + + //resize vmw + int vheight, vwidth; + vheight = height; + vwidth = width; + + if (gui.which_scrollbars[SBAR_LEFT]) vwidth+=gui.scrollbar_width; + if (gui.which_scrollbars[SBAR_RIGHT]) vwidth+=gui.scrollbar_width; + if (gui.which_scrollbars[SBAR_BOTTOM]) vheight+=gui.scrollbar_height; + + if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled() +#if QT_VERSION>=300 + && !vmw->menuBar()->isTopLevelMenu() +#endif + ) + vheight += vmw->menuBar()->height(); +#ifdef FEAT_TOOLBAR + if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() && + (vmw->toolBar()->barPos()==KToolBar::Top || + vmw->toolBar()->barPos()==KToolBar::Bottom)) + vheight += vmw->toolBar()->height(); + + if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() && + (vmw->toolBar()->barPos()==KToolBar::Left || + vmw->toolBar()->barPos()==KToolBar::Right)) + vwidth += vmw->toolBar()->width(); +#endif + vmw->lock(); + vmw->resize(vwidth,vheight); + gui_mch_update(); + //size should be nearly perfect, update baseSize and sizeIncrement + vmw->setBaseSize(base_width,vmw->menuBar()->height()+1+vmw->toolBar()->height()+gui.char_height*2); + vmw->setSizeIncrement( ( ( int )( gui.char_width/2 )*2 ),gui.char_height); + vmw->unlock(); +}//}}} + + +/* + * The screen size is used to make sure the initial window doesn't get bigger + * then the screen. This subtracts some room for menubar, toolbar and window + * decorations. + */ + void +gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)//{{{ +{ + *screen_w = kapp->desktop()->width(); + *screen_h = kapp->desktop()->height(); +}//}}} + +#if defined(FEAT_MENU) || defined(PROTO) + void +gui_mch_enable_menu(int showit)//{{{ +{ + if (showit) + vmw->menuBar()->show(); + else + vmw->menuBar()->hide(); + vmw->resize(vmw->width(),vmw->height()); +}//}}} +#endif + + +#if defined(FEAT_TOOLBAR) || defined(PROTO) + void +gui_mch_show_toolbar(int showit)//{{{ +{ + if (showit) + vmw->toolBar()->show(); + else + vmw->toolBar()->hide(); + vmw->resize(vmw->width(),vmw->height()); +}//}}} +#endif + +/* + * Put up a font dialog and return the selected font name in allocated memory. + * "oldval" is the previous value. + * Return NULL when cancelled. + */ + +char_u *gui_mch_font_dialog (char_u *oldval)//{{{ +{ + QFont myFont( vmw->w->font() ); + if (gui.fontname) { + gui.fontname=NULL; + } + int result = KFontDialog::getFont( myFont, true ); + if ( result != KFontDialog::Accepted ) { + return NULL; + } +// myFont.setFixedPitch(true); +#if QT_VERSION>=300 + QString n = myFont.toString(); +#else + QString n = KVimUtils::toString(&myFont); +#endif + n.replace(QRegExp(","),"/"); + gui.fontname = (char_u *)strdup((const char *)n); + n.replace(QRegExp(" "),"\\ "); + n=QString("To set this font as your default font for KVim, edit your ~/.gvimrc file and add the following lines : \nif has(\"gui_kde\")\nset guifont=")+n+QString("\nendif");// \n OR \n use the control center of KDE and choose the correct fixed font"); + + //display a message box which explains how to save your font settings + KMessageBox::information(vmw, n,"Font Selection", "kvimselectfont"); + + return vim_strsave(gui.fontname); +}//}}} + +/* + * Initialise vim to use the font with the given name. + * Return FAIL if the font could not be loaded, OK otherwise. + */ + int +gui_mch_init_font(char_u * font_name, int fontset)//{{{ +{ + QString fontname; + GuiFont font=NULL; + + if (font_name==NULL) { +#if 0 +#if QT_VERSION>=300 + KConfig *base = KGlobal::config(); +#else + KConfigBase *base = KGlobal::config(); +#endif + base->setGroup("General"); + if(!base->hasKey("fixed")) { + KMessageBox::error(KApplication::kApplication()->mainWidget(),"Cannot load default fixed font\n\nConfigure fonts in KDE Control Center.\n(Just click 'Choose...', 'OK' and then 'Apply')"); + return FAIL; + } +#if QT_VERSION>=300 + QString f = base->readEntry("fixed"); +#else + QFont ft = base->readFontEntry("fixed", NULL); + QString f = KVimUtils::toString(&ft); +#endif + font_name = (char_u*)strdup(f.latin1()); //latin1 ? +#else + font_name = (char_u*)strdup("misc-fixed/10/-1/5/50/0/0/0/1/0"); +#endif + } + fontname = (const char *)font_name; +/* fontname.replace(QRegExp("/"),","); + font = new QFont(); + font->fromString( fontname ); +*/ + gui_mch_free_font(gui.norm_font); +#ifdef FEAT_XFONTSET + gui_mch_free_fontset(gui.fontset); + if (fontset) + font = gui_mch_get_fontset(font_name,TRUE,TRUE); +#endif + if (font == NULL) { + font = gui_mch_get_font(font_name,FALSE); + gui.norm_font = font; +#ifdef FEAT_XFONTSET + gui.fontset=NOFONTSET; +#endif + } +#ifdef FEAT_XFONTSET + else { + gui.fontset=font; + gui.norm_font=NOFONT; + } +#endif + + if (font == NULL) + return FAIL; + + if (fontname.contains('*') && fontname.contains('-')) + return FAIL; + + QFontMetrics f(*font); + gui.char_width = f.maxWidth(); + gui.char_height = f.height()+p_linespace; + gui.char_ascent = f.ascent()+p_linespace/2; + + //check values, just to make sure and avoid a crash + if (gui.char_width<=0) gui.char_width=8; + if (gui.char_height<=0) gui.char_height=1; + + hl_set_font_name(font_name); + + return OK; +}//}}} + + GuiFont +gui_mch_get_font(char_u * name, int report_error)//{{{ +{ + QString fontname((const char *)name); + if (!gui.in_use || name == NULL) + return NOFONT; + if (fontname.contains('*') && fontname.contains('-')) + return NOFONT; // XFLD names not allowed anymore + QFont *myFont = new QFont(); + fontname.replace(QRegExp("/"),","); +// myFont->setRawMode(TRUE); + +#if QT_VERSION>=300 + myFont->fromString(fontname); +#else + KVimUtils::fromString(myFont,fontname); +#endif + myFont->setFixedPitch(true); + if (!myFont->fixedPitch()) dbf("Non fixed-width font"); + return (GuiFont) myFont; +}//}}} + +/* + * Set the current text font. + * Since we create all GC on demand, we use just gui.current_font to + * indicate the desired current font. + */ + void +gui_mch_set_font(GuiFont font)//{{{ +{ + gui.current_font=font; + gui.w->painter->setFont( *(gui.current_font) ); +}//}}} + +/* + * If a font is not going to be used, free its structure. + */ + void +gui_mch_free_font(GuiFont font)//{{{ +{ + if (font) + delete font; // this is a QFont , we can delete it :) +}//}}} + +GuiFontset gui_mch_get_fontset (char_u *name, int report_error, int fixed_width) +{ + return (GuiFontset)gui_mch_get_font(name,report_error); +} + +void gui_mch_set_fontset (GuiFontset fontset) +{ + gui_mch_set_font((GuiFont)fontset); +} + +void gui_mch_free_fontset (GuiFontset fontset) +{ + if (fontset) + delete fontset; +} + +void gui_mch_settitle (char_u *title, char_u *icon)//{{{ +{ + if (!gui.in_use) /* can't do this when GUI not running */ + return; + vmw->setPlainCaption((const char *)title); + QPixmap p((const char *)icon); + vmw->setIcon(p); //FIXME +}//}}} + +/* + * Return the Pixel value (color) for the given color name. This routine was + * pretty much taken from example code in the Silicon Graphics OSF/Motif + * Programmer's Guide. + * Return -1 for error. + */ + guicolor_T +gui_mch_get_color(char_u * name)//{{{ +{ + int i; + static char *(vimnames[][2]) = + { + /* A number of colors that some X11 systems don't have */ + {"LightRed", "#FFA0A0"}, + {"LightGreen", "#80FF80"}, + {"LightMagenta", "#FFA0FF"}, + {"DarkCyan", "#008080"}, + {"DarkBlue", "#0000C0"}, + {"DarkRed", "#C00000"}, + {"DarkMagenta", "#C000C0"}, + {"DarkGrey", "#C0C0C0"}, + {NULL, NULL} + }; + + if (!gui.in_use) /* can't do this when GUI not running */ + return (guicolor_T)(-1); + + QColor _color((const char *)name); + + + if (_color.isValid()) { + //return (_color.red() << 16) + ((_color.green() << 8)) + (_color.blue()); + return _color.rgb(); + //return (guicolor_T) _color.pixel(); + } + + /* add a few builtin names */ + for (i = 0;; ++i) { + if (vimnames[i][0] == NULL) + return (guicolor_T)(-1); + if (STRICMP(name, vimnames[i][0]) == 0) { + name = (char_u *) vimnames[i][1]; + return gui_mch_get_color(name); + } + } + + return (guicolor_T)(-1); // dead code, should not be reached.. +}//}}} + +/* + * Set the current text foreground color. + */ + void +gui_mch_set_fg_color(guicolor_T color)//{{{ +{ + QColor rgb; + rgb.setRgb(color); + gui.w->painter->setPen( rgb ); +}//}}} + +/* + * Set the current text background color. + */ + void +gui_mch_set_bg_color(guicolor_T color)//{{{ +{ + QColor rgb; + rgb.setRgb(color); + gui.w->painter->setBackgroundColor(rgb); +}//}}} + +/* + * Use the blank mouse pointer or not. + * + * hide: TRUE = use blank ptr, FALSE = use parent ptr + */ + void +gui_mch_mousehide(int hide)//{{{ +{ + if (hide == gui.pointer_hidden) return; + //#ifdef FEAT_MOUSESHAPE + // if( !hide) mch_set_mouse_shape(last_shape); + //#else +# if (QT_VERSION<300) + gui.w->setCursor((hide)?BlankCursor:ArrowCursor); +# else + gui.w->setCursor((hide)?Qt::BlankCursor:Qt::ArrowCursor); +# endif + //#endif + gui.pointer_hidden = hide; +}//}}} + + void +gui_mch_update_codec() +{ +#ifdef FEAT_MBYTE + if (!gui.in_use) return; + vmw->codec = QTextCodec::codecForName((const char *)p_enc); + if (vmw->codec==NULL) + vmw->codec = QTextCodec::codecForName(KVimUtils::convertEncodingName(QString((const char*)p_enc))); + if (vmw->codec==NULL) + vmw->codec = QTextCodec::codecForLocale(); +#else + vmw->codec = QTextCodec::codecForLocale(); +#endif + if (vmw->codec==NULL) + vmw->codec = QTextCodec::codecForName("ISO-8859-1"); //fallback +} + + void +gui_mch_draw_string(int row, int col, char_u * s, int len, int flags)//{{{ +{ + QString text = vmw->codec->toUnicode((const char *)s,len); + gui.w->draw_string( TEXT_X(col), TEXT_Y(row), text, text.length(), flags ); +}//}}} + +#if defined(FEAT_TITLE) || defined(PROTO) +/* + * Return the text window-id and display. Only required for X-based GUI's + */ + int +gui_get_x11_windis(Window * win, Display ** dis)//{{{ +{ + *win = /*vmw*/gui.w->winId(); + *dis = qt_xdisplay(); + return OK; +}//}}} +#endif + + void +gui_mch_beep()//{{{ +{ + kapp->beep(); +}//}}} + + void +gui_mch_flash(int msec)//{{{ +{ + gui.w->flash(); +}//}}} + +/* + * Invert a rectangle from row r, column c, for nr rows and nc columns. + */ + void +gui_mch_invert_rectangle(int r, int c, int nr, int nc)//{{{ +{ + bitBlt ( + gui.w, + FILL_X(c), FILL_Y(r), + gui.w, + FILL_X(c), FILL_Y(r), + (nc) * gui.char_width, + (nr) * gui.char_height, + Qt::NotROP, // raster Operation + true ); // ignoreMask +}//}}} + +/* + * Iconify the GUI window. + */ + void +gui_mch_iconify()//{{{ +{ + vmw->showMinimized(); +}//}}} + +/* + * Draw a cursor without focus. + */ + void +gui_mch_draw_hollow_cursor(guicolor_T color)//{{{ +{ + QPainter p(gui.w); + p.setPen( color ); + + p.drawRect(FILL_X(gui.col), FILL_Y(gui.row), gui.char_width - 1, gui.char_height - 1 ); + + p.end(); +}//}}} + +/* + * Draw part of a cursor, "w" pixels wide, and "h" pixels high, using + * color "color". + */ + void +gui_mch_draw_part_cursor(int w, int h, guicolor_T color)//{{{ +{ + QPainter p(gui.w); + p.setPen( color ); + p.fillRect( + FILL_X(gui.col), + FILL_Y(gui.row) + gui.char_height - h +1, + w, h-2, QColor( color, color)); + p.drawRect(FILL_X(gui.col),FILL_Y(gui.row) + gui.char_height - h + (int)p_linespace / 2, + w, h - (int)p_linespace ); + +}//}}} + + +/* + * Catch up with any queued X11 events. This may put keyboard input into the + * input buffer, call resize call-backs, trigger timers etc. If there is + * nothing in the X11 event queue (& no timers pending), then we return + * immediately. + */ + void +gui_mch_update()//{{{ +{ + kapp->processEvents(); +}//}}} + + +/* + * GUI input routine called by gui_wait_for_chars(). Waits for a character + * from the keyboard. + * wtime == -1 Wait forever. + * wtime == 0 This should never happen. + * wtime > 0 Wait wtime milliseconds for a character. + * Returns OK if a character was found to be available within the given time, + * or FAIL otherwise. + */ + int +gui_mch_wait_for_chars(long wtime)//{{{ +{ + // malte@kde.org's gift to KVim ;), thanks to him :) for this hard to find bug + if (wtime>0) { + gui.w->wait( wtime ); + while ( vim_is_input_buf_empty() && !gui.w->wait_done ) + kapp->processOneEvent(); + return vim_is_input_buf_empty() ? FAIL : OK; + } else + while (vim_is_input_buf_empty() ) { + kapp->processOneEvent(); + } + + return OK; +}//}}} + + +/**************************************************************************** + * Output drawing routines. + ****************************************************************************/ + + +/* Flush any output to the screen */ + void +gui_mch_flush()//{{{ +{ + kapp->flushX(); +}//}}} + +/* + * Clear a rectangular region of the screen from text pos (row1, col1) to + * (row2, col2) inclusive. + */ + void +gui_mch_clear_block(int row1, int col1, int row2, int col2)//{{{ +{ + gui.w->erase (FILL_X(col1), FILL_Y(row1), + (col2 - col1 + 1) * gui.char_width+ (col2 == Columns - 1), + (row2 - row1 + 1) * gui.char_height ); +}//}}} + + void +gui_mch_clear_all(void)//{{{ +{ + gui.w->erase(); +}//}}} + + +/* + * Delete the given number of lines from the given row, scrolling up any + * text further down within the scroll region. + */ + void +gui_mch_delete_lines(int row, int num_lines)//{{{ +{ + if (num_lines <= 0) + return; + + if (row + num_lines > gui.scroll_region_bot) { + /* Scrolled out of region, just blank the lines out */ + gui_clear_block(row, gui.scroll_region_left, gui.scroll_region_bot, gui.scroll_region_right); + } else { + bitBlt ( + gui.w, + FILL_X(gui.scroll_region_left), FILL_Y(row), + gui.w, + FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines), + gui.char_width * (gui.scroll_region_right -gui.scroll_region_left + 1) + 1, + gui.char_height * (gui.scroll_region_bot - row - num_lines + 1), + Qt::CopyROP, // raster Operation + true ); // ignoreMask + + /* Update gui.cursor_row if the cursor scrolled or copied over */ + if (gui.cursor_row >= row) { + if (gui.cursor_row < row + num_lines) + gui.cursor_is_valid = FALSE; + else if (gui.cursor_row <= gui.scroll_region_bot) + gui.cursor_row -= num_lines; + } + + gui_clear_block(gui.scroll_region_bot - num_lines + 1, gui.scroll_region_left, + gui.scroll_region_bot, gui.scroll_region_right); + + } +}//}}} + +/* + * Insert the given number of lines before the given row, scrolling down any + * following text within the scroll region. + */ + void +gui_mch_insert_lines(int row, int num_lines)//{{{ +{ + if (num_lines <= 0) + return; + + if (row + num_lines > gui.scroll_region_bot) { + /* Scrolled out of region, just blank the lines out */ + gui_clear_block(row, gui.scroll_region_left, gui.scroll_region_bot, gui.scroll_region_right - 1); + } else { + bitBlt ( + gui.w, + FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines), + gui.w, + FILL_X(gui.scroll_region_left), FILL_Y(row), + gui.char_width * ( gui.scroll_region_right - gui.scroll_region_left + 1 ) + 1, + gui.char_height * (gui.scroll_region_bot - row - num_lines + 1), + Qt::CopyROP, // raster Operation + true ); // ignoreMask + + /* Update gui.cursor_row if the cursor scrolled or copied over */ + if (gui.cursor_row >= gui.row) { + if (gui.cursor_row <= gui.scroll_region_bot - num_lines) + gui.cursor_row += num_lines; + else if (gui.cursor_row <= gui.scroll_region_bot) + gui.cursor_is_valid = FALSE; + } + + gui_clear_block(row, gui.scroll_region_left, row + num_lines - 1, gui.scroll_region_right); + } +}//}}} + +/* + * X Selection stuff, for cutting and pasting text to other windows. + */ + void +clip_mch_request_selection(VimClipboard *cbd)//{{{ +{ +#if QT_VERSION>=300 + if (cbd==&clip_star) kapp->clipboard()->setSelectionMode(true); +#endif + QString selection = kapp->clipboard()->text(); + + QCString unistring = vmw->codec->fromUnicode(selection); + clip_yank_selection(MCHAR,(char_u *)(const char*)unistring,(long) unistring.length(),cbd); +#if QT_VERSION>=300 + if (cbd==&clip_star) kapp->clipboard()->setSelectionMode(false); +#endif +}//}}} + + void +clip_mch_lose_selection(VimClipboard *cbd)//{{{ +{ + //Don't need to do anything here + gui_mch_update(); +}//}}} + +/* + * Check whatever we allready own the selection. + */ + int +clip_mch_own_selection(VimClipboard *cbd)//{{{ +{ + if (kapp->clipboard()->ownsSelection()) + return OK; + else { +#if QT_VERSION>=300 + kapp->clipboard()->setSelectionMode(true); +#endif + return OK; + } +}//}}} + +/* + * Send the current selection to the clipboard. + */ +void +clip_mch_set_selection(VimClipboard *cbd){//{{{ + char_u *data; + long_u length; + + clip_get_selection(cbd); + if(clip_convert_selection(&data,&length,cbd)<0) return; + + QString selection((const char *) data); + //We must turncate the string because it is not + // null terminated + selection.truncate((uint) length); + +#if QT_VERSION>=300 + if (cbd==&clip_star) kapp->clipboard()->setSelectionMode(true); +#endif + kapp->clipboard()->setText(selection); +#if QT_VERSION>=300 + kapp->clipboard()->setSelectionMode(false); +#endif +}//}}} + + +#if defined(FEAT_MENU) || defined(PROTO) +/* + * Make a menu item appear either active or not active (grey or not grey). + */ + void +gui_mch_menu_grey(vimmenu_T * menu, int grey)//{{{ +{ + if ( !menu || !menu->parent || !menu->parent->widget ) return; + menu->parent->widget->setItemEnabled((int)menu, !grey); + gui_mch_update(); +}//}}} + +/* + * Make menu item hidden or not hidden. + */ + void +gui_mch_menu_hidden(vimmenu_T * menu, int hidden)//{{{ +{ + //FIXME: cannot be fixed AFAIK + gui_mch_menu_grey(menu,hidden); // it's hard to remove an item in a QPopupMenu +}//}}} + +/* + * This is called after setting all the menus to grey/hidden or not. + */ + void +gui_mch_draw_menubar()//{{{ +{ + // nothing to do under kde +}//}}} +#endif + +/* + * Scrollbar stuff. + */ + void +gui_mch_enable_scrollbar(scrollbar_T * sb, int flag)//{{{ +{ + if (!sb->w) return; + int width = gui.w->width(); + int height = gui.w->height(); + int neww = vmw->width(); + int newh = vmw->height(); + + if (gui.which_scrollbars[SBAR_LEFT]) width += gui.scrollbar_width; + if (gui.which_scrollbars[SBAR_RIGHT]) width += gui.scrollbar_width; + if (gui.which_scrollbars[SBAR_BOTTOM]) height += gui.scrollbar_height; + + if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled() +#if QT_VERSION>=300 + && !vmw->menuBar()->isTopLevelMenu() +#endif + ) + height += vmw->menuBar()->height(); +#ifdef FEAT_TOOLBAR + 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)) + width += vmw->toolBar()->width(); +#endif + if ( abs(vmw->width() - width)>5 && (sb->type==SBAR_LEFT || sb->type==SBAR_RIGHT) ) + neww=width; + if (abs(vmw->height() - height)>5 && (sb->type==SBAR_BOTTOM) ) + newh=height; + + if (flag) + sb->w->show(); + else + sb->w->hide(); + gui_mch_update(); + vmw->lock(); + vmw->resize(neww,newh); + vmw->unlock(); + gui_mch_update(); +}//}}} + +/* + * Return the RGB value of a pixel as "#RRGGBB". + */ + long_u +gui_mch_get_rgb(guicolor_T pixel)//{{{ +{ +// QColor c(pixel,pixel); +// return (c.red() << 16) + ((c.green() << 8)) + (c.blue()); + return pixel; // funny no ? it looks like with Qt we can always use directly the rgb value (i hope i don't break colors again ;p) +}//}}} + +/* + * Get current y mouse coordinate in text window. + * Return -1 when unknown. + */ + int +gui_mch_get_mouse_x(void)//{{{ +{ + return vmw->mapFromGlobal( QCursor::pos() ).x(); +}//}}} + + int +gui_mch_get_mouse_y(void)//{{{ +{ + return vmw->mapFromGlobal( QCursor::pos() ).y(); +}//}}} + + void +gui_mch_setmouse(int x, int y)//{{{ +{ + QCursor::setPos( vmw->mapToGlobal( QPoint(x,y)) ); +}//}}} + +#if defined(FEAT_MOUSESHAPE) || defined(PROTO) +#if QT_VERSION>=300 +static int mshape_ids[] = {//{{{ + Qt::ArrowCursor, /* arrow */ + Qt::BlankCursor, /* blank */ + Qt::IbeamCursor, /* beam */ + Qt::SizeVerCursor, /* updown */ + Qt::SplitHCursor, /* udsizing */ + Qt::SizeHorCursor, /* leftright */ + Qt::SizeHorCursor, /* lrsizing */ + Qt::WaitCursor, /* busy */ + Qt::ForbiddenCursor, /* no */ + Qt::CrossCursor, /* crosshair */ + Qt::PointingHandCursor, /* hand1 */ + Qt::PointingHandCursor, /* hand2 */ + Qt::ArrowCursor, /* pencil */ + Qt::WhatsThisCursor, /* question */ + Qt::ArrowCursor, /* right-arrow */ + Qt::UpArrowCursor, /* up-arrow */ + Qt::ArrowCursor /* last one */ +};//}}} +#else +static int mshape_ids[] = {//{{{ + ArrowCursor, /* arrow */ + BlankCursor, /* blank */ + IbeamCursor, /* beam */ + SizeVerCursor, /* updown */ + SplitHCursor, /* udsizing */ + SizeHorCursor, /* leftright */ + SizeHorCursor, /* lrsizing */ + WaitCursor, /* busy */ + ForbiddenCursor, /* no */ + CrossCursor, /* crosshair */ + PointingHandCursor, /* hand1 */ + PointingHandCursor, /* hand2 */ + ArrowCursor, /* pencil */ + ArrowCursor, /* question */ + ArrowCursor, /* right-arrow */ + UpArrowCursor, /* up-arrow */ + ArrowCursor /* last one */ +};//}}} +#endif + + void +mch_set_mouse_shape (int shape)//{{{ +{ + int id; + + if (shape == MSHAPE_HIDE || gui.pointer_hidden) +#if QT_VERSION>=300 + gui.w->setCursor(Qt::BlankCursor); +#else + gui.w->setCursor(BlankCursor); +#endif + else + { + if (shape >= MSHAPE_NUMBERED) + { + id = shape - MSHAPE_NUMBERED; + /* if (id >= GDK_NUM_GLYPHS) + id = GDK_LEFT_PTR; + else + id &= ~1;*/ /* they are always even (why?) */ + id &= -1; + } + else + id = mshape_ids[shape]; + + gui.w->setCursor(id); + } + if (shape != MSHAPE_HIDE) + last_shape = shape; +}//}}} +#endif + + int +gui_mch_adjust_charsize ()//{{{ +{ + QFont f(*(gui.current_font)); + QFontMetrics fm (f); + gui.char_height = fm.height() + p_linespace; + //gui.char_height = fm.ascent() + fm.descent() + p_linespace; + gui.char_ascent = fm.ascent() + p_linespace/2; + + return OK; +}//}}} + + void +gui_mch_set_foreground ()//{{{ +{ + KWin::setActiveWindow(vmw->winId()); +}//}}} + + + diff --git a/src/kvim_iface.h b/src/kvim_iface.h new file mode 100644 index 000000000..1084bc25d --- /dev/null +++ b/src/kvim_iface.h @@ -0,0 +1,19 @@ +#ifndef KVIM_IFACE +#define KVIM_IFACE + +#include <dcopobject.h> + +class KVim : virtual public DCOPObject +{ + K_DCOP +public: + +k_dcop: + virtual void execInsert(QString command)=0; + virtual void execNormal(QString command)=0; + virtual void execRaw(QString command)=0; + virtual void execCmd(QString command)=0; + virtual QString eval(QString expr)=0; +}; + +#endif diff --git a/src/main.c b/src/main.c index 91854bf7a..5fd83394d 100644 --- a/src/main.c +++ b/src/main.c @@ -259,7 +259,7 @@ main break; # ifdef FEAT_XCLIPBOARD else if (STRICMP(argv[i], "-display") == 0 -# ifdef FEAT_GUI_GTK +# if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) || STRICMP(argv[i], "--display") == 0 # endif ) @@ -442,7 +442,7 @@ main ++initstr; } - if (TOLOWER_ASC(initstr[0]) == 'g') + if (TOLOWER_ASC(initstr[0]) == 'g' || initstr[0] == 'k') { main_start_gui(); #ifdef FEAT_GUI @@ -1087,7 +1087,7 @@ scripterror: #ifdef ALWAYS_USE_GUI gui.starting = TRUE; #else -# if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) +# if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) /* * Check if the GUI can be started. Reset gui.starting if not. * Don't know about other systems, stay on the safe side and don't check. @@ -1170,7 +1170,7 @@ scripterror: * For GTK we can't be sure, but when started from the desktop it doesn't * make sense to try using a terminal. */ -#if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) +#if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) if (gui.starting # ifdef FEAT_GUI_GTK && !isatty(2) @@ -2614,6 +2614,17 @@ usage() # endif main_msg(_("--socketid <xid>\tOpen Vim inside another GTK widget")); #endif +#ifdef FEAT_GUI_KDE + mch_msg(_("\nArguments recognised by kvim (KDE version):\n")); + main_msg(_("-black\t\tUse reverse video")); +#if QT_VERSION>=300 + main_msg(_("-tip\t\t\tDisplay the tip dialog on startup")); + main_msg(_("-notip\t\tDisable the tip dialog")); +#endif + main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)")); + main_msg(_("-geometry <geom>\tUse <geom> for initial geometry (also: -geom)")); + main_msg(_("--display <display>\tRun vim on <display>")); +#endif #ifdef FEAT_GUI_W32 main_msg(_("-P <parent title>\tOpen Vim inside parent application")); #endif diff --git a/src/mbyte.c b/src/mbyte.c index 699316d0e..db7c6524d 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -690,6 +690,11 @@ codepage_invalid: apply_autocmds(EVENT_ENCODINGCHANGED, NULL, (char_u *)"", FALSE, curbuf); #endif +#ifdef FEAT_GUI_KDE + if (gui.in_use) + gui_mch_update_codec(); +#endif + return NULL; } @@ -3976,7 +3981,7 @@ static int status_area_enabled = TRUE; # endif #endif -#if defined(FEAT_GUI_GTK) || defined(PROTO) +#if defined(FEAT_GUI_GTK) || defined(PROTO) || defined(FEAT_GUI_KDE) static int preedit_buf_len = 0; static int xim_can_preediting INIT(= FALSE); /* XIM in showmode() */ static int xim_input_style; @@ -4112,7 +4117,7 @@ im_set_active(active) /* If 'imdisable' is set, XIM is never active. */ if (p_imdisable) active = FALSE; -#ifndef FEAT_GUI_GTK +#if !defined (FEAT_GUI_GTK) && !defined (FEAT_GUI_KDE) else if (input_style & XIMPreeditPosition) /* There is a problem in switching XIM off when preediting is used, * and it is not clear how this can be solved. For now, keep XIM on @@ -4386,6 +4391,8 @@ xim_set_preedit() gdk_ic_set_attr(xic, attr, (GdkICAttributesType)attrmask); } #else /* FEAT_GUI_GTK */ +# ifdef FEAT_GUI_KDE +# else { XVaNestedList attr_list; XRectangle spot_area; @@ -4432,6 +4439,7 @@ xim_set_preedit() XFree(attr_list); } } +# endif /* FEAT_GUI_KDE */ #endif /* FEAT_GUI_GTK */ } @@ -4485,6 +4493,8 @@ xim_set_status_area() } # endif #else +# ifdef FEAT_GUI_KDE +# else { XVaNestedList preedit_list = 0, status_list = 0, list = 0; XRectangle pre_area, status_area; @@ -4576,6 +4586,7 @@ xim_set_status_area() if (preedit_list) XFree(preedit_list); } +# endif /* FEAT_GUI_KDE */ #endif } @@ -5350,6 +5361,8 @@ xim_get_status_area_height() #ifdef FEAT_GUI_GTK if (xim_input_style & (int)GDK_IM_STATUS_AREA) return gui.char_height; +#elif defined FEAT_GUI_KDE +#warning FIXME #else if (status_area_enabled) return gui.char_height; diff --git a/src/menu.c b/src/menu.c index 052910f7e..fc8411fbf 100644 --- a/src/menu.c +++ b/src/menu.c @@ -96,7 +96,7 @@ ex_menu(eap) char_u *arg; char_u *p; int i; -#if defined(FEAT_GUI) && !defined(FEAT_GUI_GTK) +#if defined(FEAT_GUI) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_KDE) int old_menu_height; # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) && !defined(FEAT_GUI_W16) int old_toolbar_height; @@ -320,7 +320,7 @@ ex_menu(eap) EMSG(_(e_trailing)); goto theend; } -#if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON)) +#if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) || defined(FEAT_GUI_PHOTON)) old_menu_height = gui.menu_height; # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) && !defined(FEAT_GUI_W16) old_toolbar_height = gui.toolbar_height; @@ -437,7 +437,7 @@ ex_menu(eap) vim_free(map_buf); } -#if defined(FEAT_GUI) && !defined(FEAT_GUI_GTK) +#if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) /* If the menubar height changed, resize the window */ if (gui.in_use && (gui.menu_height != old_menu_height @@ -1843,7 +1843,7 @@ gui_update_menus(modes) } } -#if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ +#if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) \ || defined(FEAT_GUI_PHOTON) || defined(PROTO) /* * Check if a key is used as a mnemonic for a toplevel menu. @@ -2174,6 +2174,7 @@ ex_emenu(eap) } #if defined(FEAT_GUI_MSWIN) \ + || (defined(FEAT_GUI_KDE) && defined(FEAT_MENU)) \ || (defined(FEAT_GUI_GTK) && defined(FEAT_MENU)) \ || defined(FEAT_BEVAL_TIP) || defined(PROTO) /* diff --git a/src/misc1.c b/src/misc1.c index 6c5cb6ab2..63301103e 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -4055,7 +4055,7 @@ getnextcomp(fname) #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \ || defined(FEAT_SESSION) || defined(MSWIN) \ - || (defined(FEAT_GUI_GTK) \ + || ((defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) \ && (defined(FEAT_WINDOWS) || defined(FEAT_DND))) \ || defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG) \ || defined(PROTO) diff --git a/src/misc2.c b/src/misc2.c index 55c44a865..367894789 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -2668,8 +2668,8 @@ get_real_state() } #if defined(FEAT_SESSION) || defined(MSWIN) || defined(FEAT_GUI_MAC) \ - || (defined(FEAT_GUI_GTK) \ - && (defined(FEAT_WINDOWS) || defined(FEAT_DND))) \ + || ((defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) \ + && ( defined(FEAT_WINDOWS) || defined(FEAT_DND)) ) \ || defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG) \ || defined(PROTO) /* diff --git a/src/normal.c b/src/normal.c index 222e47589..8fb8c028d 100644 --- a/src/normal.c +++ b/src/normal.c @@ -2357,7 +2357,7 @@ do_mouse(oap, c, dir, count, fixindent) * NOTE: Ignore right button down and drag mouse events. * Windows only shows the popup menu on the button up event. */ -#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) +#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_KDE) if (!is_click) return FALSE; #endif @@ -2365,7 +2365,7 @@ do_mouse(oap, c, dir, count, fixindent) if (is_click || is_drag) return FALSE; #endif -#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ +#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) \ || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \ || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_PHOTON) if (gui.in_use) diff --git a/src/option.c b/src/option.c index fcbddeae8..948018d3b 100644 --- a/src/option.c +++ b/src/option.c @@ -1019,14 +1019,14 @@ static struct vimoption #endif }, {"guiheadroom", "ghr", P_NUM|P_VI_DEF, -#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) +#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_KDE) (char_u *)&p_ghr, PV_NONE, #else (char_u *)NULL, PV_NONE, #endif {(char_u *)50L, (char_u *)0L}}, {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST, -#if defined(FEAT_GUI) +#if defined(FEAT_GUI) || defined(FEAT_GUI_KDE) (char_u *)&p_go, PV_NONE, # if defined(UNIX) && !defined(MACOS) {(char_u *)"agimrLtT", (char_u *)0L} @@ -1112,7 +1112,7 @@ static struct vimoption (char_u *)&p_ic, PV_NONE, {(char_u *)FALSE, (char_u *)0L}}, {"imactivatekey","imak",P_STRING|P_VI_DEF, -#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) +#if defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) (char_u *)&p_imak, PV_NONE, #else (char_u *)NULL, PV_NONE, @@ -4906,7 +4906,7 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, } #endif -#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) +#if defined(FEAT_XIM) && ( defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) ) else if (varp == &p_imak) { if (gui.in_use && !im_xim_isvalid_imactivate()) @@ -5163,7 +5163,7 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, if (gui.in_use) { p = p_guifont; -# ifdef FEAT_GUI_GTK +# if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) /* * Put up a font dialog and let the user select a new value. * If this is cancelled go back to the old value but don't diff --git a/src/option.h b/src/option.h index 1d2b83c2a..7e04190d6 100644 --- a/src/option.h +++ b/src/option.h @@ -466,7 +466,7 @@ EXTERN char_u *p_guifontwide; /* 'guifontwide' */ # endif EXTERN int p_guipty; /* 'guipty' */ #endif -#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) +#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_KDE) EXTERN long p_ghr; /* 'guiheadroom' */ #endif #ifdef CURSOR_SHAPE @@ -512,7 +512,7 @@ EXTERN int p_icon; /* 'icon' */ EXTERN char_u *p_iconstring; /* 'iconstring' */ #endif EXTERN int p_ic; /* 'ignorecase' */ -#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) +#if defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) EXTERN char_u *p_imak; /* 'imactivatekey' */ #endif #ifdef USE_IM_CONTROL @@ -773,7 +773,7 @@ static char *(p_ve_values[]) = {"block", "insert", "all", NULL}; EXTERN long p_verbose; /* 'verbose' */ EXTERN int p_warn; /* 'warn' */ #if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(LINT) \ - || defined (FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) + || defined (FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_KDE) #define FEAT_WAK EXTERN char_u *p_wak; /* 'winaltkeys' */ #endif diff --git a/src/os_mswin.c b/src/os_mswin.c index 97803a89d..d199f3e24 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -155,12 +155,7 @@ extern char g_szOrigTitle[]; #ifdef FEAT_GUI extern HWND s_hwnd; #else -# if (defined(FEAT_PRINTER) && !defined(FEAT_POSTSCRIPT)) \ - || defined(FEAT_CLIENTSERVER) \ - || (defined(FEAT_EVAL) && !defined(FEAT_GUI)) -# define HAVE_GETCONSOLEHWND static HWND s_hwnd = 0; /* console window handle, set by GetConsoleHwnd() */ -# endif #endif extern int WSInitialized; @@ -1537,7 +1532,7 @@ Trace( #endif //_DEBUG -#ifdef HAVE_GETCONSOLEHWND +#if !defined(FEAT_GUI) || defined(PROTO) # if defined(FEAT_TITLE) && defined(WIN3264) extern HWND g_hWnd; /* This is in os_win32.c. */ # endif @@ -1580,6 +1575,32 @@ GetConsoleHwnd(void) SetConsoleTitle(pszOldWindowTitle); } + +/* + * Console implementation of ":winpos". + */ + int +mch_get_winpos(int *x, int *y) +{ + RECT rect; + + GetConsoleHwnd(); + GetWindowRect(s_hwnd, &rect); + *x = rect.left; + *y = rect.top; + return OK; +} + +/* + * Console implementation of ":winpos x y". + */ + void +mch_set_winpos(int x, int y) +{ + GetConsoleHwnd(); + SetWindowPos(s_hwnd, NULL, x, y, 0, 0, + SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); +} #endif #if (defined(FEAT_PRINTER) && !defined(FEAT_POSTSCRIPT)) || defined(PROTO) diff --git a/src/os_unix.c b/src/os_unix.c index b59d8ff5d..597ca3d34 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1222,6 +1222,13 @@ x_error_handler(dpy, error_event) Display *dpy; XErrorEvent *error_event; { + /* KDE sometimes produces X error that we want to ignore */ +#if defined(FEAT_GUI_KDE) + XGetErrorText(dpy, error_event->error_code, (char *)IObuff, IOSIZE); + STRCAT(IObuff, "\nVim: Got X error but we continue...\n"); + fprintf(stderr, IObuff); + return 0; +#else XGetErrorText(dpy, error_event->error_code, (char *)IObuff, IOSIZE); STRCAT(IObuff, _("\nVim: Got X error\n")); @@ -1231,6 +1238,7 @@ x_error_handler(dpy, error_event) preserve_exit(); /* preserve files and exit */ return 0; /* NOTREACHED */ +#endif } /* @@ -1371,7 +1379,7 @@ get_x11_windis() did_set_error_handler = TRUE; } -#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) +#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) if (gui.in_use) { /* @@ -1798,7 +1806,10 @@ mch_settitle(title, icon) * Note: if "t_TS" is set, title is set with escape sequence rather * than x11 calls, because the x11 calls don't always work */ - +#ifdef FEAT_GUI_KDE + /* dont know why but KDE needs this one as we don't go through the next function... */ + gui_mch_settitle(title, icon); +#endif if ((type || *T_TS != NUL) && title != NULL) { if (oldtitle == NULL diff --git a/src/os_unixx.h b/src/os_unixx.h index 9f4f7eb60..abed14d3b 100644 --- a/src/os_unixx.h +++ b/src/os_unixx.h @@ -92,6 +92,12 @@ # if defined(HAVE_LIMITS_H) && !defined(_LIMITS_H) # include <limits.h> /* for SYS_NMLN (Sinix 5.41 / Unix SysV.4) */ # endif + +/* Define SYS_NMLN ourselves if it still isn't defined (for CrayT3E). */ +# ifndef SYS_NMLN +# define SYS_NMLN 32 +# endif + # include <sys/systeminfo.h> /* for sysinfo */ #endif diff --git a/src/proto.h b/src/proto.h index d89c84731..2471bb67f 100644 --- a/src/proto.h +++ b/src/proto.h @@ -20,7 +20,7 @@ * Machine-dependent routines. */ /* avoid errors in function prototypes */ -# if !defined(FEAT_X11) && !defined(FEAT_GUI_GTK) +# if !defined(FEAT_X11) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_KDE) # define Display int # define Widget int # endif @@ -180,6 +180,10 @@ extern char_u *vimpty_getenv __ARGS((const char_u *string)); /* from pty.c */ # ifdef FEAT_GUI_W32 # include "gui_w32.pro" # endif +# ifdef FEAT_GUI_KDE +# include "gui_kde.pro" +# include "gui_kde_x11.pro" +# endif # ifdef FEAT_GUI_GTK # include "gui_gtk.pro" # include "gui_gtk_x11.pro" diff --git a/src/proto/gui_kde.pro b/src/proto/gui_kde.pro new file mode 100644 index 000000000..3a52fa77c --- /dev/null +++ b/src/proto/gui_kde.pro @@ -0,0 +1,19 @@ +/* gui_kde.c */ +void gui_mch_add_menu __ARGS((vimmenu_T *menu, int idx)); +void gui_mch_add_menu_item __ARGS((vimmenu_T *menu, int idx)); +void gui_mch_set_text_area_pos __ARGS((int x, int y, int w, int h)); +void gui_gtk_set_mnemonics __ARGS((int enable)); +void gui_mch_toggle_tearoffs __ARGS((int enable)); +void gui_mch_destroy_menu __ARGS((vimmenu_T *menu)); +void gui_mch_set_scrollbar_thumb __ARGS((scrollbar_T *sb, long val, long size, long max)); +void gui_mch_set_scrollbar_pos __ARGS((scrollbar_T *sb, int x, int y, int w, int h)); +void gui_mch_create_scrollbar __ARGS((scrollbar_T *sb, int orient)); +void gui_mch_destroy_scrollbar __ARGS((scrollbar_T *sb)); +char_u *gui_mch_browse __ARGS((int saving, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter)); +int gui_mch_dialog __ARGS((int type, char_u *title, char_u *message, char_u *buttons, int def_but, char_u *textfield)); +void gui_mch_show_popupmenu __ARGS((vimmenu_T *menu)); +void gui_mch_find_dialog __ARGS((exarg_T *eap)); +void gui_mch_replace_dialog __ARGS((exarg_T *eap)); +void ex_helpfind __ARGS((exarg_T *eap)); +void gui_make_popup __ARGS((char_u *path_name)); +/* vim: set ft=c : */ diff --git a/src/proto/gui_kde_x11.pro b/src/proto/gui_kde_x11.pro new file mode 100644 index 000000000..7d968d9c5 --- /dev/null +++ b/src/proto/gui_kde_x11.pro @@ -0,0 +1,62 @@ +/* gui_kde_x11.c */ +void gui_mch_prepare __ARGS((int *argc, char **argv)); +void gui_mch_set_blinking __ARGS((long waittime, long on, long off)); +void gui_mch_stop_blink __ARGS((void)); +void gui_mch_start_blink __ARGS((void)); +int gui_mch_init_check __ARGS((void)); +int gui_mch_init __ARGS((void)); +void gui_mch_new_colors __ARGS((void)); +int gui_mch_open __ARGS((void)); +void gui_mch_exit __ARGS((int rc)); +int gui_mch_get_winpos __ARGS((int *x, int *y)); +void gui_mch_set_winpos __ARGS((int x, int y)); +void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height)); +void gui_mch_get_screen_dimensions __ARGS((int *screen_w, int *screen_h)); +void gui_mch_enable_menu __ARGS((int flag)); +void gui_mch_show_toolbar __ARGS((int showit)); +int gui_mch_adjust_charsize __ARGS((void)); +GuiFontset gui_mch_get_fontset __ARGS((char_u *name, int report_error, int fixed_width)); +int gui_mch_init_font __ARGS((char_u *font_name, int fontset)); +GuiFont gui_mch_get_font __ARGS((char_u *name, int report_error)); +void gui_mch_set_font __ARGS((GuiFont font)); +void gui_mch_set_fontset __ARGS((GuiFontset fontset)); +void gui_mch_free_font __ARGS((GuiFont font)); +void gui_mch_free_fontset __ARGS((GuiFontset fontset)); +guicolor_T gui_mch_get_color __ARGS((char_u *name)); +void gui_mch_set_fg_color __ARGS((guicolor_T color)); +void gui_mch_set_bg_color __ARGS((guicolor_T color)); +void gui_mch_draw_string __ARGS((int row, int col, char_u *s, int len, int flags)); +int gui_mch_haskey __ARGS((char_u *name)); +int gui_get_x11_windis __ARGS((Window *win, Display **dis)); +void gui_mch_beep __ARGS((void)); +void gui_mch_flash __ARGS((int msec)); +void gui_mch_invert_rectangle __ARGS((int r, int c, int nr, int nc)); +void gui_mch_iconify __ARGS((void)); +void gui_mch_set_foreground __ARGS((void)); +void gui_mch_draw_hollow_cursor __ARGS((guicolor_T color)); +void gui_mch_draw_part_cursor __ARGS((int w, int h, guicolor_T color)); +void gui_mch_update __ARGS((void)); +int gui_mch_wait_for_chars __ARGS((long wtime)); +void gui_mch_flush __ARGS((void)); +void gui_mch_clear_block __ARGS((int row1, int col1, int row2, int col2)); +void gui_mch_clear_all __ARGS((void)); +void gui_mch_delete_lines __ARGS((int row, int num_lines)); +void gui_mch_insert_lines __ARGS((int row, int num_lines)); +void clip_mch_request_selection __ARGS((VimClipboard *cbd)); +void clip_mch_lose_selection __ARGS((VimClipboard *cbd)); +int clip_mch_own_selection __ARGS((VimClipboard *cbd)); +void clip_mch_set_selection __ARGS((VimClipboard *cbd)); +void gui_mch_menu_grey __ARGS((vimmenu_T *menu, int grey)); +void gui_mch_menu_hidden __ARGS((vimmenu_T *menu, int hidden)); +void gui_mch_draw_menubar __ARGS((void)); +void gui_mch_enable_scrollbar __ARGS((scrollbar_T *sb, int flag)); +long_u gui_mch_get_rgb __ARGS((guicolor_T pixel)); +int gui_mch_get_mouse_x __ARGS((void)); +int gui_mch_get_mouse_y __ARGS((void)); +void gui_mch_setmouse __ARGS((int x, int y)); +void gui_mch_mousehide __ARGS((int hide)); +void mch_set_mouse_shape __ARGS((int shape)); +char_u *gui_mch_font_dialog __ARGS((char_u *oldval)); +void gui_mch_settitle __ARGS((char_u *title,char_u *icon)); +void gui_mch_update_codec __ARGS((void)); +/* vim: set ft=c : */ diff --git a/src/proto/misc2.pro b/src/proto/misc2.pro index cbe2af759..899018be5 100644 --- a/src/proto/misc2.pro +++ b/src/proto/misc2.pro @@ -17,7 +17,9 @@ void check_cursor __ARGS((void)); void adjust_cursor_col __ARGS((void)); int leftcol_changed __ARGS((void)); void vim_mem_profile_dump __ARGS((void)); +#ifndef __cplusplus char_u *alloc __ARGS((unsigned size)); +#endif char_u *alloc_clear __ARGS((unsigned size)); char_u *alloc_check __ARGS((unsigned size)); char_u *lalloc_clear __ARGS((long_u size, int message)); diff --git a/src/proto/os_mswin.pro b/src/proto/os_mswin.pro index b4612f0d0..c9e495d61 100644 --- a/src/proto/os_mswin.pro +++ b/src/proto/os_mswin.pro @@ -33,6 +33,8 @@ char_u *ucs2_to_enc __ARGS((short_u *str, int *lenp)); void clip_mch_request_selection __ARGS((VimClipboard *cbd)); void clip_mch_set_selection __ARGS((VimClipboard *cbd)); void DumpPutS __ARGS((const char *psz)); +int mch_get_winpos __ARGS((int *x, int *y)); +void mch_set_winpos __ARGS((int x, int y)); void mch_print_cleanup __ARGS((void)); int mch_print_init __ARGS((prt_settings_T *psettings, char_u *jobname, int forceit)); int mch_print_begin __ARGS((prt_settings_T *psettings)); diff --git a/src/screen.c b/src/screen.c index 594c42479..8a5b4214b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -2594,7 +2594,7 @@ win_line(wp, lnum, startrow, endrow) #endif #define WL_LINE WL_SBR + 1 /* text in the line */ int draw_state = WL_START; /* what to draw next */ -#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) +#if defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) int feedback_col = 0; int feedback_old_attr = -1; #endif @@ -3785,7 +3785,7 @@ win_line(wp, lnum, startrow, endrow) && (search_attr == 0 || char_attr != search_attr)) char_attr = extra_attr; -#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) +#if defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) /* XIM don't send preedit_start and preedit_end, but they send * preedit_changed and commit. Thus Vim can't set "im_is_active", use * im_is_preediting() here. */ diff --git a/src/structs.h b/src/structs.h index 0edd729da..9e6d4e249 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1751,6 +1751,9 @@ struct VimMenu Widget id; /* Manage this to enable item */ Widget submenu_id; /* If this is submenu, add children here */ #endif +#ifdef FEAT_GUI_KDE + QPopupMenu *widget; +#endif #ifdef FEAT_GUI_GTK GtkWidget *id; /* Manage this to enable item */ GtkWidget *submenu_id; /* If this is submenu, add children here */ @@ -1511,7 +1511,7 @@ vim_free_in_input_buf() } #endif -#if defined(FEAT_GUI_GTK) || defined(PROTO) +#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) || defined(PROTO) int vim_used_in_input_buf() { @@ -1593,7 +1593,7 @@ add_to_input_buf(s, len) } #endif -#if (defined(FEAT_XIM) && defined(FEAT_GUI_GTK)) \ +#if (defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE))) \ || (defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)) \ || defined(PROTO) /* @@ -2876,7 +2876,7 @@ mouse_find_win(rowp, colp) } #endif -#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined (FEAT_GUI_MAC) \ +#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined (FEAT_GUI_MAC) || defined (FEAT_GUI_KDE) \ || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \ || defined(FEAT_GUI_PHOTON) || defined(PROTO) /* diff --git a/src/version.c b/src/version.c index 01293435e..a51550fe6 100644 --- a/src/version.c +++ b/src/version.c @@ -859,6 +859,10 @@ list_version() # else # if defined (MACOS) MSG_PUTS(_("with (classic) GUI.")); +# else +# ifdef FEAT_GUI_KDE + MSG_PUTS(_("with KDE GUI.")); +# endif # endif # endif # endif diff --git a/src/version.h b/src/version.h index 2d98d2874..5799d9cc4 100644 --- a/src/version.h +++ b/src/version.h @@ -36,5 +36,5 @@ #define VIM_VERSION_NODOT "vim70aa" #define VIM_VERSION_SHORT "7.0aa" #define VIM_VERSION_MEDIUM "7.0aa ALPHA" -#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2004 June 7)" -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2004 June 7, compiled " +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2004 June 30)" +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2004 June 30, compiled " @@ -88,7 +88,8 @@ || defined(FEAT_GUI_W16) \ || defined(FEAT_GUI_BEOS) \ || defined(FEAT_GUI_AMIGA) \ - || defined(FEAT_GUI_PHOTON) + || defined(FEAT_GUI_PHOTON) \ + || defined(FEAT_GUI_KDE) # ifndef FEAT_GUI # define FEAT_GUI # endif @@ -212,7 +213,15 @@ # define __PARMS(x) __ARGS(x) #endif -#if defined(UNIX) && !defined(MACOS_X) /* MACOS_X doesn't yet support osdef.h */ +/* if we're compiling in C++ (currently only KVim), the system + * headers must have the correct prototypes or nothing will build. + * conversely, our prototypes might clash due to throw() specifiers and + * cause compilation failures even though the headers are correct. for + * a concrete example, gcc-3.2 enforces exception specifications, and + * glibc-2.2.5 has them in their system headers. + */ +#if !defined(__cplusplus) && defined(UNIX) \ + && !defined(MACOS_X) /* MACOS_X doesn't yet support osdef.h */ # include "auto/osdef.h" /* bring missing declarations in */ #endif @@ -1022,6 +1031,9 @@ enum auto_event EVENT_FOCUSGAINED, /* got the focus */ EVENT_FOCUSLOST, /* lost the focus to another app */ EVENT_GUIENTER, /* after starting the GUI */ + EVENT_INSERTCHANGE, /* when changing Insert/Replace mode */ + EVENT_INSERTENTER, /* when entering Insert mode */ + EVENT_INSERTLEAVE, /* when leaving Insert mode */ EVENT_STDINREADPOST, /* after reading from stdin */ EVENT_STDINREADPRE, /* before reading from stdin */ EVENT_SYNTAX, /* syntax selected */ @@ -1473,7 +1485,8 @@ int vim_memcmp __ARGS((void *, void *, size_t)); #define VV_THROWPOINT 30 #define VV_REG 31 #define VV_CMDBANG 32 -#define VV_LEN 33 /* number of v: vars */ +#define VV_INSERTMODE 33 +#define VV_LEN 34 /* number of v: vars */ #ifdef FEAT_CLIPBOARD @@ -1572,7 +1585,7 @@ typedef int VimClipboard; /* This is required for the prototypes. */ * been seen at that stage. But it must be before globals.h, where error_ga * is declared. */ #if !defined(FEAT_GUI_W32) && !defined(FEAT_GUI_X11) \ - && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MAC) + && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_KDE) && !defined(FEAT_GUI_MAC) # define mch_errmsg(str) fprintf(stderr, "%s", (str)) # define display_errors() fflush(stderr) # define mch_msg(str) printf("%s", (str)) |