Hi huangyingw!
On Sa, 13 Sep 2014, huangyingw wrote:
> When I used variable,
> [code]
>
> nnoremap <leader>1 :let file1=expand("%:p")<CR>
>
> function! CompareTwoFiles()
> execute '!kdiff3' file1 expand("%:p")
> endfunc
>
> nnoremap <leader>2 :call CompareTwoFiles()<cr>
>
> [/code]
> I got following error
> [code]
> Error detected while processing function CompareTwoFiles:
> line 1:
> E121: Undefined variable: file1
> E15: Invalid expression: file1 expand("%:p")
> [/code]
That is because file1 is seen as function local variable, while you want
to access the global variable file1, so use g:file1
Note, you probably want to test, whether file1 is empty (happens for a
new empty buffer).
Best,
Christian
--
Die Menschen von heute wünschen das Leben von übermorgen zu den
Preisen von vorgestern.
-- Tennessee Williams
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sunday, September 14, 2014
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment