Vim is a powerful text editor that can be extended with plugins to provide IDE-like features. However, it is also possible to use Vim as an IDE without installing any plugins, by making use of the editor’s built-in features and commands.
One of the key features of an IDE is the ability to navigate and manage your files and directories. In Vim, you can use the :Explore command to open a file tree in a new window, or the :Vexplore command to open it in a vertical split. These commands allow you to browse the file system and open files without leaving Vim.
Alternatively, you can install a file tree plugin such as nerdtree or vim-dirvish to provide this functionality. To use one of these plugins, you will need to install it and then add the appropriate commands to your .vimrc file to enable it.
Vim also provides built-in support for code completion and code navigation. The OmniCompletion feature provides context-aware code completion based on the syntax of the file you are editing. To enable OmniCompletion, you will need to add the following line to your .vimrc file:
set omnifunc=syntaxcomplete#Complete
By default, OmniCompletion will only suggest completions based on the words in the current buffer. However, you can configure it to use additional sources of completion suggestions, such as tags files or language-specific completion engines.
To do this, you will need to specify the omnifunc option for the filetype you are working with. For example, to use the OmniCompletion function provided by the python syntax file, you can add the following line to your .vimrc file:
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
This will enable Python-specific completion suggestions when editing Python files in Vim.
Once OmniCompletion is enabled, you can trigger it in insert mode by pressing <C-x> followed by <C-o>. This will display a list of completion suggestions based on the context of the word under the cursor.
You can also use the OmniCursorMotion feature to provide context-aware cursor motion based on the syntax of the file you are editing. To enable OmniCursorMotion, you will need to add the same line to your .vimrc file as for OmniCompletion. Once OmniCursorMotion is enabled, you can use the g] command to display a list of symbols in the current file, and then use the CTRL-] command to jump to the definition of the symbol under the cursor.
If you need to use Git with Vim, you can use the :! command to run Git commands from within the editor. For example, you can use :!git status to view the status of your repository, or :read !git log to insert the output of the git log command into your buffer.
Overall, while Vim does not provide all of the features of a modern IDE out of the box, it does offer a number of built-in tools and commands that can be used to enable code completion, code navigation, and Git integration without installing any plugins. With a little configuration and customization, Vim can be a powerful and efficient IDE for a wide range of programming tasks.
For more productivity tips and general Vim usage guides I recommend you read my book An IDE Called Vim. It’s a detailed guide on how to use Vim as an IDE, that goes into what tools you can use, but also all the basics of Vim usage.
Available on Leanpub and Amazon.
And if you really want to master Vim language, than make sure to check out my latest book Talk Vi(m).
Available on Leanpub.