Re: Mapping of keysequences...
Brian McKee wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 2-Oct-06, at 3:51 PM, Andy Wokula wrote: Meino Christian Cramer schrieb: Thanks for all, Tony!!! :O) I think Bram should add :he Tony Add it yourself :e ~/.vim/doc/tony.txt :i *tony.txt*Tony's mail address *Tony* "A.J.Mechelynck" vim:tw=78:ts=8:ft=help:norl: . :w :helptags ~/.vim/doc :he Tony Ya know - not only is that funny - it's useful ! It made me realize I can make my own crib sheet for the stuff I can't remember and embed it right in Vim! Cool e.g. :'<,'>!sort -t "^I" -k 9 I use that once a month or so, but never remember it... now it's :he sort9 Thanks! Brian The principle of creating "cribsheet" helpfiles in ~/.vim/doc is certainly useful (though not for my email addy which I don't read as often as vim, vim-dev or vim-multibyte @vim.org). The above is for external sort. Do you know Vim 7 has an internal sort (see :help :sort)? Best regards, Tony.
Re: Mapping of keysequences...
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 2-Oct-06, at 3:51 PM, Andy Wokula wrote: Meino Christian Cramer schrieb: Thanks for all, Tony!!! :O) I think Bram should add :he Tony Add it yourself :e ~/.vim/doc/tony.txt :i *tony.txt* Tony's mail address *Tony* "A.J.Mechelynck" vim:tw=78:ts=8:ft=help:norl: . :w :helptags ~/.vim/doc :he Tony Ya know - not only is that funny - it's useful ! It made me realize I can make my own crib sheet for the stuff I can't remember and embed it right in Vim! Cool e.g. :'<,'>!sort -t "^I" -k 9 I use that once a month or so, but never remember it... now it's :he sort9 Thanks! Brian -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (Darwin) iD8DBQFFIXh3GnOmb9xIQHQRApcaAKCbBMBVNJB2kf6U5nTUU0cXB61ZfwCgpZYH axmyL2MpQZZuzXScYpdFPwE= =UOqL -END PGP SIGNATURE-
Re: Mapping of keysequences...
Meino Christian Cramer schrieb: > Thanks for all, Tony!!! :O) > > I think Bram should add > > :he Tony > > -support in vim which prints your email address... > or may be it is not what you really want, isn't ir ;O) > > (just kidding) > > Keep hacking! > mcc Add it yourself :e ~/.vim/doc/tony.txt :i *tony.txt* Tony's mail address *Tony* "A.J.Mechelynck" vim:tw=78:ts=8:ft=help:norl: . :w :helptags ~/.vim/doc :he Tony :-) Andy ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: Mapping of keysequences...
Meino Christian Cramer wrote: [...] I think Bram should add :he Tony -support in vim which prints your email address... or may be it is not what you really want, isn't ir ;O) (just kidding) Keep hacking! mcc :-D Actually, my personal maibox is so full of spam that I read it only when there's no outstanding mail on the vim-lists (or from Bugzilla, or from a small number of close friends). If you want to get at me, post on the list. I also "committed" (as one commits crimes or misdemeanors, I suppose) a few tips and scripts at vim-online, but not as many and probably not as good as some other people like Benji Fisher, Dr. Chip Campbell, and others; and a few pages about Vim on my personal site. Don't hack too hard or too long, or you will we stuck with only shavings. Best regards, Tony.
Re: Mapping of keysequences...
From: "A.J.Mechelynck" <[EMAIL PROTECTED]> Subject: Re: Mapping of keysequences... Date: Sun, 01 Oct 2006 20:34:31 +0200 > Meino Christian Cramer wrote: > > From: "A.J.Mechelynck" <[EMAIL PROTECTED]> > > Subject: Re: Mapping of keysequences... > > Date: Sun, 01 Oct 2006 19:44:39 +0200 > > > >> Meino Christian Cramer wrote: > >> [...] > >>> Hi Tony ! > >>> > >>> nice to read you again! And thank you very much for your > >>> help,help,help... :) <- BIG smiley! > >>> > >>> Slowly and surely I get my TeX macro working... > >>> > >>> What I have now is the following: > >>> > >>>inoremap b {\bf #}?#c/} > >>>inoremap i {\it #}?#c/} > >>>inoremap s {\sl #}?#c/} > >>> > >>> which "works". A last wish I would have is: After 'c'hanging the '#' > >>> to what I really want to typeset I will press to leave > >>> 'c'hanging and insert mode. But my cursor still is inside of the {} > >>> > >>> Is it possible to let the macros recognize the pressing of '' > >>> and then jump behind the '}' and may be entering 'i'nsert mode again? > >>> > >>> Or may be I need a completly different implementation of those macros > >>> for that? > >>> > >>> I often feel, that I am not thinking vim-y enough. ;o) > >>> > >>> Thanks a lot for all your help! > >>> > >>> Keep hacking! > >>> mcc > >>> > >>> > >> The {rhs} (right-hand side) of a mapping is exactly the sequence of keys > >> as > >> you would hit them to accomplish the desired action. In Insert mode you > >> can > >> move the cursor using etc., so instead of ?# you > >> can > >> use . This means that you can leave out the # in the first > >> place, > >> and just use one to place the cursor before the }. You then remain > >> in > >> Insert mode to insert whatever you want through the keyboard after the > >> mapping > >> has finished: > >> > >>:imap b {\bf } > >> > >> etc. > >> > >> If you want the _next_ use of to move the cursor after the } then it > >> becomes more intricate: you will need to use a function as {rhs} to return > >> the > >> required string and remap as a side-effect; but "what you remap > >> > >> to" must not only do the required cursor move but also unmap itself. In > >> this > >> case I don't think the game is worth the candle, especially if {\bf } {\it > >> } > >> {\sl } etc. can be nested. It may be simpler to just hit to go > >> past > >> the right-bracket when you want to close the "{\bf " or similar. > >> > >> Another possibility is to simply yank these strings (without the closing > >> brace) into some registers (which will be saved in your viminfo so you do > >> this > >> only once, at the command-line): > >> > >>:let @b = '{\bf ' > >>:let @i = '{\it ' > >>:let @s = '{\sl ' > >> > >> (Note the _single_ quotes.) Then, in Insert mode, b will insert > >> {\bf and similarly for the other two (even after you close and > >> reopen > >> Vim, without the need to reenter them). Hit } to close the (bold?) text > >> area. > >> > >> > >> Best regards, > >> Tony. > >> > > > > Hi Tony, > > > > as I said...I am currently not thinking vim-y enough ... :))) > > > > With "" it is so much easier to achieve the wanted effect than > > jumping betwen the modes and inserting things only for the purpose of > > replaceing them with something different... > > > > And the register-trick with @b,@f,@s is even more simpler! > > > > One last question: > > Will it hurt or eat up my system resources :) when I insert the 'let' > > commands into my .vimrc? > > well, it will just (after the first time) place into your registers what is > already there because your viminfo automatically saves it from session to > session. The "resources" it "eats up" are, I suppose, a few bytes of vimrc > disk space and a few milliseconds of st
Re: Mapping of keysequences...
Meino Christian Cramer wrote: From: "A.J.Mechelynck" <[EMAIL PROTECTED]> Subject: Re: Mapping of keysequences... Date: Sun, 01 Oct 2006 19:44:39 +0200 Meino Christian Cramer wrote: [...] Hi Tony ! nice to read you again! And thank you very much for your help,help,help... :) <- BIG smiley! Slowly and surely I get my TeX macro working... What I have now is the following: inoremap b {\bf #}?#c/} inoremap i {\it #}?#c/} inoremap s {\sl #}?#c/} which "works". A last wish I would have is: After 'c'hanging the '#' to what I really want to typeset I will press to leave 'c'hanging and insert mode. But my cursor still is inside of the {} Is it possible to let the macros recognize the pressing of '' and then jump behind the '}' and may be entering 'i'nsert mode again? Or may be I need a completly different implementation of those macros for that? I often feel, that I am not thinking vim-y enough. ;o) Thanks a lot for all your help! Keep hacking! mcc The {rhs} (right-hand side) of a mapping is exactly the sequence of keys as you would hit them to accomplish the desired action. In Insert mode you can move the cursor using etc., so instead of ?# you can use . This means that you can leave out the # in the first place, and just use one to place the cursor before the }. You then remain in Insert mode to insert whatever you want through the keyboard after the mapping has finished: :imap b {\bf } etc. If you want the _next_ use of to move the cursor after the } then it becomes more intricate: you will need to use a function as {rhs} to return the required string and remap as a side-effect; but "what you remap to" must not only do the required cursor move but also unmap itself. In this case I don't think the game is worth the candle, especially if {\bf } {\it } {\sl } etc. can be nested. It may be simpler to just hit to go past the right-bracket when you want to close the "{\bf " or similar. Another possibility is to simply yank these strings (without the closing brace) into some registers (which will be saved in your viminfo so you do this only once, at the command-line): :let @b = '{\bf ' :let @i = '{\it ' :let @s = '{\sl ' (Note the _single_ quotes.) Then, in Insert mode, b will insert {\bf and similarly for the other two (even after you close and reopen Vim, without the need to reenter them). Hit } to close the (bold?) text area. Best regards, Tony. Hi Tony, as I said...I am currently not thinking vim-y enough ... :))) With "" it is so much easier to achieve the wanted effect than jumping betwen the modes and inserting things only for the purpose of replaceing them with something different... And the register-trick with @b,@f,@s is even more simpler! One last question: Will it hurt or eat up my system resources :) when I insert the 'let' commands into my .vimrc? well, it will just (after the first time) place into your registers what is already there because your viminfo automatically saves it from session to session. The "resources" it "eats up" are, I suppose, a few bytes of vimrc disk space and a few milliseconds of startup time ;-). Nothing much to worry about. This is to avoid haveing "one part" of a macro in .vimrc and the other one in .viminfonot to confuse myself right in the beginning of learning of vim if not needed. Thank you very much, Tony ! Keep hacking! mcc And if you put these three values in the registers, you don't need anything for this in the vimrc -- there is no "other part". Ctrl-R letter (in Insert mode) directly invokes the corresponding register. Similarly Ctrl-R + (the system clipboard), Ctrl-R / (the latest search pattern), etc. There are several ways to invoke each register: "x in Normal mode commands (y, d, p etc.) @x in expressions and in :let, :redir, etc. x in the argument to :yank, :put etc. "x" in the first argument to setreg() etc. xin Insert/Replace and Command-line modes In all these cases, the register is the same if the letter is the same. And if you ever forget what is in your registers, there is always the ":reg[isters]" command. Best regards, Tony.
Re: Mapping of keysequences...
From: "A.J.Mechelynck" <[EMAIL PROTECTED]> Subject: Re: Mapping of keysequences... Date: Sun, 01 Oct 2006 19:44:39 +0200 > Meino Christian Cramer wrote: > [...] > > Hi Tony ! > > > > nice to read you again! And thank you very much for your > > help,help,help... :) <- BIG smiley! > > > > Slowly and surely I get my TeX macro working... > > > > What I have now is the following: > > > >inoremap b {\bf #}?#c/} > >inoremap i {\it #}?#c/} > >inoremap s {\sl #}?#c/} > > > > which "works". A last wish I would have is: After 'c'hanging the '#' > > to what I really want to typeset I will press to leave > > 'c'hanging and insert mode. But my cursor still is inside of the {} > > > > Is it possible to let the macros recognize the pressing of '' > > and then jump behind the '}' and may be entering 'i'nsert mode again? > > > > Or may be I need a completly different implementation of those macros > > for that? > > > > I often feel, that I am not thinking vim-y enough. ;o) > > > > Thanks a lot for all your help! > > > > Keep hacking! > > mcc > > > > > > The {rhs} (right-hand side) of a mapping is exactly the sequence of keys as > you would hit them to accomplish the desired action. In Insert mode you can > move the cursor using etc., so instead of ?# you can > use . This means that you can leave out the # in the first place, > and just use one to place the cursor before the }. You then remain in > Insert mode to insert whatever you want through the keyboard after the > mapping > has finished: > > :imap b {\bf } > > etc. > > If you want the _next_ use of to move the cursor after the } then it > becomes more intricate: you will need to use a function as {rhs} to return > the > required string and remap as a side-effect; but "what you remap > to" must not only do the required cursor move but also unmap itself. In this > case I don't think the game is worth the candle, especially if {\bf } {\it } > {\sl } etc. can be nested. It may be simpler to just hit to go past > the right-bracket when you want to close the "{\bf " or similar. > > Another possibility is to simply yank these strings (without the closing > brace) into some registers (which will be saved in your viminfo so you do > this > only once, at the command-line): > > :let @b = '{\bf ' > :let @i = '{\it ' > :let @s = '{\sl ' > > (Note the _single_ quotes.) Then, in Insert mode, b will insert > {\bf and similarly for the other two (even after you close and reopen > Vim, without the need to reenter them). Hit } to close the (bold?) text area. > > > Best regards, > Tony. > Hi Tony, as I said...I am currently not thinking vim-y enough ... :))) With "" it is so much easier to achieve the wanted effect than jumping betwen the modes and inserting things only for the purpose of replaceing them with something different... And the register-trick with @b,@f,@s is even more simpler! One last question: Will it hurt or eat up my system resources :) when I insert the 'let' commands into my .vimrc? This is to avoid haveing "one part" of a macro in .vimrc and the other one in .viminfonot to confuse myself right in the beginning of learning of vim if not needed. Thank you very much, Tony ! Keep hacking! mcc
Re: Mapping of keysequences...
Meino Christian Cramer wrote: [...] Hi Tony ! nice to read you again! And thank you very much for your help,help,help... :) <- BIG smiley! Slowly and surely I get my TeX macro working... What I have now is the following: inoremap b {\bf #}?#c/} inoremap i {\it #}?#c/} inoremap s {\sl #}?#c/} which "works". A last wish I would have is: After 'c'hanging the '#' to what I really want to typeset I will press to leave 'c'hanging and insert mode. But my cursor still is inside of the {} Is it possible to let the macros recognize the pressing of '' and then jump behind the '}' and may be entering 'i'nsert mode again? Or may be I need a completly different implementation of those macros for that? I often feel, that I am not thinking vim-y enough. ;o) Thanks a lot for all your help! Keep hacking! mcc The {rhs} (right-hand side) of a mapping is exactly the sequence of keys as you would hit them to accomplish the desired action. In Insert mode you can move the cursor using etc., so instead of ?# you can use . This means that you can leave out the # in the first place, and just use one to place the cursor before the }. You then remain in Insert mode to insert whatever you want through the keyboard after the mapping has finished: :imap b {\bf } etc. If you want the _next_ use of to move the cursor after the } then it becomes more intricate: you will need to use a function as {rhs} to return the required string and remap as a side-effect; but "what you remap to" must not only do the required cursor move but also unmap itself. In this case I don't think the game is worth the candle, especially if {\bf } {\it } {\sl } etc. can be nested. It may be simpler to just hit to go past the right-bracket when you want to close the "{\bf " or similar. Another possibility is to simply yank these strings (without the closing brace) into some registers (which will be saved in your viminfo so you do this only once, at the command-line): :let @b = '{\bf ' :let @i = '{\it ' :let @s = '{\sl ' (Note the _single_ quotes.) Then, in Insert mode, b will insert {\bf and similarly for the other two (even after you close and reopen Vim, without the need to reenter them). Hit } to close the (bold?) text area. Best regards, Tony.
Re: Mapping of keysequences...
From: "A.J.Mechelynck" <[EMAIL PROTECTED]> Subject: Re: Mapping of keysequences... Date: Sun, 01 Oct 2006 18:40:47 +0200 > Meino Christian Cramer wrote: > > From: Mikolaj Machowski <[EMAIL PROTECTED]> > > Subject: Re: Mapping of keysequences... > > Date: Sun, 1 Oct 2006 15:09:56 +0200 > > > >> Dnia niedziela, 1 października 2006 14:54, Meino Christian Cramer napisał: > >>> Hi, > >>> > >>> is it possible to map the sequence of > >>> > >>> b > >>> > >>> to anything (and how?)? > >>> > >>> I tried as a first brute-force experiment > >>> > >>> noremap b echo "works" > >> If you want to print it in the buffer it should be:: > >> > >> noremap b iecho "works" > >> > >> If you want to echo it in command line:: > >> > >> noremap b :echo "works" > >> > >> Normal mode mappings begin in Normal mode, not Insert or Command-Line. > >> > >> m. > >> > > > > HmmmppffI got a problem here... > > > > What I want is to insert the string "{\bf }" (TeX!) in a buffer. It > > should work in insert mode. I want to press b in insert mode > > and it should print "{\bf }" at the place where currently the cursor > > is. > > > > I did > > > > inoremap b iecho "{\bf }" > > > > . And guess what happens? It prints "iecho {\bf }" into the buffer! > > When using 'noremap' instead of 'inoremap' nothing happens. > > > > :he iecho > > > > gives me simply nothing. Is there any needle in the haystack I can > > search for? > > > > Keep hacking! > > mcc > > > > > > If you are already in Insert mode, the right-hand side of the mapping is used > as if you had typed it. To insert left-brace backslash bee eff space > right-brace, use > > :inoremap b {\bf } > > To do the same from Normal mode, use > > :noremapb i{\bf } > > with i to enter Insert mode and to leave it. > > > Best regards, > Tony. > Hi Tony ! nice to read you again! And thank you very much for your help,help,help... :) <- BIG smiley! Slowly and surely I get my TeX macro working... What I have now is the following: inoremap b {\bf #}?#c/} inoremap i {\it #}?#c/} inoremap s {\sl #}?#c/} which "works". A last wish I would have is: After 'c'hanging the '#' to what I really want to typeset I will press to leave 'c'hanging and insert mode. But my cursor still is inside of the {} Is it possible to let the macros recognize the pressing of '' and then jump behind the '}' and may be entering 'i'nsert mode again? Or may be I need a completly different implementation of those macros for that? I often feel, that I am not thinking vim-y enough. ;o) Thanks a lot for all your help! Keep hacking! mcc
Re: Mapping of keysequences...
Meino Christian Cramer wrote: From: Mikolaj Machowski <[EMAIL PROTECTED]> Subject: Re: Mapping of keysequences... Date: Sun, 1 Oct 2006 15:09:56 +0200 Dnia niedziela, 1 października 2006 14:54, Meino Christian Cramer napisał: Hi, is it possible to map the sequence of b to anything (and how?)? I tried as a first brute-force experiment noremap b echo "works" If you want to print it in the buffer it should be:: noremap b iecho "works" If you want to echo it in command line:: noremap b :echo "works" Normal mode mappings begin in Normal mode, not Insert or Command-Line. m. HmmmppffI got a problem here... What I want is to insert the string "{\bf }" (TeX!) in a buffer. It should work in insert mode. I want to press b in insert mode and it should print "{\bf }" at the place where currently the cursor is. I did inoremap b iecho "{\bf }" . And guess what happens? It prints "iecho {\bf }" into the buffer! When using 'noremap' instead of 'inoremap' nothing happens. :he iecho gives me simply nothing. Is there any needle in the haystack I can search for? Keep hacking! mcc If you are already in Insert mode, the right-hand side of the mapping is used as if you had typed it. To insert left-brace backslash bee eff space right-brace, use :inoremap b {\bf } To do the same from Normal mode, use :noremapb i{\bf } with i to enter Insert mode and to leave it. Best regards, Tony.
Re: Mapping of keysequences...
From: Mikolaj Machowski <[EMAIL PROTECTED]> Subject: Re: Mapping of keysequences... Date: Sun, 1 Oct 2006 15:09:56 +0200 > Dnia niedziela, 1 października 2006 14:54, Meino Christian Cramer napisał: > > Hi, > > > > is it possible to map the sequence of > > > > b > > > > to anything (and how?)? > > > > I tried as a first brute-force experiment > > > > noremap b echo "works" > > If you want to print it in the buffer it should be:: > > noremap b iecho "works" > > If you want to echo it in command line:: > > noremap b :echo "works" > > Normal mode mappings begin in Normal mode, not Insert or Command-Line. > > m. > HmmmppffI got a problem here... What I want is to insert the string "{\bf }" (TeX!) in a buffer. It should work in insert mode. I want to press b in insert mode and it should print "{\bf }" at the place where currently the cursor is. I did inoremap b iecho "{\bf }" . And guess what happens? It prints "iecho {\bf }" into the buffer! When using 'noremap' instead of 'inoremap' nothing happens. :he iecho gives me simply nothing. Is there any needle in the haystack I can search for? Keep hacking! mcc
Re: Mapping of keysequences...
Dnia niedziela, 1 października 2006 14:54, Meino Christian Cramer napisał: > Hi, > > is it possible to map the sequence of > > b > > to anything (and how?)? > > I tried as a first brute-force experiment > > noremap b echo "works" If you want to print it in the buffer it should be:: noremap b iecho "works" If you want to echo it in command line:: noremap b :echo "works" Normal mode mappings begin in Normal mode, not Insert or Command-Line. m.
Re: Mapping of keysequences...
From: "A.J.Mechelynck" <[EMAIL PROTECTED]> Subject: Re: Mapping of keysequences... Date: Sun, 01 Oct 2006 15:09:17 +0200 > Meino Christian Cramer wrote: > > Hi, > > > > is it possible to map the sequence of > > > > b > > > > to anything (and how?)? > > > > I tried as a first brute-force experiment > > > > noremap b echo "works" > > > > But it does not "works"... :) > > > > Any chance to do such a trick? > > > > Thanks a lot for any help ! > > keep hacking! > > mcc > > > > Mapping Ctrl-C works only when Vim is waiting for input (see "help > map_CTRL-C"); however, your brute-force method is in error. You should have > tried > > :noremap b :echo "works" > > with a colon to start an Ex-command and a carriage-return to end it. > > > Best regards, > Tony. > Hi Tony, ah...oh! Yes! I should had know this... With the additional ":" and it works nicely! *THANKS* :O) Keep hacking! mcc
Re: Mapping of keysequences...
Meino Christian Cramer wrote: Hi, is it possible to map the sequence of b to anything (and how?)? I tried as a first brute-force experiment noremap b echo "works" But it does not "works"... :) Any chance to do such a trick? Thanks a lot for any help ! keep hacking! mcc Mapping Ctrl-C works only when Vim is waiting for input (see "help map_CTRL-C"); however, your brute-force method is in error. You should have tried :noremap b :echo "works" with a colon to start an Ex-command and a carriage-return to end it. Best regards, Tony.
Mapping of keysequences...
Hi, is it possible to map the sequence of b to anything (and how?)? I tried as a first brute-force experiment noremap b echo "works" But it does not "works"... :) Any chance to do such a trick? Thanks a lot for any help ! keep hacking! mcc