I think all the cursor movements, the window and the block commands
specially (these last ones I can't imagine how to do them...).
Thanx.
--
Yours truly, | PCC on a FreeBSD box E-mail: ab...@mclink.it
Angel Blue |-------------------------------------------------------------
_*_ | "I don't need this fucking world"
| | (Dead Kennedys)
Well, give us a list of all wordstar commands
and we will see how we can "map" them for you.
Sven
Ok, I take you seriously... :-)
Here the ones I would like to emulate always staying in Insert
mode... They are a mix from the original Wordstar, Borland IDE
editor and clones like joe - wstar version
(NB: for the compound keys Control-char+char and
Control-char+Control-char should be the same, ie ^Qa is like
^Q^A):
Cursor movements:
----------------
^E up
^X down
^D right
^S left
^A left by word
^F right by word
^W scroll up one line (the cursor stays on the same _buffer_ line)
^Z scroll down one line (idem)
^R one screen up (backward - better saving one line of the previuos screen)
^C one screen down (forward - idem :-)
^Q^E top of screen
^Q^X bottom of screen
^Q^S begin of line
^Q^D end of line
^Q^W scrolls up continuously
^Q^Z scrolls down continuously
^Q^R begin of file
^Q^C end of file
^Q^A replace (better with regexp... :-)
^Q^F search forward (better with regexp and restarting top of file :-)
^L find next
^Q^I go to line number...
^Q^B go to begin of block (more on block below... :-)
^Q^K go to end of block
^Q^P go to previous position I've done some editing
^Q 0-9 go to mark 0-9 (0,1,2,3 ecc. more on marks below... :-)
Block commands:
--------------
NB: "block" is a piece of text obtained like with "v" in
Vim/command but the text is _not_ highlighted and stays on
until another block is marked - it's like a piece of text
between two marked chars in Vi(m) (and this is the way of
emulating it I think, not with "v").
^K^B mark begin of block
^K^K mark end of block (an action I can do also much time after
marking begin of block...)
^K^C copy block at the cursor position
^K^V move block at the cursor position
^K^Y delete block
^K^W write block to a file
^K/ filter block trough external command replacing it with output
^K^T mark word like a block
File commands:
-------------
^K^E edit new file
^K^D write file - asking for confirmation
^K^S write file - without asking
^K^R read in file at the cursor position
^K^Q kill buffer/window - asking for saving changes (more below on windows)
^K^X exit program - asking for saving changes
^K^Z stop - go to shell
Various deleting commands:
-------------------------
^G delete char (like ^D in emacs)
^H delete backward char
^T delete to end of word
^Y delete _all_ line - also Return
^Q^Y delete to end of line - not Return
Window commands:
---------------
NB: Different buffers can go in different windows and the same
buffer can go in 2 or more windows, when this is the case if I
kill the buffer with ^K^Q I kill _only_ the window. If the
window is the one window of the buffer I kill the buffer using
^K^Q.
^K^O split window in half
^K^N goto window below (next)
^K^P goto window above (previous)
^K^I show one window/all windows
Marks:
-----
NB: marks are like in Vi: a char in buffer that I can reach
with the ` (grave) command. In wstar are 10 (0 to 9) and
numeric - I think it's possible to emulate them using the first
10 letters
^K 0-9 set mark 0-9 (0,1,2,3...)
^Q 0-9 goto mark 0-9 (idem)
Some utils for programming:
--------------------------
^Q< got matching parenthesis
^K. indent more
^K, indent less
^K; tags search
^K^L compile and parse errors
^Q+ goto next error
^Q- goto prev error
Various commands not included before:
------------------------------------
^B format paragraph
^J help
^U undo
^^ redo
^V toggle overwrite
DESIDERATA: ;-))
----------
NB: yes, there are some keys free, don't waste them! ;-)
* Movements by paragraphs
* Next window and prev window show next buffer or prev buffer
if there is only one window
* Copy/delete block into registers (or buffers like letter buffers in
Vi) and paste it from registers at the cursor position.
* Using the ^P key to print file after filtering it trough an
external program - a sh script with nroff and macros ex. -
specified in an option (the equalprg ex.)
* Much other but I can't imagine it now ;-)
COMMENT:
-------
I think the cursor movements, file cmds and window ones won't
be very hard to emulate for a Vi(m) addict :-)
I thought to emulate marks with the first 10 letters and all
the block commands using other marks. Letter buffers for the
"desiderata" registers and so on: but I'm not a Vi(m) guru...
Anyway if it's possible it will be useful, a lot. Pressing Esc
I'll have all the power possibilities, in Insert mode I can
stay there infinitely whithout escaping...
And it will a mode to capture new Vi(m)ers...
I think this "emulation" is a challenge for a Vi(m) guru or
enthusiast and the way to show that Vi(m) can do (almost) all
in an editing contest. And I'm sure it can do it! :-))
Good luck and thanx in advance - I'll try too, obviously! :-))
--
Yours truly, | PCC on a FreeBSD box E-mail: ab...@mclink.it
Angel Blue |-------------------------------------------------------------
_*_ | "Wickedness lies in your poisoned lips
| | Your body moves just like the crack of a whip" (B. S.)
OK, let's have a look.
Beware: all of the mappings here go untested - don't have too much time
for that :-)
And all of these mappings are for vim.
And, well, I asume that "set nocompatible" is set.
> Cursor movements:
> ----------------
>
> ^E up
inoremap <C-E> <Up>
> ^X down
inoremap <C-E> <Down>
> ^D right
inoremap <C-D> <Right>
> ^S left
inoremap <C-S> <Left>
(this one won't work on console vim, as the terminal steals ^S and
switches to scroll-off mode. It will work in gvim, though)
> ^A left by word
inoremap <C-A> <C-O>b
> ^F right by word
inoremap <C-A> <C-O>w
> ^W scroll up one line (the cursor stays on the same _buffer_ line)
inoremap <C-W> <C-O><C-E>
> ^Z scroll down one line (idem)
inoremap <C-Z> <C-O><C-Y>
> ^R one screen up (backward - better saving one line of the previuos screen)
inoremap <C-R> <C-O><C-B>
> ^C one screen down (forward - idem :-)
inoremap <C-R> <C-O><C-F>
(all the following mappings starting with ^Q won't work in console vim
as the terminal will still ^Q and set it to scroll on, the will work in
gvim, however)
> ^Q^E top of screen
inoremap <C-Q><C-E> <C-O>H
> ^Q^X bottom of screen
inoremap <C-Q><C-X> <C-O>L
> ^Q^S begin of line
inoremap <C-Q><C-S> <C-O>0
> ^Q^D end of line
inoremap <C-Q><C-S> <C-O>$
> ^Q^W scrolls up continuously
> ^Q^Z scrolls down continuously
Ehm, what's the difference to ^W and ^Z above?
> ^Q^R begin of file
inoremap <C-Q><C-R> <C-O>1G
> ^Q^C end of file
inoremap <C-Q><C-R> <C-O>G
> ^Q^A replace (better with regexp... :-)
inoremap <C-Q><C-A> <ESC>:call Replace()<CR>
fun! Replace()
let old=input("Tell me regexp to replace: ")
let new=input("Tell me replacement string: ")
exec "%s/" . old . "/" . new . "/g"
startinsert
endfun
> ^Q^F search forward (better with regexp and restarting top of file :-)
inoremap <C-Q><C-F> <ESC>:call Search()<CR>
fun! Search()
let regexp=input("Tell me search pattern: ")
" start at top of file
norm 1G
exec "norm /" . regexp . "\<CR>"
startinsert
endfun
> ^L find next
inoremap <C-L> <C-O>n
> ^Q^I go to line number...
inoremap <C-Q><C-I> <ESC>:call Line()
fun! Line()
let line=input("Tell me line number to jump to: ")
exec "norm " . line . "G"
startinsert
endfun
> ^Q^B go to begin of block (more on block below... :-)
(I asume using marks y and z for block start and end, see below ;-)
inoremap <C-Q><C-B> <C-O>`y
> ^Q^K go to end of block
inoremap <C-Q><C-K> <C-O>`z
> ^Q^P go to previous position I've done some editing
inoremap <C-Q><C-P> <C-O>``
> ^Q 0-9 go to mark 0-9 (0,1,2,3 ecc. more on marks below... :-)
inoremap <C-Q>0 <C-O>`a
inoremap <C-Q>1 <C-O>`b
inoremap <C-Q>2 <C-O>`c
inoremap <C-Q>3 <C-O>`d
inoremap <C-Q>4 <C-O>`e
inoremap <C-Q>5 <C-O>`f
inoremap <C-Q>6 <C-O>`g
inoremap <C-Q>7 <C-O>`h
inoremap <C-Q>8 <C-O>`i
inoremap <C-Q>9 <C-O>`j
> Block commands:
> --------------
>
> NB: "block" is a piece of text obtained like with "v" in
> Vim/command but the text is _not_ highlighted and stays on
> until another block is marked - it's like a piece of text
> between two marked chars in Vi(m) (and this is the way of
> emulating it I think, not with "v").
>
> ^K^B mark begin of block
inoremap <C-K><C-B> <C-O>my
> ^K^K mark end of block (an action I can do also much time after
> marking begin of block...)
inoremap <C-K><C-B> <C-O>mz
> ^K^C copy block at the cursor position
inoremap <C-K><C-C> <C-O>:'y,'z co .
> ^K^V move block at the cursor position
inoremap <C-K><C-V> <C-O>:'y,'z m .
> ^K^Y delete block
inoremap <C-K><C-Y> <C-O>:'y,'z d
> ^K^W write block to a file
inoremap <C-K><C-W> <ESC>:call WriteBlock()<CR>
fun! WriteBlock()
let filename=input("Tell me filename to write to: ")
exec "'y,'z w! " . filename
startinsert
endfun
> ^K/ filter block trough external command replacing it with output
inoremap <C-K>/ <ESC>:call FilterBlock()<CR>
fun! FilterBlock()
let command=input("Tell me command to filter block: ")
exec "'y,'z ! " . command
startinsert
endfun
> ^K^T mark word like a block
inoremap <C-K><C-T> <ESC>viw<ESC>mzviwo<ESC>myi
> File commands:
> -------------
>
> ^K^E edit new file
inoremap <C-K><C-E> <ESC>:call Edit()
fun! Edit()
let filename=input("Tell me filename to edit: ")
exec "e! " . filename
startinsert
endfun
> ^K^D write file - asking for confirmation
inoremap <C-K><C-D> <ESC>:call WriteConfirm()
fun! WriteConfirm()
let doit=input("Really save changes? ")
if doit == "y"
w!
endif
startinsert
endfun
> ^K^S write file - without asking
inoremap <C-K><C-S> <ESC>:call WriteForce()
fun! WriteForce()
w!
startinsert
endfun
> ^K^R read in file at the cursor position
inoremap <C-K><C-R> <C-O>:r<SPACE>
(you'll have to enter the filename at the :r prompt)
> ^K^Q kill buffer/window - asking for saving changes (more below on windows)
inoremap <C-K><C-Q> <C-O>:confirm q
> ^K^X exit program - asking for saving changes
inoremap <C-K><C-X> <C-O>:confirm qa
> ^K^Z stop - go to shell
inoremap <C-K><C-Z> <C-O><C-Z>
> Various deleting commands:
> -------------------------
>
> ^G delete char (like ^D in emacs)
inoremap <C-G> <ESC>lxi
> ^H delete backward char
(no mapping needed :-)
(you'd better set ":se bs=2" in your .vimrc, see :help 'bs')
> ^T delete to end of word
inoremap <C-G> <C-O>x
> ^Y delete _all_ line - also Return
inoremap <C-Y> <C-O>dd
> ^Q^Y delete to end of line - not Return
inoremap <C-Q><C-Y> <C-O>D
> Window commands:
> ---------------
>
> NB: Different buffers can go in different windows and the same
> buffer can go in 2 or more windows, when this is the case if I
> kill the buffer with ^K^Q I kill _only_ the window. If the
> window is the one window of the buffer I kill the buffer using
> ^K^Q.
>
> ^K^O split window in half
inoremap <C-K><C-O> <C-O>:sp<CR>
> ^K^N goto window below (next)
inoremap <C-K><C-N> <C-O><C-W>j
> ^K^P goto window above (previous)
inoremap <C-K><C-P> <C-O><C-W>k
> ^K^I show one window/all windows
Hm, don't know how to emulate this one. :-}
> Marks:
> -----
>
> NB: marks are like in Vi: a char in buffer that I can reach
> with the ` (grave) command. In wstar are 10 (0 to 9) and
> numeric - I think it's possible to emulate them using the first
> 10 letters
>
> ^K 0-9 set mark 0-9 (0,1,2,3...)
inoremap <C-K>0 <C-O>ma
inoremap <C-K>1 <C-O>mb
inoremap <C-K>2 <C-O>mc
inoremap <C-K>3 <C-O>md
inoremap <C-K>4 <C-O>me
inoremap <C-K>5 <C-O>mf
inoremap <C-K>6 <C-O>mg
inoremap <C-K>7 <C-O>mh
inoremap <C-K>8 <C-O>mi
inoremap <C-K>9 <C-O>mj
> ^Q 0-9 goto mark 0-9 (idem)
See above.
> Some utils for programming:
> --------------------------
>
> ^Q< got matching parenthesis
inoremap <C-Q><lt> <C-O>%
> ^K. indent more
inoremap <C-K>. <C-O>>>
> ^K, indent less
inoremap <C-K>, <C-O><lt><lt>
> ^K; tags search
What do you mean by tags search?
> ^K^L compile and parse errors
inoremap <C-K><C-L> <ESC>:call Make()<CR>
fun! Make()
make
startinsert
endfun
> ^Q+ goto next error
inoremap <C-Q>+ <C-O>:cn<CR>
> ^Q- goto prev error
inoremap <C-Q>- <C-O>:cN<CR>
> Various commands not included before:
> ------------------------------------
>
> ^B format paragraph
inoremap <C-B> <C-O>gqip
> ^J help
inoremap <C-J> <C-O>:help<CR>
> ^U undo
inoremap <C-U> <C-O>u
(this one may not work as you'd think it should)
> ^^ redo
inoremap <C-^> <C-O><C-R>
> ^V toggle overwrite
inoremap <C-V> <Ins>
> DESIDERATA: ;-))
> ----------
>
> NB: yes, there are some keys free, don't waste them! ;-)
>
> * Movements by paragraphs
> * Next window and prev window show next buffer or prev buffer
> if there is only one window
> * Copy/delete block into registers (or buffers like letter buffers in
> Vi) and paste it from registers at the cursor position.
> * Using the ^P key to print file after filtering it trough an
> external program - a sh script with nroff and macros ex. -
> specified in an option (the equalprg ex.)
> * Much other but I can't imagine it now ;-)
Hm, whoever wants may continue :-)
>
> COMMENT:
> -------
>
> I think the cursor movements, file cmds and window ones won't
> be very hard to emulate for a Vi(m) addict :-)
Well... most of the above is pretty straightforward. All those functions
only asking for a filename or such may also be done without a function
if you can live by inserting all at a :-Prompt (like shown with :r)
> I thought to emulate marks with the first 10 letters and all
> the block commands using other marks. Letter buffers for the
> "desiderata" registers and so on: but I'm not a Vi(m) guru...
emulating the 0-9 buffers through marks is done above, yes.
> Anyway if it's possible it will be useful, a lot. Pressing Esc
> I'll have all the power possibilities, in Insert mode I can
> stay there infinitely whithout escaping...
> And it will a mode to capture new Vi(m)ers...
Don't know. Have fun with the above, stick it on a web page or such...
whatever you think is useful. I'll send a copy to the vim-Mailinglist,
perhaps someone else thinks it's useful :)
> I think this "emulation" is a challenge for a Vi(m) guru or
> enthusiast and the way to show that Vi(m) can do (almost) all
> in an editing contest. And I'm sure it can do it! :-))
Well, challenge? Don't know :)
> Good luck and thanx in advance - I'll try too, obviously! :-))
CU,
Thomas
--
Thomas Köhler Email: jean...@picard.franken.de | LCARS - Linux
<>< WWW: http://jeanluc-picard.de | for Computers
IRC: jeanluc | on All Real
PGP public key available from Homepage! | Starships
That should probably be: inoremap <C-C> <C-O><C-F>
But it won't work anyway, because of the ^C.
>> ^Q^C end of file
>
>inoremap <C-Q><C-R> <C-O>G
same here.
>> ^K^C copy block at the cursor position
>
>inoremap <C-K><C-C> <C-O>:'y,'z co .
This one won't work either.
AFAIK, there isn't any way to actually have <C-C> on th left-hand-side
of a mapping, is there? If that's the case, perhaps the map commands
should complain if you try it, rather than silently accepting a mapping
that simply won't work (as they do now).
--
C. Laurence Gonsalves "Any sufficiently advanced
clgo...@kami.com technology is indistinguishable
http://cryogen.com/clgonsal/ from magic." -- Arthur C. Clarke
Uhm, yes, you're right. Silly error of mine...
> >> ^Q^C end of file
> >inoremap <C-Q><C-R> <C-O>G
> same here.
Ehm, yes :)
> >> ^K^C copy block at the cursor position
> >inoremap <C-K><C-C> <C-O>:'y,'z co .
> This one won't work either.
Right.
> AFAIK, there isn't any way to actually have <C-C> on th left-hand-side
> of a mapping, is there? If that's the case, perhaps the map commands
> should complain if you try it, rather than silently accepting a mapping
> that simply won't work (as they do now).
Good point. This time, I Cc'ed the developer's mailing list on the
issue :-)
Thanx Thomas for your work! :-)
It gives me some ideas and some notions about Vim!
>> But it won't work anyway, because of the ^C.
> Uhm, yes, you're right. Silly error of mine...
Why ^C can't be mapped? Why this choice? "Security"?
In elvis I can map it...
>> >> ^K^C copy block at the cursor position
>> >inoremap <C-K><C-C> <C-O>:'y,'z co .
>> This one won't work either.
> Right.
Another question for block: text between two marks or marked
with "v" or "^V" cmds can _only_ be filtered or written as a block of
entire _lines_, or not?
In the meantime I'm writing a new emulation... :-)
--
Yours truly, | PCC on a FreeBSD box E-mail: ab...@mclink.it
Angel Blue |-------------------------------------------------------------
_*_ | "Trovo il mio punto G e voglio un'altra stronza rivoluzione
| | un orgasmo che mi plachi ogni reazione" (Afterhours)
Straight from ":h map_CTRL_C":
It's not possible to use a CTRL-C in the {lhs}. You just can't map CTRL-C.
The reason is that CTRL-C must always be available to break a running command.
Peppe
--
"Before you criticize someone, walk
Preben "Peppe" Guldberg __/-\__ a mile in his shoes. That way, if
c92...@student.dtu.dk (o o) he gets angry, he'll be a mile away
----------------------oOOo (_) oOOo-- - and barefoot." --Sarah Jackson
*map_CTRL_C*
It's not possible to use a CTRL-C in the {lhs}. You just can't map CTRL-C.
The reason is that CTRL-C must always be available to break a running command.
Hm. So in elvis, it's easier to shoot yourself in the foot. :-)
> >> >> ^K^C copy block at the cursor position
> >> >inoremap <C-K><C-C> <C-O>:'y,'z co .
> >> This one won't work either.
>
> > Right.
>
> Another question for block: text between two marks or marked
> with "v" or "^V" cmds can _only_ be filtered or written as a block of
> entire _lines_, or not?
Yes, true.
But you could probably write a (somewhat complex) macro that would
delete the visual block, go to the end of the file, paste it there,
filter it, delete it there again, go back and paste again.
Well, yes, not too easy :)
> In the meantime I'm writing a new emulation... :-)
Have fun doing so :-)