title: Vim auto indents curly brackets wrong
body: <p>I have smart indent and auto indent turned on, but it still acts weird with curly brackets (at least in JavaScript). If i type:</p>
  
  <pre><code>if(x==y){
  </code></pre>
  
  <p>then I get this:</p>
  
  <pre><code>if(x==y){
    }
  </code></pre>
  
  <p>And I have no idea why. I constantly have to backspace once to get the normal:</p>
  
  <pre><code>if(x == y){
    //yay!
  }
  </code></pre>
  
  <p>syntax. Would it at all be possible to have it also put the cursor inside the if block with the cursor at the first <code>/</code> in the comment above?</p>
  
  <p>Here's my current <code>.vimrc</code> file.</p>
  
  <pre><code>"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 &lt; 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"))&gt;0
        echo "Not a number"
        return
      endif
      if l:input&lt;1 || l:input&gt;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("&lt;args&gt;")
  </code></pre>