Vim as an Integrated Development Environment (IDE) for Python3? - Part II of II
In Part I, we used Homebrew to install a version of vim for macOS with Python 3 support. Today we will finish setting up vim. This post is for new users, and a refresher for veterans who haven’t touched their configuration in a while.
My .vimrc (vim’s “run commands” file) is like a Mary Shelley novel come to life. I took bits and bytes from all over the internet and experimented, adding and removing features and plugins to boost productivity. My whole .vimrc would make a poor example today, as it would take a very long time to explain or read.
Below is part of my .vimrc to help you get started. To learn more about any setting, type :h <setting> inside vim to open its help page. The highlights are formatting features that will keep you productive while working in vim.
syntax on
set nu
set relativenumber
set shiftwidth=4
set smartindent
set tabstop=4 softtabstop=4
set cursorline
"Plugins
call plug#begin('~/.vim/plugged')
Plug 'sheerun/vim-polyglot'
Plug 'jiangmiao/auto-pairs'
call plug#end()
"Key remapping
nnoremap <C-t> :terminal<CR>
"Cursorline settings
hi Search ctermbg=LightGray ctermfg=Black
hi CursorLine ctermfg=DarkGray
hi CursorLineNr ctermfg=Black
hi LineNr ctermbg=Black ctermfg=Gray
hi QuickFixLine ctermbg=Yellow ctermfg=Black
Out of the Box Items
Vim has built-in features that need no plugins. It was hard to pick three of them, and to trim my configuration from 102 lines down to about 25.
Line numbers, the terminal and indentation keep you focused on your work. Let’s get you on your way to an IDE!
The Numbers
Line numbers are built into vim, but you have to turn them on. As you get comfortable navigating vim, line numbers help a lot. In NORMAL mode, you can use them to jump around quickly. For example, say you are on the last line of the .vimrc above and want to move up three lines to change a highlight color. Press ESC to leave INSERT mode, then type 3k to jump up three lines. Relative numbers make this easy, because they show exactly how far away each line is.
set nu turns on line numbers, and set relativenumber shows how many lines away each line is from your cursor.
Map Those Keys!!!
Key mapping is essential for working with vim. Typing out a full command every time wastes your cycles. Claim those cycles back with key mappings that make sense to you. Other people’s mappings won’t always make sense to you, and that’s fine, because you can map key combinations however you like.
One important mapping here is nnoremap <C-t> :terminal<CR>. In NORMAL mode, pressing CTRL+t opens a terminal inside vim at your current location. Testing a new script then takes a couple of keystrokes instead of a dozen. Pop into the terminal, test, and exit to get right back to your code.
Keep the Code Clean With Indenting
You don’t need to hammer the spacebar or the tab key to get clean, indented code blocks that show your program’s structure.
Customize vim and let it do the work for you. Whether you’re writing a small script or a fully object-oriented program, clean code helps you and everyone who reads it. With set smartindent, a new line lines up with the indentation of the line above when you press Return.
set shiftwidth sets how many columns one level of indentation uses. For example, when you start an if statement in a Python file and press Return after the colon, vim indents the next line for you. Our .vimrc sets it to FOUR, which matches the Python convention. These seem like little things, but they add up.
These features are very useful. Explore the options that come with vim; you’ll be surprised how much you can do out of the box. There are plenty of resources, including the :h help pages, vim.org, and the many “dotfiles” that people share online.
Let Us Have a Word About Plugins
We don’t need plugins to venture into the universe with vim and Python 3. Plugins get hard to manage if you install twenty of them and try to use them all at once. Believe me, I have been there! Confusion sets in, then frustration, then you blow out your .vimrc and start all over. That time could have gone into developing the next big tech idea!
If you haven’t been to VimAwesome, it’s one of my favorite places to discover vim plugins. Its interface is easy to navigate, and once you’ve chosen a plugin manager, it shows the exact line to add to your .vimrc for each plugin. It’s up to you to vet any plugin before you install it: check when it was last updated, read reviews, and confirm what it needs to work.
Plug This
For a plugin manager, I use junegunn/vim-plug. It’s simple to use, and it was still maintained at the time of writing.
Here are a few basics to get you going with plugins, so you don’t have to read the whole README first.
- Add your plugins between
call plug#begin()andcall plug#end(). - The path inside
plug#begin()keeps your plugins in one tidy folder. - Each plugin uses the syntax
Plug '<user>/<repository>'.
If you choose vim-plug as your manager:
:PlugInstallinstalls new plugins.:PlugUpdateupdates them.:PlugCleanremoves plugins that are no longer in your.vimrc. I use it often: if a new plugin interferes with my workflow, I comment out its line, save, source the file and run:PlugClean. A bit overboard, but I like to make sure it’s really gone.
See whether the two plugins in our .vimrc are right for you.
jiangmiao/auto-pairs is great for pairs like ( ), [ ], { } and quotes. When you type the opening character, it adds the closing one after your cursor so you don’t forget it.
sheerun/vim-polyglot adds syntax highlighting for almost any mainstream language. Of course, you can write your own syntax highlighting. Good luck! I have a few custom highlights in my .vimrc that help me spot lines when inspecting logs, but nothing as long and complex as a full language definition.
Closing Bytes and Bits
These two posts only scratch the surface of what you need to be successful developing Python 3 in vim. Using vim is a lot of muscle memory. Many people shy away from the editor because they think it’s complex, but it’s only as complex as you make it. Remember, piling on changes and plugins will only push you away from using vim as your IDE.
Add features when you need them and take them for a test drive. Imagine all the time you’ll save by being productive. That time can go into learning something new or further improving your workflow. Coach others on what you learn and keep moving toward success!
Written with vim 8.2 and vim-plug.
Edited in October 2026 for grammar and accuracy. Added set cursorline, which the CursorLine colors need, and fixed the QuickFixLine spelling.