Vim的:使用选项卡压痕,用C源文件调整空间 [英] Vim: Use tabs for indentation, spaces for alignment with C source files

查看:223
本文介绍了Vim的:使用选项卡压痕,用C源文件调整空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人在使用硬片作为缩进字符的方式她的vim的设置,但会使用空间的调整?我的问题是,开始像一个续行,当

Does anybody have her vim setup in a way that uses hard tabs as indentation characters, but does use spaces for alignment? The problem I have is that when starting a continuation line like in

if (condition1 && (anotherlongcondition || /* <-- Here I insert a newline */
|-------|-------   whatever  /* some additional alignment added automatically */

,然后 CIN (这是一个必须对我来说)增加了一些调整只是我的方式preFER 在位置,但这种调整用尽可能多的硬标签,尽可能填补剩下的用空格(当我试着想象)被创建。

, then cin (which is a must for me) adds some alignment just the way I prefer positionally, but this alignment is created using as much hard tabs as possible and filling the rest with spaces (as I tried to visualize).

因此​​,简而言之, CIN 并没有真正似乎缩进调整区分。我真的很喜欢,所有在上面的例子中所添加的对齐空间。这种方式的切换 TS当对准将是preserved正确暂时的。

So, in short, cin doesn't really seem to distinguish between indentation and alignment. I'd really like that all the added alignment in the example above is spaces. This way the alignment would be preserved correctly when switching ts temporarily.

要使其再次明确,我希望能够写入以下code,从未pressing &LT;标签&gt; &lt;空&GT; 中的第一个非空白字符的任意行前(并没有做任何手动换档或其他):

To make it clear again, I'd like to be able to write the following code, never pressing <TAB> or <SPACE> in front of the first non-blank character in any line (and not doing any manual shifting or whatever):

void foo(int bar)
{
|-------somestatement;
|-------if (somecondition && (someothercondition ||
|-------                      whatevercomesnext))
|-------|-------dosomething;
}

我已经尝试了 ctab.vim ,但它着重于编辑对齐线软标签,这似乎是愚蠢的我,因为人工调整是得到1步细化,而不是标签宽度步细化任务。我没有改变的方式 CIN 使用混合制表和空格的排列。

I have already tried out ctab.vim, but it focuses on editing an aligned line with soft tabs, which seems silly to me because manual alignment is a task which affords 1-step refinement and not tab-width-step refinement. I did not change the way cin uses mixed tabs and spaces for alignment.

我还没有设法找到任何内置的方式来实现这一目标。或许还在,有一个?无论如何,我怀疑有一个插件,做到这一点。虽然我诚然不VIM脚本自己,可能没有足够的经验,我必须说,大多数的插件我尝试了只搞砸了我的编辑配置...

I have not managed to find any built-in way to accomplish that. Perhaps still, there is one? Anyway, I doubt that there's a plugin that does that. Although I admittedly don't vim-script myself and may not have enough experience, I must say that most plugins I tried out only messed up my editor configuration...

推荐答案

好了,遗憾的问题。我终于找到了一些好的材料吧。

Okay, sorry for the question. I've finally found some good material for it.

http://vim.1045645.n5.nabble.com/Indent-with-tabs-align-with-spaces-td1183279.html

综上所述,目前VIM不够灵活为此得到轻松完成。

To sum up, currently vim is not flexible enough for this to be done comfortably.

我的解决办法目前正在使用:集cinoptions =(1 这起续行时只添加一个对准单元这样的话,我可以肯定的是,添加的调整是一个空间(只要我没:设置TS = 1 ,至少),并添加了手动位漂亮的量这仍然是确定在速度方面和似乎是最不分散注意力的行为给我!

My workaround currently is using :set cinoptions=(1 which adds only one alignment unit when starting a continuation line. This way, I can be sure that the added alignment is a space (as long as I did not :set ts=1, at least) and add the nice amount of spaces manually. This is still ok in terms of speed and seems to be the least distracting behaviour to me!

这篇关于Vim的:使用选项卡压痕,用C源文件调整空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆