TransWikia.com

Use normal command output as variable

Vi and Vim Asked by Hassek on August 31, 2021

I want to be able to use some normal commands I tend to use in the day to day as an input for another function, for example 4X, I would like 4X to be expanded to XXXX and then use it in a function as :substitude(s, 'here', <expand result of 4X>, 'g')

It’s there an easy way to set this up?

One Answer

In this specific case, you have repeat(4, 'X').

Otherwise, normal and command mode commands don't return anything. They may echo messages (which we can get with execute()), or they can do any kind of action (compile, move cursor, change focus, open/close buffers/windows, change the buffer...). We can't provide a generic answer to your question as there is none.

What are your specific use cases? repeat(). What else?

Correct answer by Luc Hermitte on August 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP