Vim 中令人恼火的 Tab 问题,Haskell 的读写问题
我正在使用“Bird”风格的识字haskell,它要求所有代码如下所示:
> module Main (main) where
如果我有一个块,它应该看起来像这样:
> main = do
> args = getArgs
> file = args!![0]
等等。但是,当我输入gt符号时,然后输入一个空格并点击tab键仅两个个空格上的制表符!
我已执行以下操作来尝试解决该问题:
set tabexpand
set tabstop=4
set softtabstop=4
set noautoindent
set shiftwidth=4
任何帮助将不胜感激 我认为上述内容基本上只会使其插入 4 个空格而不是任何制表符。
I am using "Bird" style literate haskell, which requires all code to be like the following:
> module Main (main) where
and if I have a block it should look something like this:
> main = do
> args = getArgs
> file = args!![0]
etc. However when I enter the gt sign, then a space and hit tab it tabs over only two spaces!
I have done the following to try to fix the problem:
set tabexpand
set tabstop=4
set softtabstop=4
set noautoindent
set shiftwidth=4
Any help would be much appreciated I thought the above would essentially just make it insert 4 spaces rather than any tabs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道有什么简单的方法可以解决这个问题,但这里有一些您可以尝试的解决方法(按复杂程度粗略排序)。
将缩进设置为两个空格,并且必须按两次 Tab 键。
使制表符在插入模式下不加区别地插入 4 个空格,忽略所有制表位和缩进规则/选项。
使用经过修补的 Vim,它允许您设置任意制表符。 Vim 补丁页面上有一个变量制表位补丁。
编写您自己的缩进算法。有关如何执行此操作的详细信息,请参阅
:help indentexpr
。I don't know any easy way to solve this, but here are some workarounds you can try (in rough order of complexity).
Set your indentation to two spaces and live with having to press tab twice.
Make tab indiscriminately insert 4 spaces in insert mode, ignoring all tab stop and indentation rules/options.
Use a patched Vim which allows you to set arbitrary tabstops. There's a variable tabstops patch at the Vim patches page.
Write your own indentation algorithm. See
:help indentexpr
for details on how to do this.设置shiftwidth=4
set shiftwidth=4
当然,Vim 将光标移动到下一个制表位所在的第 4 列。不知道是否有办法将第一个制表位设置为第 6 列(或 2)。
Sure, Vim moves the cursor to col 4 where the next tabstop is located. Don't know if there is a way to set the first tabstop to col 6 (or 2) instead.