Javascript indentation in VIM

前端 未结 7 1045
遇见更好的自我
遇见更好的自我 2021-02-02 15:46

I\'m trying to get VIM to indent Javascript with the \'=\' and related commands. When I try to auto indent the following, for example:

   new function($) {
              


        
7条回答
  •  春和景丽
    2021-02-02 16:24

    I hate to say something unhelpful like "It works for me", but it does. Even with nothing in my .vimrc and all plugins off, I get the correct indentation.

    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();
            }
    

    Have you tried loading vim with the --noplugins switch and temporarily moving/renaming your .vimrc to see if it still doesn't work? I suspect another setting in your .vimrc or another plugin may be causing the conflict.

提交回复
热议问题