简体   繁体   English

Kate(文本编辑器)缩进,C++

[英]Kate (text editor) indentation, c++

I use the kate text editor for writing c++ code.我使用 kate 文本编辑器编写 C++ 代码。 I really like the editor except for its indentation behavior which drives me mad.我真的很喜欢这个编辑器,除了它的缩进行为让我发疯。 I have the following problem: If I want to write code like我有以下问题:如果我想编写类似的代码

if( true )
{
    //code
}

the indentation messes everything up initially: instead of inserting a tab and jumping to the position marked " //code " when hitting enter, kate just inserts a single blank space.缩进最初把一切都搞砸了:当按下回车键时,凯特并没有插入一个制表符并跳转到标记为“ //code ”的位置,而是插入一个空格。 So to describe it more in detail: You start from所以更详细地描述它:你从

if( true )
{//your cursor is here
}

and on pressing enter, kate produces something like按下回车键后,凯特会产生类似的东西

if( true )
{
[ ]//your cursor is here
}

where '[ ]' stands for a single blank space.其中 '[ ]' 代表单个空格。 But instead, I want kate to insert a tabulator to give the result indicated at the start.但相反,我希望 kate 插入一个制表符以给出开始时指示的结果。 Or, to repeat it more verbosely, I want that kate gives me或者,更详细地重复一遍,我希望凯特给我

if( true )
{
<tabulator>//your cursor is here
}

on hitting enter.点击进入。 I have played around with all settings and can not make it work.我玩过所有设置,但无法使其正常工作。 It drives me crazy.它让我疯狂。 I selected "default identation mode normal", "Ident using tabulators" (8 characters).我选择了“默认识别模式正常”、“使用制表符进行识别”(8 个字符)。 Does anybody know how to customize this behavior?有人知道如何自定义这种行为吗? I looked up the katerc file but couldn't find any options that would help me...我查找了 katerc 文件,但找不到任何可以帮助我的选项......

edit : I should add that it would be ok if kate would just give me编辑:我应该补充一点,如果凯特给我就可以了

if( true )
{
//your cursor is here
}

on pressing enter.按回车键。 But this additional blank space is absolutely annoying.但是这个额外的空白空间绝对令人讨厌。

Ok, I tried for half an hour, I don't know why I found out how to do it right AFTER posting the question :).好的,我尝试了半个小时,我不知道为什么我在发布问题后才发现如何正确操作:)。 So in case anybody has the same issue, here is the "solution": I missed that kate seems to have a global setting for the indentation mode as well as a local one for every file.因此,如果有人遇到同样的问题,这里是“解决方案”:我错过了 kate 似乎有缩进模式的全局设置以及每个文件的本地设置。 In my case - for some reason - my file had special indentation options set.就我而言 - 出于某种原因 - 我的文件设置了特殊的缩进选项。 You can alter them via the menu bar by chosing "Tools -> Indentation".您可以通过选择“工具 -> 缩进”通过菜单栏更改它们。 This local option overrides the global one!此本地选项覆盖全局选项! Or the global one is just the default for the local options, I don't know exactly...或者全局选项只是本地选项的默认值,我不知道确切......

You can create a config file .kateconfig and add the variables kate: replace-tabs off; tab-indents: true;您可以创建一个配置文件.kateconfig并添加变量kate: replace-tabs off; tab-indents: true; kate: replace-tabs off; tab-indents: true;

More on this in the manual . 手册中有更多关于这方面的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM