我试图让 VIM 使用 '=' 和相关命令缩进 Javascript。例如,当我尝试自动缩进以下内容时:
new function($) {
$.fn.setCursorPosition = function(pos) {
if ($(this).setSelectionRange) {
$(this).setSelectionRange(pos, pos);
} else if ($(this).createTextRange) {
var range = $(this).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
结果是相当荒谬的:
new function($) {
$.fn.setCursorPosition = function(pos) {
if ($(this).setSelectionRange) {
$(this).setSelectionRange(pos, pos);
} else if ($(this).createTextRange) {
var range = $(this).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
我已设置set syntax=javascript
,并且已设置filetype
为:
filetype detection:ON plugin:ON indent:ON
虽然我已经尝试了这个的每一个排列。我已经尝试了, 和的所有排列smartindent
,但似乎没有什么能产生正确的效果来给 Vim 预期的缩进。我已经设置了。autoindent
cindent
tabstop=4
我已经安装了javascript.vim
, 和IndentAnything
,尽管它们似乎没有任何效果。
对于如何让 Vim 在 JavaScript 中正确缩进的任何建议,我将不胜感激。