Emacs-like mappings

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Emacs-like mappings

Matt Rechkemmer
Just curious if there's a way to map things like C-x+C-s, and C-x+C-c.  I
googled around for this a bit, but couldn't come up with anything useful.
Doing <C-xC-s> or <C-x><C-s> doesn't work.

Any help on this is greatly appreciated!

Thanks,

--
Matt Rechkemmer
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Emacs-like mappings

Tim Chase-2
> Just curious if there's a way to map things like C-x+C-s, and
> C-x+C-c.  I googled around for this a bit, but couldn't come
> up with anything useful. Doing <C-xC-s> or <C-x><C-s> doesn't
> work.

The following mapping worked for me:

        :inoremap <c-x><c-s> :echo "boink!"<cr>

Not being an emacs sorta fellow, I couldn't tell you what that
action (:echo "boink!"<cr>") should be doing in the emacs world.

The other mapping, using the C-c is going to fail, as Vim seems
to treat ^C as an "abort this mapping" command.  Thus, it sees
the ^X as a leader for a pending command, and then sees the ^C as
an "abort this attempt at a command".

        :help ^C

states "In Normal mode, any pending command is aborted."

Additionally, depending on which version of Vim, ^S may not be
mappable (mapable?  mapible?  mappible?  is it a word?), as it,
along with ^Q are know to be flow-control characters.  The
terminal may intercept them before they get to Vim and prevent
Vim from seeing them.  The mapping worked in my Win32 gvim, and
likely works on Win32 console vim as well as *nix gvim.  However,
with *nix console vim, you may see problems.

For a more accurate Emacs experience, I recommend

        :w  | !emacs %

;-)

Just a few early Saturday morning thoughts on the matter.

-tim




Reply | Threaded
Open this post in threaded view
|

Re: Emacs-like mappings

Matt Rechkemmer
On Sat, Oct 01, 2005 at 07:43:58AM -0500, Tim Chase wrote:
>
> The other mapping, using the C-c is going to fail, as Vim seems
> to treat ^C as an "abort this mapping" command.  Thus, it sees
> the ^X as a leader for a pending command, and then sees the ^C as
> an "abort this attempt at a command".

I guess that knocks out my ability to have C-x C-c functionality.

> Additionally, depending on which version of Vim, ^S may not be
> mappable (mapable?  mapible?  mappible?  is it a word?), as it,
> along with ^Q are know to be flow-control characters.  The
> terminal may intercept them before they get to Vim and prevent
> Vim from seeing them.  The mapping worked in my Win32 gvim, and
> likely works on Win32 console vim as well as *nix gvim.  However,
> with *nix console vim, you may see problems.

I'm using VIM 6.3 (6.3.071 according to Debian).  I couldn't get C-x C-s to
work either.  I've been trying to get off my Emacs crutch, and fully move to
VIM.  I suppose I could just get used to the VIM equivalents, but it would
have been nice to map them...

Thanks for the help!

--
Matt Rechkemmer
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Emacs-like mappings

Göran Gustafsson
In reply to this post by Tim Chase-2
On 10/1/05, Tim Chase <[hidden email]> wrote:
> The following mapping worked for me:
>
>         :inoremap <c-x><c-s> :echo "boink!"<cr>
>

This actually did work but just to make things clear it should be:

:inoremap <c-x><c-s> <esc>:echo "boink!"<cr>
:noremap <c-x><c-s> :echo "boink!"<cr>

Thanks so much for enlightening me on this subject :-)
It's something that i find really useful.

- Göran Gustafsson - http://www.fulknark.se
Reply | Threaded
Open this post in threaded view
|

Re: Emacs-like mappings

Yegappan Lakshmanan
Hi,

On 10/2/05, Göran Gustafsson <[hidden email]> wrote:

> On 10/1/05, Tim Chase <[hidden email]> wrote:
> > The following mapping worked for me:
> >
> >         :inoremap <c-x><c-s> :echo "boink!"<cr>
> >
>
> This actually did work but just to make things clear it should be:
>
> :inoremap <c-x><c-s> <esc>:echo "boink!"<cr>
>

Instead of "<esc>", you should use <CTRL-O>:

   inoremap <c-x><c-s> <c-o>:echo "boink!"<cr>

If you use <esc>, after invoking the map, you will be in normal
mode. If you use <c-o>, after invoking the map, you will still
be in insert mode.

- Yegappan

> :noremap <c-x><c-s> :echo "boink!"<cr>
>
> Thanks so much for enlightening me on this subject :-)
> It's something that i find really useful.
>