gpt4 book ai didi

javascript - Vim 自动缩进大括号错误

转载 作者:行者123 更新时间:2023-11-30 06:42:38 25 4
gpt4 key购买 nike

我打开了智能缩进和自动缩进,但它在大括号中的表现仍然很奇怪(至少在 JavaScript 中是这样)。如果我输入:

if(x==y){

然后我明白了:

if(x==y){
}

我不知道为什么。我经常需要退格一次才能恢复正常:

if(x == y){
//yay!
}

语法。是否有可能将光标也放在 if block 内,光标位于上面注释中的第一个 / 处?

这是我当前的 .vimrc 文件。

"Color syntaxing of course
syntax on

"colorscheme molokai

:colors molokai

"Lots of undo history... just in case
set history=700

"Set to auto read when a file is changed from the outside
set autoread

"highlight the current line
set cul

"set color of the highlighted line
hi CursorLine term=none cterm=none ctermbg=234

"auto indent
set autoindent
set smartindent

"Soft tabs FTW
set expandtab
set smarttab

"Size of the (soft) tabs
set shiftwidth=2
set softtabstop=2

"Show line numbers
set number

"Set line number colors to something other than that god awful orange
hi LineNr ctermfg=234 ctermbg=black


"Change the color of the matching brackets
highlight MatchParen cterm=bold ctermfg=black ctermbg=DarkYellow

"Keep at least 5 lines of space above and below and then left and right
set scrolloff=5
set sidescrolloff=5

hi StatusLine cterm=NONE ctermbg=darkgreen ctermfg=white

"Scrolling with your mouse!
set ttymouse=xterm2
set mouse=a

let g:molokai_original = 1

" Find file in current directory and edit it.
function! Find(name)
let l:list=system("find . -name '".a:name."' | perl -ne 'print \"$.\\t$_\"'")
let l:num=strlen(substitute(l:list, "[^\n]", "", "g"))
if l:num < 1
echo "'".a:name."' not found"
return
endif
if l:num != 1
echo l:list
let l:input=input("Which ? (CR=nothing)\n")
if strlen(l:input)==0
return
endif
if strlen(substitute(l:input, "[0-9]", "", "g"))>0
echo "Not a number"
return
endif
if l:input<1 || l:input>l:num
echo "Out of range"
return
endif
let l:line=matchstr("\n".l:list, "\n".l:input."\t[^\n]*")
else
let l:line=l:list
endif
let l:line=substitute(l:line, "^[^\t]*\t./", "", "")
execute ":e ".l:line
endfunction
command! -nargs=1 Find :call Find("<args>")

最佳答案

我推荐使用 vim javascript 缩进插件 JavaScript Indent ,这在编程 javascript 时给了我非常满意的结果。

关于javascript - Vim 自动缩进大括号错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9714662/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com