Brian Vandenberg
Brian Vandenberg

Reputation: 4121

Vim: How to use function call results in : prompt commands

As an example, suppose I have a few windows open in vim:

:echo winnr()
:argument 5

... will print out the current window number, then switch to the 5th file passed to vim on the command-line. Supposing winnr() == 5, then I would expect ...

:argument winnr()

... to open the 5th file for editing. However, vim treats this as though I had typed argument with no parameters.

can I use function call results as parameters to vim commands as attempted above?

Upvotes: 1

Views: 173

Answers (1)

Brian Vandenberg
Brian Vandenberg

Reputation: 4121

Finally found the answer. I thought about deleting the question, but someone might like to know the answer.

:execute 'argument ' . winnr()

Upvotes: 1

Related Questions