> hey guys, I want to write a function in _vimrc to compile some source
> code file .
>
> For example, I want to use "set makeprg=javac\ %" to compile .java
> file, and if there is no error I wanna vim to continue run the "java
> %<", and if there are any errors , I wanna vim to open the quickfix
> windows automatically. So , the problem is how to judge whether there
> is error after compile . I wanna use vim's function filereadable() to
> judge whether there is any error (if there is error , javac will not
> create a class file ), but when I try to use this function, I found
> that the function filereadable() can't receive arguments like % and
> %<, the result is , ":echo filereadable("test.class")" is 1, but
> ":echo filereadable("%<.class")" is 0 .The current file I am editing
> is test.java, so this confused me a lot .
>
> I wonder whether fuctions like filereadable() can receive arguments
> like % or %<, and anyone who can help me to write my own function ?
> Thanks a lot .
There may be a better way to solve the original problem, but I'm
only going to address the filereadable() issue.
Special file names such as %< need to be expanded to their actual
names before they can be used by most functions. This is done
automatically on the command line. When passing such names to
functions, you must expand the names using the expand() function,
like this:
:echo filereadable(expand("%<").".class"))
Regards,
Gary
> sorry for my poor English , I hope you guys can understand what I
> mean .
A question that is presented clearly and logically goes a long way
toward overcoming limitations in language. Your question was very
clear and I understood you just fine.
Regards,
Gary
--
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:
Post a Comment