Vim: Repeating Commands "Till Condition" rather then "Count of Times"
It happens to me many times that I want to repeat a command in Vim till a certain condition is satisfied rather than just multiple times. For example, say I want to make this code tidier:
Ogre::String GetConfigPath() const { return m_configPath; }
Ogre::String GetConfigName() const { return m_configName; }
Ogre::String GetConfigFileName() const { return m_configPath + m_configName + ".txt"; }
Ogre::String GetConfigStateFileName() const { return m_configPath + m_configName + "-state.txt"; }
Ogre::String GetConfigStatisticsFileName() const { return m_configPath + m_configName + "-statistics.txt"; }
Ogre::String GetConfigDetailedStatisticsFileName() const { return m_configPath + m_configName + "-detailed_statistics.txt"; }
Wh开发者_如何学编程at I usually do is to go to the function with longest name, press 'Tab' then align the other braces of other functions to match this one. Obviously, the task is now to add spaces before the braces of other functions until the cursor is at position, say, 80 (which the position of the brace of the longest function).
Is there anyway of repeating the command until the cursor is at position x?
This is just an example, and I frequently need to repeat a command until a certain condition is fulfilled.
Any idea?
I don't know how to do this through vim only, but I believe you should try the Align script.
精彩评论