<tangential-rant-about-greatness-of-digraphs>

it is true that in mappings you can use <C-r>, etc instead of digraphs.
however, i've found that for recording macros on the fly it's very helpful
to know your digraphs -- particularly if you ever edit your macros after
recording.

for example, i have the following mappings in my ~/.vimrc:

nmap qp maGo<ESC>"qP
nmap qd G0"qd$dd`a

these will take the contents of the 'q' register (where i usually record my
one-off macros) and put them on a new line at the end of the file. then i
can make any edits or adjustments i need to my macro and type qd in normal
mode to replace the old contents of the 'q' register (i added some
mark-setting to the mappings so that my cursor will go back where it started
afterwards)

if you use mappings like these, you'll find that vim records certain key
sequences (like carriage return and escape) as digraphs and it behooves one
to know what they mean and how to type them.

knowing/using digraphs also enables you to include things like window
motions (go to the window above this one, do something, come back, etc) and
other fancy stuff to things like global commands. Say i want to copy every
function declaration in a php file to a separate buffer. i can do the
following global command (after opening a new window above the current)

:%g/^function/normal yy^WkGp^Wp

To make a long story short (too late!) digraphs are your friend.

</tangential-rant-about-greatness-of-digraphs>

On Sun, Nov 16, 2008 at 7:31 PM, Ben Schmidt
<[EMAIL PROTECTED]>wrote:

>
> madiyaan wrote:
> > On Nov 16, 12:26 pm, madiyaan <[EMAIL PROTECTED]> wrote:
> >> On Nov 14, 5:16 pm, "Chris Suter" <[EMAIL PROTECTED]> wrote:
> >>
> >>> you could do a mapping such as the following:
> >>> :cmap %/ ^R%^FF/lC
> >> Thank you. This would be something very useful. However, it doesn't
> >> work in my current vim. When I put in just this:
> >>
> >>> :cmap %/ ^R%
> >> It does place the entire full path of the current file in there. But
> >> if I put in the full command that you wrote here, it instead shows me
> >> a history of commands (basically the same window when I do q:) instead
> >> of leaving me with the path of the current file. Any ideas what could
> >> be going wrong? I entered the digraphs correctly as it shows me those
> >> in a different color when I wrote them to my .vimrc file.
> >>
> >> Also, I tried entering F/lC while in normal mode in front of a path in
> >> a regular buffer, and it worked. It seems to me that ^F is not doing
> >> what it should be doing (i.e. it is not putting me into normal mode on
> >> the Ex line). Any help would be appreciated.
> >
> > OK, I figured this one out:
> >
> > cmap %/ ^R%^F$F/lC
> >
> > works as expected, and I thank you for it (there was a missing $). But
> > it would be really really useful if it copied this command back to the
> > Ex command line and not in a separate Ex buffer. That way I could use
> > tab and vim would autocomplete the filename for me.
> >
> > So once again, thanks a lot, but I would appreciate if you could tell
> > me a way to copy this back to the Ex command line (from the Ex history
> > buffer).
>
> Quickly, I can't modify that one, but can propose another similar
> solution if you want to actually see the path on the commandline:
>
> :cmap %/ <C-r>=expand('%:p:h')<CR>/
>
> (Incidentally, you could write ^R and ^F as <C-r> and <C-f> in your one
> above, too, as long as you're not running in compatible mode.)
>
> :help c_CTRL-R_=
> :help expand()
>
> Ben.
>
>
>
>
> >
>


-- 
Christopher Suter

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to