[EMAIL PROTECTED] wrote:
> Hi,
>
> I want to assign the current line under the cursort to an external
> program. Example
>
> Textfile:
> 1 foo
> 2 bar
> 3 calvin
> 4 hobbes
>
> If the cursor is in line 2, want to assign the line "2 bar" to a
> script, like foo.sh.
>
> If I want to call a external script from vim I type in the command
> modus:
>
> :! foo.sh [and hit enter]
>
> Now I want to assign the line in the file to the script via a function
> into the .vimrc.
>
> I know how to get the line, but I dont know how to assign it to the
> external script. Or better I dont know how to use the variale to
> assign the parameter to the script. Basicly I have this in my .vimrc
>
> function Foo( )
> :let start=line( '.' )
> :! foo.sh getline(start) "this dont work :(
exe "!foo.sh" getline(start)
otherwise you pass "getline(start)" to the shell as a literal part of the
command string: Vim does not evaluate it. With ":exe", Vim evaluates each
expression, adds a space between each separate expression, and executes the
result as an ex-command. ":echo" does the same but displays the evaluated
expressions instead, so replacing ":exe" by ":echo" above would let you see
what command your shell would receive.
> endfunction
>
> command Foo call Foo( )
>
> This returns the errormessage:
> /bin/bash: -c: line 0: syntax error near unexpected token `('
> /bin/bash: -c: line 0: ` foo.sh getline( start )'
>
> ideas ?
>
> cheers -- jerik
Best regards,
Tony.
--
This sentence contradicts itself -- no actually it doesn't.
-- Hofstadter
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---