DEV Community

dwarfŧ
dwarfŧ

Posted on

neovim: the basics

Image description

introduction
welcome to neovim! It is a super-set of vim and makes a handy editor for any project. I use neovim because of the fact my operating system is linux. This means most of the code i run is in a terminal and neovim is perfect for that!

entering
first of all we need to enter the editor. We can enter vim with: vim and neovim: nvim. you will be greeted with this lovely text editor:

Image description

insert mode
once you have entered the editor typing will not do anything. You can type by pressing the key i. To leave insert mode (so you can run commands) press esc.

exiting
then once we've typed code we need to exit the editor. We can do this by doing: :q however this will only work if you have not typed anything. To leave neovim without saving do: :q!. To save and exit vim you can do: :wq and you can save it without exiting by doing: :w

running code directly inside of vim
here i have some code written in neovim:

Image description

and i can run it without leaving neovim. What allows me to do this is the fact by doing :! you can run bash code inside neovim. this means to run my c++ code i can just do: :! g++ main.cpp and run it with: :! ./a.out You can do this with any programming language as long as you have it installed on your computer.

goodbye
enjoy your knowledge and have a good day

Top comments (0)