On Tue, Jul 8, 2008 at 9:26 AM, Bobby Impollonia wrote: > > Consider the following mapping : > vmap <expr> Q visualmode()==#"V" ? "<ESC>:echo 'line'<CR>" : > "<ESC>:echo 'not line'<CR>" > > I would expect the result to be that hitting Q in visual mode would > echo whether I were in linewise visual mode. > The actual result is that Q tells me whether I had used linewise > visual mode the previous time I used visual mode before this one. > This is altogether consistent with the documentation for visualmode(). > However, it doesn't seem very useful. > Surely it would be better for visualmode() while in visual mode to > report the current visual mode rather than the last one?
No, it wouldn't. There's already a function to tell you which mode you're currently in, mode(). visualmode() serves an entirely different purpose, namely, allowing you to write that mapping this way instead: :vmap Q <Esc>:echo visualmode() ==# "V" ? "line" : "not line"<CR> In the case of your command, visualmode() doesn't give what you want; you need to know what mode you're currently in rather than what visual mode was used last. In the case of my command, mode() doesn't give me what I want; I need to know what visual mode was last used. mode() and visualmode() serve entirely different purposes, and changing visualmode() to be able to be used as a replacement for mode() some of the time, but not all of the time, seems like it would just lead to confusion. Plus, I'm sure I can come up with some circumstances where knowing the previously used visual mode would be useful in visual mode... no good reason to replace that useful information with duplicate information that could be found by calling another function. ~Matt --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
