Saturday, May 5, 2012

RE: Insert the directory of the current buffer in command line mode

kuaf wrote:
> 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?

See Tim's reply. However, whether to use '%:h' or '%:p:h' would
be a personal preference. If the current file is in what Vim
regards as the current directory, the former would give '.'
while the latter would give the full path.

See the following for inserting name in buffer:
http://vim.wikia.com/wiki/Insert_current_filename

John

--
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

No comments: