On 05/05/12 20:27, kuaf wrote:
> I saw one line command map used to insert the directory of the current
> buffer in command line mode in steve losh's vimrc:
>
> cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
>
> I imagined it would insert directory of the current buffer when enter
> %% in command mode. But it seemed not work as I imagine. So what I
> missed?
Are you referring to Normal mode as "command mode"? (a common
misnomer). It should perform as advertised: you press ":" to enter
Command mode and then type "%%" and it expands to the relative path
of the current file. Things to watch:
1) it guards against a search command-mode (entered via either "/"
or "?")
2) the behavior may or may not be what you expect if you aren't
currently in a buffer that maps to an existing buffer (such as
'buftype' being one of several non-empty cases)
If you understood the above and it's still not working, check it
with "vim -u NONE" to make sure configuration isn't interfering. It
Works For Me™.
-tim
--
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
Saturday, May 5, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment