Question

I'm editing a file, part of which looks like:

The quick brown fox jumped over the lazy dog.
    ^

With the cursor under the "q". In normal mode, I want to type ">" to obtain

The quick brown fox jumped over the lazy dog.
                                            ^

That is, I want the cursor to jump to the end of the line. If I add the line

nmap > $

To my .vimrc file, the effect of typing ">" becomes

The quick brown fox jumped over the lazy dog.

^

That is, ">" now sends the cursor to the beginning of the line after the line I'm on. In command mode, if I type

:nmap > $

The behavior is as desired; that is, from "q" the cursor jumps to the following:

The quick brown fox jumped over the lazy dog.
                                            ^

Not sure how much it matters, but I'm using MacVim with the latex-suite package running, using Mac OS X version 10.8.4.

Was it helpful?

Solution

You most likely have trailing white space in your map command. You can check this by doing
:set list. Set list will shows the end of the line with a faded $. If there is trailing whitespace remove it.

Mappings takes the trailing whitespace and its the same as if you had hit the spacebar in normal mode. Which moves the cursor over by one and since it is at the end of the line the cursor is at the beginning of the next one.

Side Note: You should be using nnoremap so the mapping to immune to recursion and remapping.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top