Here is a short practice exercise to help you get some hands-on experience with Neovim:
- Open a new file: Launch Neovim by typing
nvim
in your terminal. Once Neovim is open, create a new file by typing:
rubyCopy code:enew
This will open a new, empty buffer for you to work with.
- Insert some text: Press
i
to enter Insert mode, and start typing some text. Type a few sentences about anything you like. - Save the file: To save the file, press
Esc
to return to Normal mode, and then type:
rubyCopy code:w myfile.txt
This will save the current buffer to a file called myfile.txt
.
- Quit Neovim: To quit Neovim, type:
lessCopy code:q
If you’ve made changes to the buffer and haven’t saved them, Neovim will warn you before quitting. If you want to discard your changes and quit without saving, type :q!
.
- Reload the file: To reload the file you just saved, type:
rubyCopy code:e myfile.txt
This will reopen the file in a new buffer.
- Use a plugin: Neovim has many plugins available that can help you be more productive. One popular plugin is called
nerdtree
, which provides a tree-based file explorer. To install it usingvim-plug
, add the following line to yourinit.vim
file:
pythonCopy codePlug 'preservim/nerdtree'
After saving and re-sourcing your init.vim
file, you can install the plugin by running the :PlugInstall
command from within Neovim.
Once the plugin is installed, you can open the file explorer by typing:
rubyCopy code:NERDTree
This will open a new window showing the file tree. You can use the arrow keys to navigate and Enter
to open a file.
These are just a few examples of what you can do with Neovim. The more you use it, the more you’ll discover how powerful and flexible it can be.