On Mon, 22 May 2006 at 4:07am, Eric Arnold wrote: > On 5/21/06, Hari Krishna Dara <[EMAIL PROTECTED]> wrote: > > > > On Sun, 21 May 2006 at 3:12pm, Eric Arnold wrote: > > > > > I've been trying to map "cd" if it's the first two characters on the > > > :ex line. I've tried all the combinations I can think of. On > > > several of them, I seem to be getting errors as if <expr> is run in > > > the sandbox (that dog won't hunt). The only one that works at all is > > > the first simple mapping, but that gets painful, of course, when you > > > want to use "cd" in a search, etc. > > > > > > Anybody know any good tricks? > > > > > > > > > silent! cunmap cd > > > > > > cnoremap <silent> cd call Cd_plus()<CR> > > > > > > "cnoremap <silent> cd echo getcmdpos()<CR> > > > "cnoremap <silent> cd if getcmdpos() < 3 <bar> call Cd_plus() <bar> > > > else <bar> call feedkeys('cd','n') <bar> call setcmdpos(1) <bar> end > > > <CR> > > > "cnoremap <silent> <expr> cd ( getcmdpos() == 1 ? Cd_plus() : 'cd' ) > > > "cnoremap <silent> <expr> cd Cd_plus() > > > "abbr <silent> <expr> cd Cd_plus() > > > "silent! unabbr cd > > > > You should use the new <expr> option and check if you are in the start > > > <expr> seems to be evaluated in the sandbox as with <C-R>=, I report > with sadness...
Actually cabbr with <expr> option would have been a great solution for you, if not for the fact that that also is evaluated in sandbox. Anyway you fould a solution, I think. -- Hari __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com