DVG
DVG

Reputation: 17480

Vim :'<,'> When entering command mode

Sometimes in vim I appear to be entering a keymap unintentionally when attempting to enter command mode. For instance, when attempting to write :w I, sometimes, end up with this:

:'<,'>w

Which throws the error E481: No Range Allowed

It's mostly just a minor annoyance, and I'm more wanting to know what am I doing to initiate the command line in this way with the brackets.

Upvotes: 0

Views: 1849

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172698

Adding to Vincent's correct answer, if you happen to come upon a command that doesn't support a range and gives you the E481 error (though the given :write does support ranges), you can just remove the '<,'> prefilled content by pressing Ctrl + U, and then start typing the command. This is quicker than Esc and re-triggering command-line mode via :.

Upvotes: 4

Vincent
Vincent

Reputation: 430

:'<,'>w appears when you start a command line while being in visual mode. It allows to apply this command on a portion of your document, e.g. to sort some lines. In your case, you have accidentally hit v before entering your command.

Upvotes: 4

Related Questions