On 11/24/11 02:12, Preben Randhol wrote:
I have made some vimscripts for Python programming. I made them for
Vim 7.0, but now I need to get them to work on Vim 6.3 as I have to
work on a system where I cannot update Vim.

My main problem is that I cannot figure out how I can call a function
like one can in Vim 7

function! PM_Insert_Code(function_name) "{{{1
        " Calls the given function and inserts the text

        let Func = function(a:function_name)
        execute "normal! a". Func()

endfunction

function! foo()

Glad I still have a machine with 6.2 on it to test this.
(ducks as Tony hurls a "hey, you should upgrade!" email at me :)

You likely want something like

  function! PM_Insert_Code(function_name)
    echo 'About to call '.(a:function_name)
    call {a:function_name}()
    echo 'Returning from '.(a:function_name)
  endfunction

  function! MyFunc()
    echo 'Calling MyFunc()'
  endfunction

  call PM_Insert_Code('MyFunc')

which you can read about at

  :help curly-braces-names
  :h curly-braces-function-names

It's ripe for abuse, but there are times like this where it's *exactly* what you need.

-tim


--
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

Reply via email to