c++ - Emacs - 覆盖缩进

我有一个多重嵌套的命名空间:

namespace first {namespace second {namespace third {
              // emacs indents three times
    // I want to intend here
} } }

所以 emacs 缩进到第三个位置。但是我只想要一个缩进。
能不能简单的实现这个效果?

最佳答案

在命名空间内使用绝对缩进列:

(defconst my-cc-style
  '("gnu"
    (c-offsets-alist . ((innamespace . [4])))))

(c-add-style "my-cc-style" my-cc-style)

然后使用 c-set-style 来使用自己的风格。

请注意,这只适用于 c++-mode,c-mode 不知道 'innamespace'。

https://stackoverflow.com/questions/2619853/

相关文章:

c++ - 如何获得 high_resolution_clock 的精度?

c++ - OpenCV:获取 3 channel RGB 图像,拆分 channel 并仅使用 R

c++ - 在 C/C++ 中从 TCP 套接字读取的正确方法是什么?

c++ - 对两个对应的数组进行排序

c++ - 不能在数组上使用 .begin() 或 .end()

c++ - 使用 boost::graph 获取特定边缘

c++ - 为什么 std::get() 不能用于获取 vector 的成员?

c++ - 了解 double 到 int64_t 的转换

c++ - 在 C++ 中,是否可以获取函数的返回类型以便在不调用该函数的情况下声明一个变量?

c++ - 为什么 PRIu64 在此代码中不起作用?