Monday, February 18, 2013

vim: map a key to "conditionally" override built-in behavior

this looks weird at first glance.
but sometime, I want to give the existing keystroke (like 'h') a new
behavior, at a very certain circumstance.
for example, if you use ranger (file manager), by default it will end up
with opening the text file in vim, if you keep press "l" towards the
file. now you disconnect (temporarily ) with range and you are with vim.
then to go back you have to type vim's keystroke (:q) to exit vim and
turn control back to ranger.

I'm thinking if I want to make it real consistent , I need to have a "h"
key that can exit vim and go back to ranger, just opposite what a "l"
key does in ranger.
but if I map it (absolute map) this way:

map h :q

it will be obviously a disaster.

so , how can I map the 'h', to ":q", if , and only if, say, my cursor is
in the left/top corner of the file?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: