- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想知道如何在 Neovim 启动时将自动缩进设置为四个空格,因为我使用空格进行缩进。
提前致谢。
最佳答案
我不知道 Neovim,但是(从我读到的 there )我猜它在这个主题上与 Vim 兼容。所以下面的解释适用于纯 Vim。
您正在寻找的选项是 'expandtab'
.然而,为了清楚起见,我在进入这个选项之前解释了缩进宽度。
缩进宽度
缩进的宽度由几个选项控制。这里的“缩进”是指例如按 <Tab>
在插入模式(或 <BS>
,退格,撤消现有缩进),或自动增加缩进级别(取决于语言)。
:help tabstop
:help softtabstop
:help shiftwidth
'tabstop'
规定用于显示实际制表符 (
\t
) 的宽度(不是直接感兴趣的,而是见下文)。
'softtabstop'
表示缩进应该跨越的宽度。特殊值 0 表示复制
'tabstop'
的值(或者更准确地说,禁用“软制表位”功能),特殊值 -1 表示复制
'shiftwidth'
的值.
'shiftwidth'
给出用于移位命令的宽度,例如
<<
,
>>
和
==
.特殊值 0 表示复制
'tabstop'
的值.
'expandtab'
设置,缩进总是只使用空格字符。否则,按
<Tab>
插入尽可能多的制表字符,并用空格字符完成缩进宽度。
:help expandtab
tabstop=8
和
softtabstop=3
,然后,在插入模式下:
<Tab>
在空行上将插入 3 个空格,因此总缩进为 3 列宽; <Tab>
再次插入 3 个空格,使总缩进为 6 列宽; <Tab>
将使总缩进 9 列宽;如果 'expandtab'
被设置,那么它将使用总共9个空格来写;否则,它将使用制表字符(替换以前的空格)后跟空格字符编写; <BS>
将撤消第 3 步; <BS>
将撤消第 2 步; <BS>
将撤消步骤 1。'tabstop'
的值即可。随心所欲。它还设置了
'expandtab'
按照你的要求。最后,由于您引发了自动缩进,因此我包含了相关选项:
'autoindent'
,
'smartindent'
和
'cindent'
;但是您应该为此使用特定于语言的插件。
" length of an actual \t character:
set tabstop=4
" length to use when editing text (eg. TAB and BS keys)
" (0 for ‘tabstop’, -1 for ‘shiftwidth’):
set softtabstop=-1
" length to use when shifting text (eg. <<, >> and == commands)
" (0 for ‘tabstop’):
set shiftwidth=0
" round indentation to multiples of 'shiftwidth' when shifting text
" (so that it behaves like Ctrl-D / Ctrl-T):
set shiftround
" if set, only insert spaces; otherwise insert \t and complete with spaces:
set expandtab
" reproduce the indentation of the previous line:
set autoindent
" keep indentation produced by 'autoindent' if leaving the line blank:
"set cpoptions+=I
" try to be smart (increase the indenting level after ‘{’,
" decrease it after ‘}’, and so on):
"set smartindent
" a stricter alternative which works better for the C language:
"set cindent
" use language‐specific plugins for indenting (better):
filetype plugin indent on
.vimrc
中。或
.nvimrc
文件。
" do NOT expand tabulations in Makefiles:
autocmd FileType make setlocal noexpandtab
" for the C language, indent using 4‐column wide tabulation characters,
" but make <Tab> insert half‐indentations as 2 spaces (useful for labels):
autocmd FileType c setlocal noexpandtab shiftwidth=2
" use shorter indentation for Bash scripts:
autocmd FileType sh setlocal tabstop=2
关于vim - 在neovim中将自动缩进设置为空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51995128/
我正在使用 libxml2 的 xmlwriter api 编写一个 xml 文件。 当我使用记事本打开文件时,缩进不正确。 有人知道怎么解决吗? 非常感谢。 最佳答案 我在这里有点冒进,但我会说“缩
我正在尝试让这个脚本工作,但它...给我缩进错误 #!/usr/bin/env python import io myfile = open('stats.txt', 'r') dan = myfil
我使用 Emacs 有一段时间了,我真的很想念一个古老的 Geany 快捷方式 - “C-i”和“C-u”。 “C-i”缩进整个当前行(将鼠标光标保持在原处),“C-u”取消整个当前行的缩进。 我发现
如何向 UILabel 内的文本添加缩进或偏移?它需要是特定的像素大小,与字体大小无关。 最佳答案 您可以创建另一个UILabel,然后将每个标签的框架设置为一定的宽度,这样,如果您想要实现这一目标,
请帮我在 Emacs haskell-mode 中设置正确的缩进 当我尝试输入诸如 ADT 或记录之类的内容时,按 后我进入了错误的列。 ,然后按 不会切换到右边,直到我输入 |或者 ';'! d
我在 Visio 2010 中有一个项目符号列表,我试图在其中缩进二级项目符号。例如: 我希望“子项目符号”项目向右缩进,这样很明显它是一个子元素。我认为功能区上的“增加缩进”选项可以做到这一点,但这
我写了这段代码: addNums key num = add [] key num where add res a:as b:bs | a == [] = res
我在生成的 xml 文档中添加了换行符。 "\n" some text etc."\n" "\n" 这最终应该是: some text etc. 这是否可以通过 google-code-pre
使用 JTabbedPane 时,如何缩进选项卡? Swing 默认输出: ------- --------- ------ | A | | B | | C | --------
我收到这些行的缩进错误 有没有在线验证器可以帮助我? showAliveTests : (pageIndex, statusFilter) -> data= pageI
在 Python 中,当你写了 100 行代码而忘记在某个地方添加一堆循环语句时,你会怎么做? 我的意思是,如果您在某处添加一个 while 语句,您现在必须缩进它下面的所有行。这不像您可以戴上牙套并
我喜欢这样做,如 indesign 或 quark...段落缩进...图片 如何在 html 和 css 中做到这一点的正确方法 我不希望文字环绕图像...我喜欢保护整个左边的部分给图片留边距就可以了
我试过添加 10px 的内边距但没有成功。你可以看到它的一个例子lower down on this page . #menu li { float: left;
这个问题在这里已经有了答案: I'm getting an IndentationError. How do I fix it? (6 个答案) 关闭去年。 while 1 == 1:
您好,我正在尝试使用来自 C# 应用程序的收据打印机打印帐单/收据。 预期的输出是这样的: ITEM NAME QTY PRICE Banana Large Y
有没有办法在 JTextPane 中缩进一段文本? import javax.swing.*; import java.awt.*; import javax.swing.text.StyledDoc
我知道 #define 等通常从不缩进。为什么? 我目前正在编写一些代码,其中混合了#define、#ifdef、#else s、#endifs 等。所有这些通常与普通 C 代码混合在一起。 #def
我认为缩进在 YAML 中很重要。 我在 irb 中测试了以下内容: > puts({1=>[1,2,3]}.to_yaml) --- 1: - 1 - 2 - 3 => nil 我期待这样的事情:
我在带有 openmp 语句的 C++ 代码中使用 Vim。 而在我的 ~/.vimrc set ai " auto indent 我的问题:当我使用 openmp 语句(以 # 开头)时,光标会跳
我想使用 Megaparsec 解析一种基本的缩进语言。最初我使用的是 Parsec,我设法通过缩进正常工作,但现在我遇到了一些麻烦。 我一直在关注一个教程here这是我必须解析一种忽略缩进的语言的代
我是一名优秀的程序员,十分优秀!