From d0487877d453d31a63709f84678566a7f27f7db7 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 17 May 2024 09:25:31 -0300 Subject: vim: include vimacs manually The Vimacs plugin (form vim-scripts) includes a "tab-indent" file which we don't want the behavior of. It's convenient enough to just drop the file, but we have to manually include the files we *do* want instead of using a submodule. --- .vim/pack/editing/start/vimacs/doc/vimacs.txt | 1366 ++++++++++++++++++++ .../editing/start/vimacs/plugin/vimacs-0.93.vim | 931 +++++++++++++ 2 files changed, 2297 insertions(+) create mode 100644 .vim/pack/editing/start/vimacs/doc/vimacs.txt create mode 100644 .vim/pack/editing/start/vimacs/plugin/vimacs-0.93.vim diff --git a/.vim/pack/editing/start/vimacs/doc/vimacs.txt b/.vim/pack/editing/start/vimacs/doc/vimacs.txt new file mode 100644 index 0000000..969e456 --- /dev/null +++ b/.vim/pack/editing/start/vimacs/doc/vimacs.txt @@ -0,0 +1,1366 @@ +*vimacs.txt* Vimacs: Emacs mappings (emulation) for Vim + +|Vimacs.01| Introduction +|Vimacs.02| Installing Vimacs +|Vimacs.03| Vimacs Options +|Vimacs.04| Changes for Emacs users +|Vimacs.05| Changes for Vim users +|Vimacs.06| Key Map +|Vimacs.07| Design Comments +|Vimacs.08| Known Problems +|Vimacs.09| Revision History (ChangeLog) +|Vimacs.10| In the Future ... (TODO list) +|Vimacs.11| Contact, Help, Credits + + +============================================================================== +*Vimacs.01* Introduction + + *vimacs* + + *vimacs-introduction* + +Vimacs (Vim-Improved eMACS) brings Emacs' extensive key bindings and modeless +editing features to the Vim world, while completely retaining Vim's +powerful moded editing style. + +Vimacs is based on the keymaps of GNU Emacs 21 and XEmacs, so if you are +familiar with them, you'll feel right at home in Vimacs. For Emacs users, +most (if not all) of the common key maps in Emacs are present in Vimacs, such +as , and to mark, kill and yank regions, to +find a file, and 2 to vertically split a window. However, you can now +take advantage of the incredible power of Vim's Normal and Command modes with +a touch of the key. + +Why use Vimacs instead of Emacs? Vim's configuration and option tweaking is +arguably much easier than doing the same task in the Emacs world; its +scripting language is simpler and more conventional than LISP, and still very +powerful. Python, Perl, and |libcall()| (C library interface) support allow +for incredibly powerful scripting if you need something which is the equal of +ELISP. Vim is heavily optimised for speed and text editing; you may find Vim +to be much quicker in many tasks. While Emacs and Vim may run on equally as +many platforms, Vim often has superior support for non-Unix operating systems +in comparison to Emacs; e.g. Vim for Win32 can natively function as a DDE +server and can integrate into Microsoft Visual Studio. + +If you're a long-time Vim user, you retain vi's powerful moded editing +paradigm while gaining all the benefits of Emacs' modeless editing. After a +while, the and keys will become second nature to you, just as +you're used to the |h|, |j|, |k|, and |l| keys for movement. Some of the keys +familiar to you in Insert mode have been changed, but you won't take long to +get used to Emacs' keys: just like Vim, Emacs' key layout has been designed so +that commonly used keys are quick to access. Emacs' initially strange key +layout will reward you later on for its efficiency, just like Vim does. Emacs +experts are just as fast as Vim experts in manipulating text, and as a bonus, +you start becoming familiar with Emacs keybindings, which are gradually +becoming more pervasive in Unix applications. (Even MacOS X supports some +Emacs keys in its dialog boxes!) + + *vimacs-terminology* + +Vim and Emacs use different (and sometimes conflicting) terminology. Since +Vimacs runs within the Vim environment, we will use the Vim terminology rather +than Emacs terminology. + + Emacs Terminology Vim Terminology + + (key)binding map + point cursor + kill yank + yank paste + register mark + rectangle block + kill-ring registers + +It is Vim standard that key bindings are written in |<>| notation; thankfully +this is essentially the same as Emacs' key binding notation. In Emacs, the +key combination Control-x followed by Control-f is written as "C-x C-f"; in +Vim, this is written as "". Meta-f in Emacs is written as "M-f"; in +Vim, this is written as "" or "". (The 'A' stands for Alt; in Vim, +there is no distinction between the Meta and Alt keys.) Vim helpfiles also +use a |CTRL-X_CTRL-F|-style notation; Vimacs-specific keys will use a +|vimacs:CTRL-X_CTRL-F| notation. + +For the gory details of Vim notation, see |notation|. + + *vimacs-help-navigation* + +Emacs users: If you are not in insert mode (if you do not see a line at the +bottom of the screen saying "-- INSERT MODE --"), use to follow a link, +and to go back a link. If you are using Vimacs keybindings and are in +Insert mode, you can follow a help link such as |vimacs-introduction| by +moving your cursor over it and pressing . This is the same as Emacs' +typical keybinding, which is the |vimacs:find-tags| command. Jump back +to your previous position using the key. + +Vim users: Pressing in Insert mode performs the same function as +|CTRL-]| in Normal mode. is equivalent to |CTRL-T|. + + +============================================================================== +*Vimacs.02* Installing Vimacs + + *vimacs-quickstart* + +The following quick start guides are for Win32 and Unix systems. Detailed +installation instructions follow afterward. + + *vimacs-win32-quickstart* + +Firstly, you'll need Vim 6 installed. Vimacs won't work on older +versions. + +To install Vimacs, copy the .txt file in the archive to your Vim +documentation directory (typically "C:\Program Files\vim\vimfiles\doc"), +and copy the .vim file to your plugin directory (typically "C:\Program +Files\vim\vimfiles\plugin"). + +See the |vimacs-installation| topic in the main Vimacs help file for full +information. + + *vimacs-unix-quickstart* + +Firstly, you'll need Vim 6 installed. Vimacs won't work on older +versions. So, make sure you're running Vim 6: +> + vim --version | head -1 +< +The reply you get should say "VIM - Vi IMproved 6.0" (or higher). + +To install Vimacs, execute the following commands in your shell: +> + mkdir -p $HOME/.vim/doc + mkdir -p $HOME/.vim/plugin + cp -R doc plugin $HOME/.vim +< +Run the following command in a shell to make Vim rescan your documentation +directory: +> + vim --cmd "helptags $HOME/.vim/doc" --cmd "q" +< +That's it. If you're a Vim user, Emacs key mappings will now be enabled +whenever you're in Vim's Insert mode. If you're an Emacs user and have +never used Vim before, you probably want to always keep Vim in Insert +Mode, and use Select mode rather than Visual mode: +> + echo 'set insertmode' >> $HOME/.vimrc + echo 'set selectmode += cmd' >> $HOME/.vimrc +< +Vimacs is now completely installed. However ... + +If you want to have a more sophisticated setup, where you can type a +different command (such as 'vimacs') to always start in Insert mode, but +typing 'vim' starts Vim in Normal mode, read on. + +Put the shell script located at plugin/vimacs/vim somewhere in your $PATH, +and symlink it to the appropriate files. Change the $myscriptdir variable +below to whatever directory you use for scripts; if you don't currently +have one, you'll need to mkdir the directory and add it to your $PATH. +(Consult your local Unix expert on adding directories to your $PATH if you +don't know how to do this.) +> + myscriptdir=$HOME/bin + mkdir -p $myscriptdir + cp plugin/vimacs/vim $myscriptdir + chmod 755 $myscriptdir/vim + ln -s $myscriptdir/vim $myscriptdir/gvim + ln -s $myscriptdir/vim $myscriptdir/vm + ln -s $myscriptdir/vim $myscriptdir/gvm + ln -s $myscriptdir/vim $myscriptdir/vimacs + ln -s $myscriptdir/vim $myscriptdir/gvimacs + myscriptdir= +< +For more detailed installation instructions, see |vimacs-installation| in +the Vimacs help file. + + *vimacs-installation* + +Vimacs is designed for Vim 6 only; if you are running Vim 5.x, please upgrade +to Vim 6. There is no intention to `port' Vimacs to run on older versions of +Vim. + +Vimacs is a Vim 6 plugin; simply drop it into any Vim plugin directory, such +as "$HOME/.vim/plugin" on a Unix system, or "C:\Program +Files\vim\vimfiles\plugin" on Windows. You may also want to place this +documentation (the "vimacs.txt" file) in a Vim documentation directory; e.g. +"$HOME/.vim/doc", or "C:\Program Files\vim\vimfiles\doc". You should run the +|:helptags| command on the documentation directory after installation; see +|add-local-help| for more information. + +Vimacs does not initially start in Insert mode, to be consistent with what Vim +users normally expect. If you an Emacs user, you may wish to put +> + set insertmode + set selectmode += cmd +< +in your |.vimrc| startup file, so that you use a more Emacs-like selection +mode, as well as being in Insert mode straight away. + +Please read the |vimacs-unix| section if you are running Vimacs on a Unix +systems, and |vimacs-non-unix| if you are installing Vimacs on other operating +systems (e.g. Windows, Macintosh). + + *vimacs-unix* + *vimacs-unix-flow-control* + +Like Emacs, Vimacs uses the key to search, and to insert the next +character literally ('quoted-insert' in Emacs-speak; normally in Vim). + +In many Unix terminals, and are flow control characters used to +stop and start terminal output, which means that Vim will look like it has +frozen when you press . (This problem only affects the Unix console +version of Vim; gvim is not affected.) Emacs modifies your terminal's +settings, so it doesn't normally have this problem. Vim, however, does not +modify terminal settings, and thus you need to explicitly turn off flow +control. + +To solve the / flow control problem, you need to turn off XON/XOFF +flow control processing for your tty. The stty(1) command will do this: +> + $ stty -ixon -ixoff +< +You may wish to make a shell script somewhere in your path to do this +automatically, e.g. +> + $ cat << END > $HOME/bin/vim + #!/bin/sh + + # turn off flow control if we're a terminal + [ -t 0 ] && stty -ixon -ixoff + + exec /usr/bin/vim "$@" + END +< +For a more in-depth example of using a wrapper shell script to initialise Vim +(and Vimacs) to your choosing, see |vimacs-unix-progname| + + *vimacs-unix-meta-sends-esc* + +This applies to the console version of Vim only (i.e. not gvim). On many Unix +terminals, the Meta key typically generates an followed by the +combination key; for example, pressing generates the key sequences +x. However, you may have a terminal emulator that sends as an 'x' +with the 8th bit set, rather than as x. Most Unix terminal emulators, +(including xterm) have an option to do this, but do not enable it by default. +If your terminal sends as x with the 8th bit set, set the +|'g:VM_UnixConsoleRemapEsc'| option to 1. + +NOTE: This is not a Vimacs-specific problem; Vim also has to work around this +issue, with options like 'esckeys', 'timeout' and 'ttimeout'. + + *vimacs-unix-progname* + +Via the magic of shell scripts (and symlinks), it's possible to change the +default behaviour of Vimacs, depending on what you typed to run it. For +example: + + Command name Load Vimacs? Start in/use Insert mode? + + (g)vim yes no/no + (g)vimacs yes yes/yes + (g)vm[1] yes yes/yes + + 1. `vm' is an abbreviation for `ViMacs' + +To do the above, firstly, make a directory to store programs and scripts in, +and add that directory to your $PATH: +> + $ mkdir $HOME/bin + $ export PATH="$HOME/bin:$PATH" +< +Save the following shell script in the above directory as "vim". For +convenience, this script is also available in the plugin/vimacs directory; +simply copy it to $HOME/bin/vim. +> + #!/bin/sh + + # real path to vim + VIM_CMD=${VIM_CMD:-/usr/bin/vim} + GVIM_CMD=${GVIM_CMD:-/usr/bin/gvim} + + # what program name was i run as? + argv0=`basename $0` + + # turn off software flow control so and will work. you can add + # extra stty settings by setting $VIM_STTY (i use 'erase ^?' here) + [ -t 0 ] && stty -ixon -ixoff $VIM_STTY + + case "$argv0" in + g*) + VIM_CMD="$GVIM_CMD" + ;; + esac + + case "$argv0" in + *diff) + VIM_CMD="${VIM_CMD}diff" + ;; + esac + + case "$argv0" in + # This case has to come before *vim*, since *vim* will match *vimacs* + *vm*|*vimacs*) + exec $VIM_CMD --cmd "let g:VM_Enabled = 1" \ + --cmd "set insertmode" \ + "$@" + ;; + *vim*) + exec $VIM_CMD --cmd "let g:VM_Enabled = 1" \ + "$@" + ;; + esac + +< +Now, make your vim command executable: +> + chmod a+x $HOME/bin/vim +< +Finally, make symlinks from the `vim' shell script to the other commands +you'll be running it as: +> + ln -s $HOME/bin/vim $HOME/bin/gvim + ln -s $HOME/bin/vim $HOME/bin/vm + ln -s $HOME/bin/vim $HOME/bin/gvm + ln -s $HOME/bin/vim $HOME/bin/vimacs + ln -s $HOME/bin/vim $HOME/bin/gvimacs + ln -s $HOME/bin/vim $HOME/bin/vimdiff + ln -s $HOME/bin/vim $HOME/bin/gvimdiff + ln -s $HOME/bin/vim $HOME/bin/vmdiff + ln -s $HOME/bin/vim $HOME/bin/gvmdiff + ln -s $HOME/bin/vim $HOME/bin/vimacsdiff + ln -s $HOME/bin/vim $HOME/bin/gvimacsdiff +< +Now, after all that hard work, you can give Vim different personalities +just by running a different command name! + + *vimacs-non-unix* + +There are no special notes for running Vimacs on non-Unix operating systems. + + +============================================================================== +*Vimacs.03* Vimacs Options + + *vimacs-options* + +Vimacs can change its behaviour to your liking by setting variables in your +Vim startup file ("$HOME/.vimrc" in Unix; "C:\Program Files\vim\_vimrc" in +Windows; see |.vimrc| for more information). You can set variables using +|:let| command, e.g. + +> + let g:VM_CmdHeightAdj = 0 + let g:VM_NormalMetaXRemap = 1 +< + + *vimacs-option-list* + + *'g:VM_CmdHeightAdj'* + +'g:VM_CmdHeightAdj' number (default 1) + + Adjust the current 'cmdheight' setting. Vimacs will normally increase + the 'cmdheight' option to 2 if it's less than 2 and the 'showmode' + option is set, because the mode message will often obscure the most + recent message. + + *'g:VM_Dev'* + +'g:VM_Dev' number (default 0) + + Turn on "developer mode"; forces overwriting of commands, functions + and maps which already exist when Vimacs is loaded. Vimacs will not + typically load its own commands, functions or mappings if one + currently exist. + + *'g:VM_Enabled'* + +'g:VM_Enabled' number (default 1) + + Don't load Vimacs at all. May be useful in your startup script, e.g. + for Unix people who use the "less" Vim script: +> + if v:progname == "less" + source /usr/share/doc/vim/macros/less.vim + let g:VM_Enabled = 0 + endif +< + *'g:VM_F10Menu'* + +'g:VM_F10Menu' number (default 1) + + Enable the key to pull down the menus which are normally only + available in the GUI version of Vim. (GNU Emacs uses F10 for this + purpose.) + + *'g:VM_NormalMetaXRemap'* + +'g:VM_NormalMetaXRemap' number (default 1) + + In Normal mode, map the key to go to Command mode (i.e. it has + the same effect as typing |:|). + + NOTE: is always enabled in Insert mode; this option affects + in Normal mode only. + + *'g:VM_SearchRepeatHighlight'* + +'g:VM_SearchRepeatHighlight' number (default 0) + + Highlight all occurances of your current search on the screen when you + repeat a search with or . This effectively turns on the + 'hls' option while you're searching. + + *'g:VM_SingleEscToNormal'* + +'g:VM_SingleEscToNormal' number (default 1) + + Only need to press the once in Insert mode to return to Normal + mode. If this option is off, you need to press to return + to Normal mode; see |vimacs-unix-esc-key| for rationale. + + *'g:VM_UnixConsoleMetaSendsEsc'* + +'g:VM_UnixConsoleMetaSendsEsc' number (default 1) + + Remap x to become (where x is any keypress); this is needed + for Unix terminals which send a Meta key as an Escape sequence, rather + than sending the keypress with the 8th bit on. Most Unix terminals + seem to do that these days. + + *vimacs-vim-options* + +Vimacs's operation is heavily influenced by a few of Vim's options. You can +set them in the usual manner (with the |:set| command). + + *'vimacs-backspace'* +'backspace' 'bs' string (default "") + global + {not in Vi} + + Vimacs will automatically set this option, since pressing in + Emacs typically backspaces over anything and everything :). + + *'vimacs-cedit'* +'cedit' string (Vi default: "", Vim default: CTRL-F) + global + {not in Vi} + {not available when compiled without the |+vertsplit| + feature} + + Currently, Vimacs relies on the 'cedit' option to be CTRL-F. This is + regarded as a bug, and will hopefully be fixed in the future. + + *'vimacs-esckeys'* +'esckeys' 'ek' boolean (Vim default: on, Vi default: off) + global + {not in Vi} + + Vimacs automatically sets this option. (Note that strictly speaking, + this may not be necessary ... please send me a patch if you can't live + with this behaviour). + + *'vimacs-hidden'* +'hidden' 'hid' boolean (default off) + global + {not in Vi} + + Vimacs will automatically set this option; Emacs always "hidden + buffers". + + *'vimacs-incsearch'* +'incsearch' 'is' boolean (default off) + global + {not in Vi} + {not available when compiled without the + |+extra_search| feature} + + CTRL-S (incremental search forward) and CTRL-R (incremental search + backward) will override Vim's 'incsearch' option; they will always do + an incremental search. + + *'vimacs-insertmode'* + +'insertmode' 'im' boolean (default off) + global + {not in Vi} + + Setting the 'insertmode' option makes Insert mode the default mode, + and effectively makes Vim modeless. This is important for Vimacs + since it allows for a much more complete emulation of Emacs. (See + Vim's 'insertmode' help entry for more detail.) + + When 'insertmode' is set and Vimacs is active, the CTRL-O and CTRL-L + keys change to the Emacs behaviour, and still escapes back to + normal mode. + + See also: the |'g:VM_SingleEscToNormal'| option and + |vimacs-unix-esc-key|. + + *'vimacs-keymodel'* +'keymodel' 'km' string (default "") + global + {not in Vi} + + Vimacs will automatically manipulate this option to ensure that + marking blocks using (and the key, if the "key" word + is included in 'selectmode') works as intended. + + *'vimacs-selection'* +'selection' 'sel' string (default "inclusive") + global + {not in Vi} + + Vimacs will change the default value of this option to "exclusive", + since it's very much more Emacs-like in its behaviour. + + *'vimacs-selectmode'* +'selectmode' 'slm' string (default "") + global + {not in Vi} + + If the "cmd" word is in the 'selectmode' option, Vimacs will use + Select mode when marking a block using . + + *'vimacs-timeout'* +'timeout' 'to' boolean (default on) + global + *'vimacs-ttimeout'* +'ttimeout' boolean (default off) + global + {not in Vi} + + Vimacs will automatically set these options for optimal behaviour, + depending on whether the 'insertmode' and |'g:VM_SingleEscToNormal'| + options are set, and whether you're running in a UNIX console or not. + + This is done for safety reasons; it's quite easy to screw up Vim if + use key mappings extensively and you're running in a UNIX + console. + + *'vimacs-whichwrap'* +'whichwrap' 'ww' string (Vim default: "b,s", Vi default: "") + global + {not in Vi} + + Vimacs will automatically manipulate this option to obtain Emacs-like + behaviour. (If you're that pedantic about this option, why on earth + are you using Vimacs in the first place? Send me a patch, send me + a patch ...) + + *'vimacs-wildcharm'* +'wildcharm' 'wcm' number (default: none (0)) + global + {not in Vi} + + Vimacs automatically manipulates this option. If you don't like that, + send me a patch! + + *'vimacs-winaltkeys'* +'winaltkeys' 'wak' string (default "menu") + global + {not in Vi} + {only used in Win32, Motif, GTK and Photon GUI} + + Vimacs will automatically unset this option, since it interferes with + remapping the / keys. + + +============================================================================== +*Vimacs.04* Changes for Emacs users + +Nothing written yet. Send patches or hate mail to the |vimacs-author| :). + + +============================================================================== +*Vimacs.05* Changes for Vim users + +Nothing written yet. Send patches or hate mail to the |vimacs-author| :). + + +============================================================================== +*Vimacs.06* Key Map + +Emacs has many keys, and this section of the documentation is currently +incomplete. If you want to help complete this section, please send me +patches! + +Other than looking at the vimacs.vim script file itself, a suggested way of +learning the Emacs key set is from Emacs itself (and Emacs clones such as jed +and jmacs). Press b in GNU Emacs or XEmacs to get a list of key +bindings. + +Files and Buffers + *vimacs:CTRL-X_CTRL-F* + +CTRL-X CTRL-F Loads a new file into the current window; see |:edit|. + + *vimacs:CTRL-X_CTRL-S* + +CTRL-X CTRL-S Saves the current buffer to disk, but only if's been + modified. See |:update|. + + *vimacs:CTRL-X_s* + +CTRL-X s Saves all changes buffers to disk; see |:wa|. + + *vimacs:CTRL-X_i* + +CTRL-X i Inserts a file into the current buffer. See |:read|. + + *vimacs:CTRL-X_CTRL-W* + +CTRL-X CTRL-W Saves the current buffer to disk as a different filename. + See |:write_f|. + + +Error Recovery + *vimacs:CTRL-_* + *vimacs:CTRL-X_CTRL_U* + +CTRL-_ +CTRL-X CTRL-U Undo your last action. + + +============================================================================== +*Vimacs.07* Design Comments + +This is a collection of anecdotes, design issues and ramblings that I came +across with when writing Vimacs. Vi was certainly never designed to be used +in a modeless way, and Vimacs pushes Vim's modeless functionality to its +limits, so I expected to encounter some bugs^H^H^H^Hundocumented features in +writing Vimacs. Somewhat surprisingly, there seems to be only a few small +problems in Vim which limit Vimacs' Emacs emulation capabilities, and these +tend to be philosophical or conceptual differences between the two editors +rather than being actual bugs. (Quite amazing, considering that the two +editors, at first glance, seem so completely different.) + + *vim-emacs-similarity* + +Many Emacs features actually have a direct 1:1 mapping to Vim commands; for +example, Emacs' |vimacs:META-A| command is exactly the same as Vim's Command +mode |(| command. Thus, many of the Vimacs commands were very simple to +imlpement. + + *cursor-at-eol* + +One of the bigger complications that arose in Vimacs is that the cursor +position is conceptually different between Vim's various modes. In Insert +mode, Vim's cursor is treated as being _between_ two characters, not "on" a +character. + +In Normal mode, the cursor is treated as being "on" a character, and not +between the characters. (If you use gvim, you can see that the cursor is a +normal block shape in Command mode, but the shape changes to a thin vertical +line in Insert Mode.) This means that switching from Insert mode to Normal +mode can cause problems if you're at the end of a line. The cursor seems to +'jump back' a character, because the cursor is _after_ the last character in +Insert mode, and when you revert to Normal mode, the cursor cannot be past the +end of the line, so it goes to the last character on the line. Going back to +Insert Mode from there therefore puts your cursor one character back from the +end of the line, rather than being at the end of the line. + +You can use the |a| command instead of the |i| to solve this problem, but then +you lose precision at the beginning of the line, rather than at the end. It's +not a particularly easy problem to solve; I hope that Bram Moolenar provides +an option to change this behaviour in the future. + + *remapping-CTRL_O* + +In Emacs, the key is mapped to `open-line'; in Vim, executes one +command in Normal mode, and then returns to Insert mode (see |i_CTRL-O|). +This poses a problem: internally, Vim uses for many commands, and +remapping it to `open-line' causes problems. Commands such as |:amenu| use + to return to Normal mode from Insert mode, and thus remapping can +lead to interesting problems. + +There will be an option in the future to prevent from being remapped at +all; of course, this means that you can't remap the to a function at +all, which isn't ideal. + +The `proper' way to fix this would be for Vim to limit the mapping to +Insert mode only, and fix the other commands (such as |:amenu|) so that they +always use the unmapped version of . + + *vimacs-quotes* + +Conrad Parker: "Dude, I gotta get you doing some serious hacking +projects" + +Erik de Castro Lopo: "Oh, so you're the insane guy that K was talking +about" + +Wichert Akkerman: "Gross. Horror. Vim abuse. Mind if I include this as +an example in the Debian vim packages? :)" + +(add yours here if you like :) + + +============================================================================== +*Vimacs.08* Known Problems + + *vimacs-and-lazyredraw* + +Vim seems to be a bit buggy and occasionally doesn't redraw the screen +properly when it should, if you have the 'lazyredraw' option set. Please turn +it off if you notice redraw glitches. + +This is a problem in Vim, not Vimacs, but Vimacs seems to exarcerbate the +problem. + + *vimacs-meta-d-at-eol* + +Pressing at the end of the line (EOL) doesn't delete the word. + + *vimacs-unix-esc-key* + +On Unix console systems (i.e. not gvim), you may get a warning when you press + twice telling you to use the or keys to return to Normal +mode. i.e. You can't do a simple press to return to Normal mode, as you +normally do in Vi(m). In a nutshell, this is because of Vim's 'insertmode' +option. + +When 'insertmode' is turned on, Vim normally remaps the key so that +novice users don't find themselves in Vim's Normal mode if they accidently hit +. Remember that 'insertmode' is originally designed for |evim|, which is +a point-and-click editor in the style of Windows Notepad. You don't want +users winding up in Normal mode if they want something as simple as Notepad! + +Due to the way that Unix terminals were originally designed, if: + + 1. you are running Vimacs in a Unix console, + 2. have |g:VM_UseInsertMode| (and the 'insertmode' option) set + 3. have |g:VM_UnixConsoleRemapEsc| set + 4. have |g:VM_SingleEscToNormal| set + +when Vim receives an key, it is completely impossible to determine +whether it is part of a Meta key mapping (such as ) or the single +key press that you did to get out of Insert mode. The simple solution to this +is: either get used to the or keys to get back to Insert mode, or +change one of the above g:VM_ settings. There's no way around it, sorry; this +is a limitation in the way that Vim and Unix consoles were designed. + +Another way to solve the problem is to always make the user press twice +to get back to Normal mode. Vim will interpret an in an +unambigious way, and therefore you will never have this problem. To do this, +turn off the |'g:VM_SingleEscToNormal'| option. The obvious problem with this +solution is that you need to change your habits, so that you must press + to return to Normal mode, rather than a simple . + +Deep Vim and Unix hackers may be interested to hear why this happens. Vim can +normally tell whether the key is part of a Meta key sequence (such as +f), by using its multitude of |:timeout|-related options. However, if +|:insertmode| is set (which it is if |g:VM_UseInsertMode| is set), Vim changes +the key so that it no longer brings you out of Insert mode. To get +around this, we remap the ourselves so that it does bring you out of +Insert mode. We can do this in an environment which has a completely +unambigious key; i.e. an is always an . However, in the Unix +console, since many (most?) terminals send a combo as x, we must +change Vim's terminal settings to interpret a x as . However, now +there's no way for Vim to tell whether the first is a single by +itself, or part of a larger sequence like x, because we have both the + key remapped to and the key being part of a larger key +sequence. This unfortunate design flaw is therefore a limitation of both Vim +(because it changes the normal behaviour of ) and the Unix console +(because whoever designed the original terminals decided to put the real +key on the keyboard, which should never have happened). Any suggestions to +fix this annoying situation would save me a lot of pain :). + + *vimacs-'cedit'* + +See the |'vimacs-cedit'| topic in the option summary for details. + + + +============================================================================== +*Vimacs.09* Revision History (ChangeLog) + + *vimacs-changelog* + + *vimacs-0.93* + +Made the thankyou (credits) list look a bit nicer :). + + *vimacs-0.92* + + and now cycle through the QuickFix list rather than perform the +next/previous search + + at EOL now deletes the word at the start of the next line, +instead of the last character at the end of the current line + + on command line now deletes the word before the cursor + + on command line copies the selection (to register) + + on command line pastes the selection + +Indenting on key moved to a tab-indent.vim + + *vimacs-0.91* + +Moved vi check to be much earlier in the script + +Rewrote : it's (much) simpler now + +Updated Unix installation notes + + at EOL will now include the last character on the line + +Use Vim's 'keymodel' option instead of own g:VM_VisualMode variable + +Use Vim's 'selectmode' option instead of own g:VM_ShiftSel variable + + *vimacs-0.9* + +Added Piet Delport to THANKS section + +Wrote a function to initialise a variable to a default value, with Piet's help + +Added Barrie Stott to THANKS section + +Added navigation keys such as to Operator Pending mode (actually done in +0.2, but I forgot to add it to the ChangeLog. Oops.) + +Automatically pop up list of buffers for b + +Added , , , to select region (for +g:VM_ShiftSel) + +Added commandline abbreviations for query_replace + +Added to normal mode (yeah, I kept hitting instead of just typing +a colon (':'); sad, innit? + + is now remapped in Insert mode instead of Normal mode + + (query-replace) and (query-replace-regexp) now escape / +characters, so the s/// doesn't get messed up + +Remapped to (for UNIX terminals) + + (fill-paragraph) now leaves cursor at fill point, thanks to the +very useful Mark() function stolen from foo.vim by Benji Fisher. + +Added ... bindings for quick escape into Normal mode + +Added (that's Meta and a backtick) to return to Normal mode + +Added to pulldown the menus (in the GUI system), ala GNU Emacs + +Added VM_Enabled variable to allow users to not load Vimacs + +Properly fixed mapping of x keys to keys, using the :set +command rather than :map + +Added r when in Visual mode to switch to Visual Block mode; this is +meant to (poorly) emulate Emacs' rectangle support. It'll almost +definitely be changed at a later date, because this isn't similar to how +Emacs works at all + +Changed mappings to (see :help ; it doesn't +mention that it's case-sensitive!) + +Made and search forward/backward from within a search prompt + +Added Hari Krishna Dara & Arun Easi to THANKS section + +Made be more Emacs-like by making Vim go into Select mode rather +than Visual mode. (This is now the default; set g:VM_VisualMode to 1 to +change it back to the old behaviour where triggers Visual mode.) + +Added g:VM_SearchRepeatHighlight option, which highlights the current item +you're searching for if you press or to search again + +Default for g:VM_AlwaysRemapEsc changed from 0 to 1, to maintain interface +consistency throughout all of vim's console/GUI versions + +Initial formal documentation (vimacs.txt: check it out!) + +Fixed to leave one line + +Added (toggle-readonly) + +Added (find-file-read-only) + +Added (upcase-region) + + in Insert mode now jumps back to Command mode; to suspend Vimacs +from Insert mode, press twice. Note that you'll be in Normal mode +when you resume + +Fixed highlighting one less character than the current word + +Changed all functions to have be internal to the script (i.e. use +mappings) + +Implemented primitive yank-pop () support, but hey, it does work ... + +Added Charles E. Campbell to THANKS section + + now actually redraws as well as recentering cursor + + and move by paragraphs + + scrolls other window down. + +Integration with Jeff Lanzarotta's BufExplorer plugin for b. Vimacs will +launch BufExplorer when you press b if you have it. BufExplorer will use +a default sort order of MRU, since this how it works in Emacs. You will need +BufExplorer 6.0.16 for this to work properly, otherwise ':insertmode' will +screw things up ... + +Added , and : All map to Vim's |insert_expand| command + +Added to |Cmdline-mode| + + inserts the character above the cursor (|i_CTRL-Y|) + + +============================================================================== +*Vimacs.10* In the Future ... (TODO list) + + *vimacs-todo* + +Replace "set =^[x" with a loop; ASCII range 7 to 127 + +Implement haskell-mode and with vimsh for Manuel :) + +BufExplorer used for bdelete etc. commands? + +Don't overwrite maps. Err. Will be hard ... + +GotoLine should accept a range or argument + +Autoconfiscate ... is that overkill?! + +Make b silent (for :BufExplorer?) + +C-x n p + +Emacs-like status line? + +"Mark stack" ala in Emacs, and to jump to last +marks + +Add Mac notes to documentation. + +Jed keys: = newline but no indent, = ?, = +leave one line, = find-alternate-file, + +Emacs folding keys + +Fix and to turn on regexps + +Bind , and ? + +Follow mode (http://www.csd.uu.se/~andersl/follow.shtml). Maybe as a +separate script; e.g. vimacs-follow.vim + +Argument (M-1/M-2/etc) and universal argument keys. Ahahaha, good +luck to me ... (hmm, v:count1 looks promising!) + +mapcheck() everything -- oooh boy + +Port the rest of XEmacs' 419830213 bindings + +Zippy, Doctor, kitchen sink + + +============================================================================== +*Vimacs.11* Contact, Help, Credits + + *vimacs-author* + +The author of Vimacs is Andre Pang . + + *vimacs-webpage* + +The official Vimacs webpage is at http://www.vimacs.cx/. It is also regularly +uplaoded to the Vim Online website, at http://vim.sourceforge.net/. + + *vimacs-thanks* + +Many people have inspired me to work on Vimacs. (This is actually a good +thing. Really ...) The following are a brief list of people who have been +particularly helpful: + + Manuel Chakravarty ~ + For introducing me to Emacs, otherwise I'd never be writing an + alternative for it ;) + + Piet Delport ~ + Vim scripting help + + Benji Fisher ~ + Vim scripting help, and the wonderful foo.vim script + + Barrie Stott ~ + Testing and feedback on early releases + + Hari Krishna Dara, Arun Easi ~ + Inspiration on how to map and to repeat your current search + + Charles E. Campbell ~ + Writing a document on how to write Vim plugins, convincing me use s + and s for Vimacs's internal functions, Vim scripting help + + The Vim, GNU Emacs, and XEmacs teams ~ + For absolutely amazing text editors! + + *vimacs-suggestions* + +Please, please ask for key mappings which you consider to be fundamental +in Emacs! This is a serious project, it's not another Vigor :). I'm not +a veteran Emacs user by any means, so there are potentially scores of +keys which many consider to be fundamental which I am missing. Send me +a request (or even better, a patch!) if you feel like a favourite key +binding is missing, or if behaviour is incorrect. + + *vimacs-gpl2* + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + + +============================================================================== + vim:tw=78:sts=0:ts=8:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl: + diff --git a/.vim/pack/editing/start/vimacs/plugin/vimacs-0.93.vim b/.vim/pack/editing/start/vimacs/plugin/vimacs-0.93.vim new file mode 100644 index 0000000..aa07fd8 --- /dev/null +++ b/.vim/pack/editing/start/vimacs/plugin/vimacs-0.93.vim @@ -0,0 +1,931 @@ +""" +"" Vimacs (0.93) +" +" Vim-Improved eMACS +" +" (Oh dear, what have I got myself into?) +" + +" +" Copyright (C) 2002 Andre Pang +" +" Please see the documentation (vimacs.txt) for the README, installation +" notes, and the ChangeLog. +" + +" +" This program is free software; you can redistribute it and/or modify +" it under the terms of the GNU General Public License as published by +" the Free Software Foundation; either version 2 of the License, or +" (at your option) any later version. +" +" This program is distributed in the hope that it will be useful, +" but WITHOUT ANY WARRANTY; without even the implied warranty of +" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +" GNU General Public License for more details. +" +" You should have received a copy of the GNU General Public License +" along with this program; if not, write to the Free Software +" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +" +" This General Public License does not permit incorporating your program into +" proprietary programs. If your program is a subroutine library, you may +" consider it more useful to permit linking proprietary applications with the +" library. If this is what you want to do, use the GNU Library General +" Public License instead of this License. +" + +" TODO: :h map-script +" :h cpoptions +" :h mapleader +" :h map- +" :h +" :h undo? +" :h write-plugin + +" Have for all maps? + + +" Never load Vimacs if user wants true Vi! (We're not _that_ evil 8) +if v:progname =~ '^vi$' + finish +endif + +if version < 600 + " We require Vim 6 to work :( + echoerr 'Vimacs requires Vim 6 to run :(' + finish +endif + +" We want to be able to remap <> key codes and do line continuation +let s:saved_cpoptions = &cpoptions +set cpoptions-=<,C + + +" Set a default value for a variable only if it doesn't exist +" (like "$foo |= 'bar'" in Perl) +" +" Thanks to Piet Delport for this solution, and Benji Fisher for +" additional comments :) +" + +function! LetDefault(var_name, value) + if !exists(a:var_name) + execute 'let ' . a:var_name . '=' . a:value + endif +endfunction + +command! -nargs=+ LetDefault call s:LetDefault() + +" Load Vimacs by default +LetDefault g:VM_Enabled 1 + +" Developers may want to turn this on, to always load the file +LetDefault g:VM_Dev 0 + +if g:VM_Enabled == 0 || (exists("loaded_vimacs") && g:VM_Dev == 0) || &cp + finish +endif + + +" +" Function to mark a cursor position and restore it afterward -- used in a few +" functions, like FillParagraph(). Blatantly stolen from foo.vim by Benji +" Fisher :) +" + +function! Mark(...) + if a:0 == 0 + let mark = line(".") . "G" . virtcol(".") . "|" + normal! H + let mark = "normal!" . line(".") . "Gzt" . mark + execute mark + return mark + elseif a:0 == 1 + return "normal!" . a:1 . "G1|" + else + return "normal!" . a:1 . "G" . a:2 . "|" + endif +endfun + + +" +" It's a good idea to have a command height of at least 2 if showmode is on, +" because many important messages will be overwritten by the mode display. +" e.g. , which saves the file, will display that the file has been +" saved, but the notice will be immediately overwritten by the modeline when +" this happens. +" + +" Don't fork around with cmdheight? +LetDefault g:VM_CmdHeightAdj 1 + +if &cmdheight == 1 && &showmode == 1 && g:VM_CmdHeightAdj + set cmdheight=2 +endif + + +" +" Vim options essential for emulating Emacs-ish behaviour +" + +" Turn off / pulling down GUI menu +set winaltkeys=no +" Emacs normally wraps everything +set whichwrap=b,s,<,>,h,l,[,],~ +" Emacs always has 'hidden buffers' +set hidden +" Backspace in Emacs normally backspaces anything :) +set backspace=indent,eol,start +" Want to be able to use within our mappings +" (This has got to be the coolest option name ever, btw) +set wildcharm= +" Recognise key sequences that start with in Insert Mode +set esckeys + + +" +" For the UNIX console -- make x == +" + +" Pressing sends x? (As Unix terminals often do) +LetDefault g:VM_UnixConsoleMetaSendsEsc 1 + +" One or two s required to go back to Normal mode? +LetDefault g:VM_SingleEscToNormal 1 + +if has("unix") && !has("gui_running") && g:VM_UnixConsoleMetaSendsEsc + " x maps to + set =1 + set =2 + set =3 + set =4 + set =5 + set =6 + set =7 + set =8 + set =9 + set =0 + set =a + set =b + set =c + set =d + set =e + set =f + set =g + set =h + set =i + set =j + set =k + set =l + set =m + set =n + set =o + set =p + set =q + set =r + set =s + set =t + set =u + set =v + set =w + set =x + set =y + set =z + set = + set =/ + " Doing "set >=^[>" throws up an error, so we be dodgey and use Char-190 + " instead, which is ASCII 62 ('>' + 128). + set => + set =< + set =0 + set =% + set =* + set =. + set =^ + " Can't set right now :( + set =^[ + +endif + + +" +" One or two s to get back to Normal mode? +" + +" on CmdwinLeave? +if g:VM_SingleEscToNormal == 1 + if &insertmode + if has('unix') && !has('gui_running') && g:VM_UnixConsoleMetaSendsEsc + inoremap :UseF1ForNormal + else + inoremap + endif + endif + + set notimeout + set ttimeout + set timeoutlen=50 +else + inoremap + vnoremap + set notimeout + set nottimeout +endif + +command! UseF1ForNormal echoerr "Use F1 or to return to Normal mode. :help vimacs-unix-esc-key" + + +" +" Insert mode <-> Normal mode <-> Command mode +" + +inoremap : +inoremap : +inoremap +inoremap +inoremap +inoremap :echo "Returning to Normal mode; press again to suspend Vimacs" +nnoremap :call Suspend() +" M-` isn't defined in Emacs + +inoremap 1 +inoremap 2 +inoremap 3 +inoremap 4 +inoremap 5 +inoremap 6 +inoremap 7 +inoremap 8 +inoremap 9 + +LetDefault g:VM_NormalMetaXRemap 1 + +if g:VM_NormalMetaXRemap == 1 + nnoremap : +endif + +function! Suspend() + suspend! + if &insertmode + startinsert + endif +endfunction + + +" +" Leaving Vim +" + +inoremap :confirm qall + + +" +" Files & Buffers +" + +inoremap :hide edit +inoremap :update +inoremap s :wall +inoremap i :read +"what does C-x C-v do? +inoremap :write +inoremap :set invreadonly +inoremap :hide view + + +" +" Help Sistemmii (hi Finns) +" +"inoremap :help + + +" +" Error Recovery +" + +inoremap u +inoremap u +"lots of other stuff :( + + +" +" Incremental Searching and Query Replace +" + +inoremap :call StartSearch('/')/ +inoremap :call StartSearch('?')? +inoremap :cnext +" not in Emacs: next in QuickFix +inoremap :cprevious +" not in Emacs: previous in QuickFix +inoremap :call StartSearch('/')/ +inoremap :call StartSearch('?')? +inoremap :set invhls +inoremap :call QueryReplace()() +inoremap :call QueryReplace()_regexp() +cnoremap ? + +command! QueryReplace :call QueryReplace()() +command! QueryReplaceRegexp :call QueryReplace()_regexp() + +" Searching is a bit tricky because we have to emulate Emacs's behaviour of +" searching again when or is pressed _inside_ the search +" commandline. Vim has no equivalent to this, so we must use a bit of +" on-the-fly remap trickery (popular in Quake-style games) to provide +" different functionality for , depending on whether you're in 'search +" mode' or not. +" +" We must map and because we have to undo the map trickery that we +" set up when we abort/finish the search. All in all, it's not too complex +" when you actually look at what the code does. +" +" Note that in Emacs is functionally the same as . + +LetDefault g:VM_SearchRepeatHighlight 0 + +function! StartSearch(search_dir) + let s:incsearch_status = &incsearch + let s:lazyredraw_status = &lazyredraw + set incsearch + cmap + cnoremap :call SearchAgain()/ + cnoremap :call SearchAgain()? + cnoremap :call StopSearch() + cnoremap :call AbortSearch() + cnoremap :call AbortSearch() + if a:search_dir == '/' + cnoremap :set invhls/ + else + cnoremap :set invhls? + endif + let s:before_search_mark = Mark() +endfunction + +function! StopSearch() + cunmap + cunmap + cunmap + cunmap + cunmap + cnoremap + if exists("s:incsearch_status") + let &incsearch = s:incsearch_status + unlet s:incsearch_status + endif + if g:VM_SearchRepeatHighlight == 1 + if exists("s:hls_status") + let &hls = s:hls_status + unlet s:hls_status + endif + endif +endfunction + +function! AbortSearch() + call StopSearch() + if exists("s:before_search_mark") + execute s:before_search_mark + unlet s:before_search_mark + endif +endfunction + +function! SearchAgain() + if g:VM_SearchRepeatHighlight == 1 + if !exists("s:hls_status") + let s:hls_status = &hls + endif + set hls + endif +endfunction + +" Emacs' `query-replace' functions + +function! QueryReplace() + let magic_status = &magic + set nomagic + let searchtext = input("Query replace: ") + if searchtext == "" + echo "(no text entered): exiting to Insert mode" + return + endif + let replacetext = input("Query replace " . searchtext . " with: ") + let searchtext_esc = escape(searchtext,'/\^$') + let replacetext_esc = escape(replacetext,'/\') + execute ".,$s/" . searchtext_esc . "/" . replacetext_esc . "/cg" + let &magic = magic_status +endfunction + +function! QueryReplaceRegexp() + let searchtext = input("Query replace regexp: ") + if searchtext == "" + echo "(no text entered): exiting to Insert mode" + return + endif + let replacetext = input("Query replace regexp " . searchtext . " with: ") + let searchtext_esc = escape(searchtext,'/') + let replacetext_esc = escape(replacetext,'/') + execute ".,$s/" . searchtext_esc . "/" . replacetext_esc . "/cg" +endfunction + + +" +" Command line editing +" + +" Navigation +cmap +cmap +cnoremap +cnoremap +cmap +cmap + +" Editing +cmap +cmap +cmap +cnoremap " +cnoremap +cnoremap +cnoremap d$ +"Should really use &cedit, not just -- but how? + + +" +" Navigation +" + +" Insert/Visual/Operator mode maps +imap +vmap +omap +imap +vmap +omap +imap +vmap +omap +imap +vmap +omap +inoremap e +vnoremap e +onoremap e +inoremap +vnoremap +onoremap +imap +vmap +omap +imap +vmap +omap +inoremap ( +vnoremap ( +onoremap ( +inoremap ) +vnoremap ) +onoremap ) +inoremap +vnoremap +onoremap +inoremap 1G0 +vnoremap 1G0 +onoremap 1G0 +inoremap > G$ +vnoremap > G$ +onoremap > G$ +inoremap +vnoremap +onoremap +inoremap +vnoremap +onoremap +inoremap ^ +vnoremap ^ +onoremap ^ +inoremap = +vnoremap = +onoremap = +inoremap :call GotoLine() +vnoremap :call GotoLine() +onoremap :call GotoLine() +" Phear, works properly even in Visual/Operator-Pending +" modes :) (It's rather dangerous with the latter, though ...) +inoremap +vnoremap +onoremap +inoremap +vnoremap +onoremap +inoremap { +vnoremap { +onoremap { +inoremap } +vnoremap } +onoremap } + +command! GotoLine :call GotoLine() + +function! GotoLine() + let targetline = input("Goto line: ") + if targetline =~ "^\\d\\+$" + execute "normal! " . targetline . "G0" + elseif targetline =~ "^\\d\\+%$" + execute "normal! " . targetline . "%" + elseif targetline == "" + echo "(cancelled)" + else + echo " <- Not a Number" + endif +endfunction + +command! GotoLine :call GotoLine() + + +" +" General Editing +" + +inoremap +inoremap d0 +inoremap +inoremap +inoremap = + +"" Aborting +cnoremap +onoremap + + +" +" Killing and Deleting +" + +inoremap +inoremap =KillWord() +inoremap +inoremap +inoremap +inoremap =KillLine() +" Thanks to Benji Fisher for helping me with getting to work! +inoremap d0 +inoremap d) +inoremap d( +inoremap dt +inoremap beldwi + +function! KillWord() + if col('.') > strlen(getline('.')) + return "\\dw" + else + return "\dw" + endif +endfunction + +function! KillLine() + if col('.') > strlen(getline('.')) + " At EOL; join with next line + return "\" + else + " Not at EOL; kill until end of line + return "\d$" + endif +endfunction + + +" +" Abbreviations +" + +inoremap +inoremap +inoremap +inoremap + + +" +" Visual stuff (aka 'marking' aka 'region' aka 'block' etc etc) +" + +set sel=exclusive +" Visual mode +inoremap =StartVisualMode() +" Unix terminals produce , not +imap +vnoremap +vnoremap +vnoremap +vnoremap "1y +"May have to change to "1d and paste ... + +" Marking blocks +inoremap :call StartMarkSel()viw +inoremap :call StartMarkSel()vap +inoremap :call StartMarkSel()v1G0o +inoremap > :call StartMarkSel()vG$o +inoremap h :call StartMarkSel()1G0vGo + +" Block operations +vnoremap "1d +vnoremap "_d +vnoremap o +vnoremap U +vnoremap : + +" Pasting +inoremap :call ResetKillRing()" +inoremap * +"inoremap :echoerr "Sorry, yank-pop is not yet implemented!" +inoremap :call YankPop() + +function! YankPop() + undo + if !exists("s:kill_ring_position") + call ResetKillRing() + endif + execute "normal! i\\" . s:kill_ring_position . "\" + call IncrKillRing() +endfunction + +function! ResetKillRing() + let s:kill_ring_position = 3 +endfunction + +function! IncrKillRing() + if s:kill_ring_position >= 9 + let s:kill_ring_position = 2 + else + let s:kill_ring_position = s:kill_ring_position + 1 + endif +endfunction + +function! StartMarkSel() + if &selectmode =~ 'key' + set keymodel-=stopsel + endif +endfunction + +function! StartVisualMode() + call StartMarkSel() + if col('.') > strlen(getline('.')) + " At EOL + return "\\v\" + else + return "\v" + endif +endfunction + + +" +" Use to select text, ala Windows. +" (XEmacs supports this) +" + +" We need to make sure that the 'keymodel' option has stopsel before we +" start the actual marking, so that the user can cancel it with any +" navigational key as she normally would. This is in contrast to the +" style of marking, where navigational keys do _not_ cancel +" marking. +" +" Note that this doesn't work properly if the user remaps + +inoremap :call StartShiftSel() +inoremap :call StartShiftSel() +inoremap :call StartShiftSel() +inoremap :call StartShiftSel() +inoremap :call StartShiftSel() +inoremap :call StartShiftSel() +inoremap :call StartShiftSel() +inoremap :call StartShiftSel() + +function! StartShiftSel() + if &selectmode =~ "key" + set keymodel+=stopsel + endif +endfunction + + +" +" Window Operations +" + +inoremap 2 s +inoremap 3 v +inoremap 0 c +inoremap 1 o +inoremap o w +" O is not defined in Emacs ... +inoremap O W +inoremap w +inoremap W +inoremap + = +inoremap :ScrollOtherWindow + +inoremap 4 :FindFileOtherWindow +inoremap 4f :FindFileOtherWindow + +function! number_of_windows() + let i = 1 + while winbufnr(i) != -1 + let i = i + 1 + endwhile + return i - 1 +endfunction + +function! FindFileOtherWindow(filename) + let num_windows = number_of_windows() + if num_windows <= 1 + wincmd s + endif + wincmd w + execute "edit " . a:filename + wincmd W +endfunction + +command! -nargs=1 -complete=file FindFileOtherWindow :call FindFileOtherWindow() + +command! ScrollOtherWindow silent! execute "normal! \w\\W" + + +" +" Formatting +" + +inoremap :call FillParagraph() +inoremap