Top 20 Neovim Commands to Get Started with
Neovim is a powerful, extensible, and modern fork of the venerable Vim text editor. Launched in 2014, Neovim aims to improve upon Vim’s foundation by addressing long-standing issues, enhancing extensibility, and fostering a more open development model. For developers and text editing enthusiasts, Neovim offers a compelling blend of Vim’s efficiency with modern features and improved performance.
Why Everybody is Talking about Neovim
- Enhanced Performance: Neovim’s codebase has been refactored and optimized, resulting in faster startup times and smoother operation, especially when working with large files or complex plugins.
- Asynchronous Plugin Architecture: Unlike Vim, Neovim supports asynchronous execution of plugins, preventing UI freezes and enabling more responsive, IDE-like features.
- Built-in Terminal Emulator: Neovim includes a fully functional terminal emulator, allowing seamless integration of command-line tools within the editing environment.
- First-class Lua Support: While maintaining VimScript compatibility, Neovim embraces Lua as a primary scripting language, offering a more powerful and efficient way to extend and configure the editor.
- Modern Codebase: Neovim’s source code is cleaner, more maintainable, and more accessible to contributors, facilitating faster development and innovation.
- LSP Integration: Native support for Language Server Protocol (LSP) provides advanced code intelligence features like auto-completion, go-to-definition, and real-time diagnostics.
- Active Community: Neovim boasts a vibrant, responsive community that actively develops new features, plugins, and improvements.
- Backwards Compatibility: Most Vim plugins and configurations work seamlessly with Neovim, ensuring a smooth transition for Vim users.
Before we continue, let’s talk about something that we all face during development: API Testing with Postman for your Development Team.
Yeah, I’ve heard of it as well, Postman is getting worse year by year, but, you are working as a team and you need some collaboration tools for your development process, right? So you paid Postman Enterprise for…. $49/month.
Now I am telling you: You Don’t Have to:
That’s right, APIDog gives you all the features that comes with Postman paid version, at a fraction of the cost. Migration has been so easily that you only need to click a few buttons, and APIDog will do everything for you.
APIDog has a comprehensive, easy to use GUI that makes you spend no time to get started working (If you have migrated from Postman). It’s elegant, collaborate, easy to use, with Dark Mode too!
Want a Good Alternative to Postman? APIDog is definitely worth a shot. But if you are the Tech Lead of a Dev Team that really want to dump Postman for something Better, and Cheaper, Check out APIDog!
Basic Neovim Navigation Commands
1. h, j, k, l — Move the Cursor
These four keys are the foundation of Neovim navigation:
h
: Move leftj
: Move downk
: Move upl
: Move right
While it may feel awkward at first, mastering these keys will significantly improve your editing speed.
2. w — Move to Next Word
The w
command moves the cursor to the beginning of the next word. This is useful for quickly navigating through text.
3. b — Move to Previous Word
Similarly, the b
command moves the cursor to the beginning of the previous word.
4. 0 — Move to Start of Line
Pressing 0
instantly moves the cursor to the beginning of the current line.
5. $ — Move to End of Line
The $
command moves the cursor to the end of the current line.
Editing Commands
6. i — Enter Insert Mode
Pressing i
enters Insert mode, allowing you to type and edit text normally.
7. a — Append
The a
command enters Insert mode after the cursor, useful for adding text at the end of a word or line.
8. o — Open New Line Below
Pressing o
creates a new line below the current line and enters Insert mode.
9. O — Open New Line Above
Similar to o
, but O
creates a new line above the current line.
10. dd — Delete Line
The dd
command deletes the entire current line.
Advanced Navigation
11. gg — Go to Top of File
Typing gg
instantly moves the cursor to the first line of the file.
12. G — Go to Bottom of File
The G
command moves the cursor to the last line of the file.
13. :{number} — Go to Specific Line
To jump to a specific line number, type :
followed by the line number and press Enter.
Search and Replace
14. / — Search Forward
Typing /
followed by a search term and pressing Enter searches forward in the file for that term.
15. ? — Search Backward
Similar to /
, but ?
searches backward in the file.
16. n — Next Search Result
After performing a search, pressing n
jumps to the next occurrence of the search term.
17. N — Previous Search Result
Pressing N
jumps to the previous occurrence of the search term.
File Operations
18. :w — Save File
To save your changes, type :w
and press Enter.
19. :q — Quit Neovim
To exit Neovim, use the :q
command. If you have unsaved changes, it will warn you.
20. :wq — Save and Quit
Combine saving and quitting with the :wq
command.
And… Even More Neovim Commands You Can Learn!
These 20 commands form the foundation of efficient Neovim usage. As you become more comfortable with them, you’ll find your editing speed and productivity increasing dramatically. Let’s dive deeper into how to use these commands effectively and some additional tips to enhance your Neovim experience.
Combining Commands in Neovim
One of the powerful aspects of Neovim is the ability to combine commands. For example:
3j
: Move down 3 lines5dd
: Delete 5 lines2w
: Move forward 2 words
By combining numbers with commands, you can perform actions more efficiently.
Visual Mode in Neovim
While not included in our top 20, Visual mode is worth mentioning. Press v
to enter Visual mode, which allows you to select text visually. This is particularly useful when combined with commands like d
for delete or y
for yank (copy).
Undo and Redo
Mistakes happen, and Neovim has you covered:
u
: Undo the last changeCtrl + r
: Redo the last undone change
These commands are essential for experimenting and correcting errors.
How to CustomizeNeovim
As you grow more comfortable with Neovim, you may want to customize it to fit your workflow. This is done through the init.vim
file (or init.lua
for Lua configurations). Here, you can set options, map keys, and add plugins to extend Neovim's functionality.
Neovim Plugin Ecosystem
Neovim has a rich plugin ecosystem that can enhance your editing experience. Some popular plugins include:
- Telescope: Fuzzy finder for files, buffers, and more
- LSP (Language Server Protocol): Provides IDE-like features
- Treesitter: Improved syntax highlighting and code navigation
While plugins are powerful, it’s recommended to master the basics before diving into extensive customization.
Some More Neovim Tips
To become proficient with Neovim, regular practice is key. Here are some tips to improve:
- Use Neovim for all your text editing tasks, even simple ones.
- Try to avoid using the arrow keys and mouse, forcing yourself to use Neovim commands.
- Learn one new command or feature each week and incorporate it into your workflow.
- Use Neovim’s built-in tutor by typing
vimtutor
in your terminal.
Advanced Features to Explore with Neovim
As you become more comfortable with the basics, consider exploring these advanced features:
Macros
Macros allow you to record a series of commands and play them back. This is incredibly useful for repetitive tasks.
q{letter}
: Start recording a macro (e.g.,qa
to record macro 'a')q
: Stop recording@{letter}
: Play back the recorded macro
Marks
Marks allow you to set bookmarks in your file for quick navigation.
m{letter}
: Set a mark (e.g.,ma
sets mark 'a')'{letter}
: Jump to the line of the mark`{letter}
: Jump to the exact position of the mark
Text Objects
Text objects allow you to operate on logical chunks of text.
iw
: Inside wordaw
: Around wordis
: Inside sentenceip
: Inside paragraph
These can be combined with commands like d
(delete) or c
(change). For example, diw
deletes the word under the cursor.
Neovim vs. Vim
While Neovim shares many commands with Vim, it offers several advantages:
- Better default settings
- Asynchronous plugin support
- Built-in terminal emulator
- Lua integration for configuration and plugins
These features make Neovim a more modern and extensible editor while maintaining compatibility with most Vim plugins and configurations.
Conclusion
Mastering Neovim is a journey that requires patience and practice. Starting with these top 20 commands will give you a solid foundation to build upon. As you become more comfortable, you’ll discover the power and flexibility that Neovim offers.Remember that the goal is not to memorize every command, but to develop muscle memory for the most common operations. This will allow you to edit text as fast as you can think, ultimately boosting your productivity as a developer.Embrace the learning curve, and soon you’ll find yourself navigating and editing text with unprecedented speed and precision. Neovim’s extensive customization options mean that as your skills grow, your editor can evolve with you, adapting to your unique workflow and preferences.Whether you’re a seasoned developer looking to optimize your toolset or a newcomer to text editing, Neovim offers a powerful, extensible platform that can significantly enhance your coding experience. Start with these basic commands, practice regularly, and watch as your efficiency and enjoyment of text editing reach new heights.