Vim “调辛登”;开关";压痕
Nemerle是一种类似C的语言,大多数情况下都能很好地与Vim “调辛登”;开关";压痕,vim,nemerle,Vim,Nemerle,Nemerle是一种类似C的语言,大多数情况下都能很好地与cindent配合使用。但是,其类似于开关的结构称为匹配: match (x) // switch (x) { // { | "Hello World" => ... // case "Hello World": ... | _ => ... // default: ... }
cindent
配合使用。但是,其类似于开关的结构称为匹配:
match (x) // switch (x)
{ // {
| "Hello World" => ... // case "Hello World": ...
| _ => ... // default: ...
} // }
是否可以将cinoptions
forswitch
语句应用于此构造?也许我可以在某个地方设置一个正则表达式。如果没有,我可以用另一种方式使垂直杆与支架对齐吗
更新 以下是我的想法:
" Vim indent file
" Language: Nemerle
" Maintainer: Alexey Badalov
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
" Nemerle is C-like, but without switch statements or labels.
setlocal cindent cinoptions=L0
" Enable '|', disable ':'.
setlocal indentkeys=0{,0},0),0#,0\|,!^F,o,O,e
setlocal indentexpr=GetNemerleIndent()
let b:undo_indent = "setl cin< cino< indentkeys< indentexpr<"
function! GetNemerleIndent()
" Nemerle is C-like; use built-in C indentation as a basis.
let indent = cindent(v:lnum)
" Set alignment for lines starting with '|' in line with the opening
" brace. Use default indentation outside of blocks.
if getline(v:lnum) =~ '^\s*|'
call cursor(v:lnum, 1)
silent! normal [{
if line('.') == v:lnum
return indent
endif
return indent(line('.'))
endif
return indent
endfunction
Vim缩进文件
“语言:Nemerle
“维护者:阿列克谢·巴达洛夫
“仅在未加载其他缩进文件时加载此缩进文件。
如果存在(“b:是否缩进”)
完成
恩迪夫
设b:did_indent=1
Nemerle类似于C,但没有开关语句或标签。
setlocal cindent cinoptions=L0
启用“|”,禁用“:”。
SetLocalIndentKeys=0{,0},0),0#,0\|^F、 o,o,e
setlocal indentexpr=GetNemerleIndent()
让b:undo_indent=“setl cin
:h indent expression
在Vim文档中站稳脚跟。基本上,我认为您需要为您的文件类型编写自己的“indent file”,它将返回一个indentexpr,其中包含适合匹配结构的空格,否则(假设这是唯一的变化)返回通常的cindent()值。它涉及的不仅仅是设置正则表达式,缩进文件将有Vim命令和结构来计算行并返回正确的值。正如文档所述,了解它们如何工作的最好方法是查看其他语言的一些缩进文件。(C没有缩进文件供您查看,因为它都集成到Vim自己的C源代码中,但大多数其他语言都有使用Vimscript的缩进文件。)