Comments on How to use markers and perform text selection in Vim

When using GUI-based text/source code editors, some features are a given, such as selecting text. I mean, most of us won't even consider this a feature anymore. But that's not the case with command line based editors like Vim. Specifically for Vim, when only using keyboard, you'll have to learn certain commands in order to select text the way you want. In this tutorial we will discuss this feature as well as the 'marks' feature of Vim in detail.

5 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: Gian Domenico Bonazzoli

Well done !

There is only a little error on "Now just press 'dd' and the selected paragraph...". On the selected text it has to be invoked the 'd' command and not 'dd'!  Otherwise, you will delete also the line on which the cursor will jump alfter the deletion of text and not only the selected block.

By: himanshu

Thanks for your comment Gian. I checked, and observed that both 'dd' and 'd' are having the same impact.

By: TW

Gian is correct. You only need a single 'd'. If you use 'dd', the first 'd' deletes the selected text and the second 'd' starts another delete command. At that point it is waiting for a motion to complete the command. So if your next keystroke was 'j' for instance, then it would delete down to the next line. By using 'dd' instead of 'd' you are going to end up deleting more than you expected to in most cases.

By: David Heremans

Nice article, but your opening is rather flawed. If I want to delete 15 lines I simply use the repeater functionality of vim. You don start typing 'dd','dd','dd','dd',... etc until you reach your fiftheen lines. You would simple type '15dd'. for 8 lines you type '8dd' for one hundred lines you type '100dd'. Maybe you only want to delete the following 10 words, then you type '10dw' etc etc

So please adjust your articles opening mentioning this usefull repeater-stuff but say that for the sake of this article you will be presenting a different way.

 

By: Herman Jaramillo

So. How to do you select between marks?

For xample I have a mark 'a  and another 'b. How do I select all lines between 'a and 'b?

Thanks.