Boost Your Coding Speed with Three Essential Vim Plugins
Learn how the Auto Pairs, NERD Commenter, and Vim Surround plugins can automatically complete brackets, comment code blocks, and manipulate surrounding symbols to make Vim a powerful, lightweight development environment.
Vim is a widely used text editor on Linux, often considered an "ancient artifact" because of its steep learning curve, yet many experts prefer it for its speed and lightweight nature compared to heavyweight IDEs.
This guide introduces three highly practical Vim plugins that can dramatically improve coding efficiency.
1. Auto Pairs – Automatic Bracket Completion
The Auto Pairs plugin automatically inserts matching symbols such as curly braces, square brackets, parentheses, and quotes. When you type an opening symbol, the corresponding closing symbol appears instantly, and deleting the opening symbol also removes the closing one. With auto‑indent enabled, the cursor is placed correctly inside the pair.
package main
import "fmt"
func main() {
x := true
items := []string{"tv", "pc", "tablet"}
if x {
for _, i := range items {
// cursor lands here after typing '{' and pressing Enter
}
}
}These basic features already save a lot of time; additional options are available on the plugin’s GitHub repository.
2. NERD Commenter – Easy Code Block Commenting
NERD Commenterdetects the file type and applies the appropriate comment syntax. In normal mode you can press <Leader> + Space (default leader is \) to comment or uncomment selected lines in visual mode. The plugin also offers a “Sexy Comment” mode, triggered by <Leader>+cs, which formats comments in a more elegant style.
/*
* x := true
* items := []string{"tv", "pc", "tablet"}
* if x {
* for _, i := range items {
* fmt.Println(i)
* }
* }
*/3. Vim Surround – Manipulating Surrounding Characters
The Vim Surround plugin lets you add, change, or delete surrounding delimiters quickly. Examples:
Delete surrounding double quotes: ds" Change double quotes to single quotes: cs"' Wrap a word with HTML tags: place the cursor on the word and type ysiw<em> Wrap a whole line with a <div> block: ySS<div class="normal"> The plugin also works well with HTML/XML, allowing you to add tags around selected text effortlessly.
Conclusion
Mastering these three Vim plugins—Auto Pairs, NERD Commenter, and Vim Surround—can significantly speed up coding, reduce repetitive keystrokes, and make Vim a more comfortable primary development tool. The Vim community offers many more powerful extensions for further customization.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
