Block Selecting, The Killer Feature of Vim
Without any doubts Vim is one of the best and most efficient text editors, which comes with a lot of features.
The block selecting feature of Vim is one of the many features Vim has to offer that you cannot find in most GUI based text editors as far as I know. You can use Ctrl+v to select a block of text. Using this feature not only you can remove a block of text, but also to add certain text to the selected block. For example, suppose you need to remove "django", "HTTPSS", and "webint" from all 6 lines of the following piece of code and replace them by "django_new".
from django.http import HttpResponseRedirect from HTTPSS.core.mail import send_mail from django.core import serializers from webint.http import Http404 from django.http import HttpResponse
All you have to do is to place the cursor on line 1, column 6, and press Ctrl+v and select your block. By pressing x, you can delete that block from your code. In order to add "django_new" to every single line of that block, again you have to go to line 1, column 6, press Ctrl+v, select that block you want to add your new word to, press "I" and type your new word (in this case "django_new") and finally press Escape to see the magic. If you want to add a new word to the end of a selected block, you can press "A" after selecting the block instead of "I".
To me this is the killer feature of Vim that I haven't seen in other text editors, yet. I just thought someone would probably find this technique useful. Please let me know what other features of Vim you find interesting by commenting on this article.
Published On: Dec. 26, 2010 --- Views: 3285
Tags:
If you found this article helpful, I strongly recommend reading this article:
How to work with tabs in vim
There are 2 comment(s):
On Feb. 27, 2011, ts says:
Good article. And, this feature existed in quite a lot of editors, such as notepad++/ultraedit/visual studio....
My Favorite Bloggers:
Categories:
Related:
- How to work with tabs in vim
- Arch Linux sound problem in Firefox and amarok
- How to create common folders for all users in Linux
- How to fix intel video card freezing problem in Ubuntu 10.04
- Starting Gmote at startup on Linux
- How to test Android apps on your phone on Arch Linux
- Serializing Foreign Key in Django Model
- Top 4 Android Apps for Linux Lovers
- 5 tips and tricks to speed up your bash experience
- Moonlight vs Flash - on Linux Support
- My Thoughts on Ubuntu 10.10
- Using Custom Fonts in CSS
- Google Chrome OS, Useful or Useless?
- How to Make a Quick Django Website For Mobile
On Dec. 26, 2010, asdf says:
Or you could just select the block once with ctrl+v and press 's' to substitute, rather than selecting, deleting, selecting, inserting.