[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to map the # key to a command?
From: |
Chris Green |
Subject: |
Re: How to map the # key to a command? |
Date: |
Sat, 13 May 2023 13:55:16 +0100 |
On Sat, May 13, 2023 at 07:48:25AM -0400, Paul Fox wrote:
> chris wrote:
> > On Sat, May 13, 2023 at 11:09:59AM +0100, Chris Green wrote:
> > > On Sat, May 13, 2023 at 11:04:26AM +0100, Chris Green wrote:
> > > > I can map the # key to do ^Xe 'manually' when running vile simply by
> > > > going to the colon prompt and entering 'map ', then entering # in
> > > > response to 'change this string' and, finally ^Xe in response to 'to
> > > > this new string'. The # key then opens the file under the cursor for
> > > > editing.
> > > >
> > > > However I can't seem to get the same result by entering the map
> > > > command in my .vilerc file.
> > > >
> > > > What do I need in .vilerc to get # to 'edit file under cursor'?
> > > >
> > > It's OK, I think I've worked it out, I need to use bind-cmdmode-key to
> > > do it.
> > >
> > But of course rebinding the # key has lots of repercussions! :-) I
> > need to go and rethink what I'm doing!
>
> :-)
>
> I do use map for some things, but sometimes I find it easier
> to use load-register. If I happen to use the register for a yank
> while editing (unlikely for the later members of the alphabet), I
> lose that macro, but it's not a big deal. (I've converted the literal
> ^M characters to two ascii characters for this message, but they need
> to be literal in .vilerc)
>
> ; @h --turn off syntax highlighting
> use-register h load-register ":set nohighlight^M"
> ; @w -- make current buffer's file writeable, and write it
> use-register w load-register ":!chmod +w %^M:w^M"
> ; @s -- suck in my .signature
> use-register s load-register "G:r ~/.signature^M"
>
> I guess it doesn't really help if you're trying to find a shortcut for
> a two character command (^Xe --> #), But unlike ^X, '@' doesn't need a
> modifier.
>
In the end I have used E as I never use[d] the default binding for
that. So:-
bind-key edit-file E
Does just what I want, gives me a single key way to edit files loaded
as a result of 'vi <directory>' which I have just created a need for.
I might even use lower case e (even simpler, no need to shift))
because I don't think I have ever used the default e either.
--
Chris Green