5 Tasks You Didn't Know You Could do With Vim
Published | Last Update
Vim is the best text editor, as you know. Most Vim users are aware of the basic hotkeys, commands, and other Vim tricks; however, there are a number of useful tricks that are lesser-known.
6,197 views, 0 RAMs, and 0 comments
Vim is the best text editor, as you know. While there aretricks that you can do with more basic text editors like Gedit, Vim allows for more complex and efficient text editing. Most Vim users are aware ofthe basic hotkeys, commands, and other Vim tricks; however, there are a number of useful tricks that are lesser-known.
Vim has Built-in Word Completion
While you might think that a plugin is needed for word completion in Vim, there is in fact built-in word completion, which will suggest words based on the contents of your file. Here’s an easy demonstration:
- Put some content into a file
- Start typing a word that matches an existing word
- Press Ctrl+N
- That’s it.
See this screenshot for what this looks like:
Very nice. There are alsoa number of other auto-completion tricks worth learning about.
Paste from External Clipboard
When working with Vim, an internal clipboard is used for copying, cutting, and pasting. For example:
- The command “dd” will cut the current line (“yy” will copy it)
- The command “p” will paste that line
However, often you may need to paste content from an external source. To do this, use the key combination:
When doing this, make sure that you are in insert mode. Otherwise, it will interpret the contents of the copy-paste as if you were manually inputting those keys in that order.
Bonus:When using most rich text editors, like Google Drive, as well as other tools that support rich text likeGoogle Sheets, Ctrl+Shift+V will paste without formatting.
There are several ways to enter visual mode in Vim:
- Pressing “v” will enter the standard visual mode
- Pressing “V” will enter visual mode, highlighting full lines rather than individual characters
- Pressing “ctrl+v” will enter visual mode with support for vertical highlighting
This can be seen in the screenshot below:
Using this vertical highlighting, it is possible to do things like:
- Use “u” or “U” to adjust the case of the first letter in a line
- Use “I” once multiple lines are highlighted to enter insert mode, type something, then press ESC and that text will be entered on all highlighted lines.
- Bulk deletions to lines.
Note that using “$” to highlight to the end of all lines when in visual mode vertically, since lines may be of different lengths.
Showing Line Numbers in Vim
By default, Vim does not show line numbers. There are a few common ways to determine line number without them being shown on the left-hand side, such as:
- Using commands like 30gg to jump to particular lines; and
- Looking at the bottom-right corner to view the current column and number.
However, it is in fact possible to show line numbers in Vim. To do this, enter the following command:
- :set number
To remove line numbers, use this command:
- :set nonumber
How to Autoindent in Vim
Similarly to showing line numbers, this is an easy-to-use feature that many are unaware of. To enable, use the command:
- :set autoindent
And to disable, use this command:
- :set noautoindent
- [Video] 28+ Methods to Make Money Online: The Ultimate Tier List from S-Tier through F-Tier
- Scriptable Headless Browsers 101: PhantomJS vs. Headless Chrome/Chromium vs. Headless Firefox
- [Video] How to do Competitor Analysis for Internet Marketing
- [Video] The Ultimate Offpage SEO Tier List: 28+ Link Building Methods Ranked from S through F (and a Few Other...
- 5 Tasks You Didn't Know You Could do With Vim
- [Infographic] The Beginner's Vim Cheat Sheet
- [BST - FH] 256 Kilobytes Web Development Sales Thread
- A Review and Overview of the Charles Web Debugging Proxy Application
- The Complete Guide to Discord Text Formatting, Syntax Highlighting, and Tricks for Adding Colors
- SquirrelMail vs. RoundCube vs. Horde: Why does every web hosting company come with these three email clients?
August Garcia is some guy who used to sell Viagra on the Internet. He made this website to LARP as a sysadmin while posting about garbage like user-agent spoofing, spintax, the only good keyboard, virtual assitants from Pakistan, links with the rel="nofollow" attribute, proxies, sin, the developer console, literally every link building method, and other junk.
Post a New Comment
Do you like having a good time?
Register an Account
Read Quality Articles
Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.
Argue with People on the Internet
Use your account to explain why people are wrong on the Internet forum.
Vandalize the Wiki
Or don't. I'm not your dad.
Ask and/or Answer Questions
If someone asks a terrible question, post a LMGTFY link.
Make Some Money
Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.