Normally, when I use the up/down arrow keys to move between lines in insert mode (I'm using Vim wrong, I know), Vim remembers which column my cursor is in, so if I move to a line shorter than where my cursor is, then back to a longer line, the cursor pops right back to the same column. This is what I want and expect to happen, as well as what happens most of the time.
However, when I'm editing a Java sourcecode file and the last character in the shorter line is an opening or closing curly brace, square bracket, or parenthesis, Vim seems to forget entirely that the cursor was ever in any column other than the one immediately after the brace. The result is the I often find my cursor near the beginning of a line of code when I want and expect it to be at the end, so I have to $a to get back. Since this is Java, I have a lot of short lines ending with curly braces- so this is really annoying.
The weird part is that this only happens in insert mode- in normal mode, the arrows as well as j and k work fine. It's also weird that it only happens with those six grouping symbols- blank lines, lines with only whitespace, typical comments, and lines ending with semicolons cause no trouble in either mode.
It's not a bug in the Java plugin that I'm using- the exact same behavior happens in a .txt file.
I tried typing :au CursorHold
, as instructed by one or two other answers to related questions, but it only prints --- Auto-Commands ---
in purple text, and nothing to direct me to a bugged script.
Related: I recently upgraded my Apple-installed version of Vim 7.3 to Homebrew-installed Vim 7.4, which did not have this problem. I'm also on a Mac (and no, I'm not using GVim or MacVim).
Edit: I derped in writing the last paragraph above. Apple's Vim 7.3 install did not have this issue; Homebrew's Vim 7.4 did. Not that it matters now...
:au CursorHoldI
or:au CursorMovedI
( both ending with uppercase i )?vim -u NONE
. I would recommend you disable your plugins and vimrc customization until you find the culprit. protip: use a binary search to make it quicker.