[Vim-latex-devel] Some problems with command implementation
Brought to you by:
srinathava,
tmaas
From: Srinath A. <sr...@fa...> - 2002-12-27 09:06:58
|
Hello, I am facing a problem implementing some commands in templates.vim, packages.vim and custommacros.vim... I have as an example, the following setup: ---------------------%<--------------------- fun! Foo(...) if a:0 == 0 let name = input('Whats your name?', 'bozo') else let name = a:1 endif return 'Your name is '.name endfun inoremap <F3> <C-r>=Foo()<CR> nnoremap <F3> i<C-r>=Foo()<CR> inoremenu Help.foo <C-r>=Foo()<CR> nnoremenu Help.foo i<C-r>=Foo()<CR> com! -nargs=? FooCom normal! i<C-r>=Foo()<CR> ---------------------%<--------------------- With this setup, the insert and normal mode menu and mappings work as expected. It also works when FooCom is called with 1 argument, such as :FooCom bar However, when FooCom is called without any arguments, we end up always getting a value 'bozo' for name because the <CR> gets eaten up by the input() immediately (I think). Whats a good way to make the command work? I tried placing a ":call getchar()" at the beginning of the function but even then the command without argument doesn't work... Also, I cannot use something like: com! -nargs=? FooCom put!=Foo() because in general Foo() will contain movement commands such as <Esc>3h and stuff... Moreover, sometimes, we would like to end up in say select mode after the function returns... So :put will not work... Any ideas? Srinath |