Вопрос

When selecting the following code in gvim and hitting "=" it is shifting the parenthesis left on the constructor. Is this a gvim bug or is this some setting I might have to set to fix?

Output:

class GameData
{
  public:
    enum Key { A=0, B, C, D, TOTAL_KEYS };

    GameData() : moves_() , numKeys_(TOTAL_KEYS) 
  {
    populateMoves();
  }

    inline const std::vector<Key>& getMoves ( int k ) const 
    { 
      return moves_[k];
    }

Desired Output:

class GameData
{
  public:
    enum Key { A=0, B, C, D, TOTAL_KEYS };

    GameData(): moves_(), numKeys_(TOTAL_KEYS) 
    {
      populateMoves();
    }

    inline const std::vector<Key>& getMoves ( int k ) const 
    { 
      return moves_[k];
    }
Это было полезно?

Решение

Setting cino=i0 aligns the statements properly with my vim install.

From the help

                        *cino-i*
iN    Indent C++ base class declarations and constructor
      initializations, if they start in a new line (otherwise they
      are aligned at the right side of the ':').
      (default 'shiftwidth').
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top