DEV Community

Cover image for Use Vim as a Python IDE

Posted on

Use Vim as a Python IDE

Vim is an awesome text editor that can be used as a Python IDE. For those who use Vim and want to program in Python, here are a few tips on how to do it easily.

Vim is a highly extensible text editor. By adding plugins to your .vimrc and installing other packages, you can tailor Vim to your liking.

I've been using Vim as my primary text editor for several years and I really love it. It has an excellent interface for navigating and editing text, and I've never been able to find a better one.

If you are new to vim, I recommend these exercises


A lot of people love Python and they use Vim to write Python code. Instead of the default configuration, you can add plugins to ease Python development with vim.

Auto completion

You can add auto completion with the YouCompleteMe plugin.

YouCompleteMe adds fast, as-you-type, fuzzy-search code completion to Vim.

python auto completion vim

Syntax highlighting

There is a plugin called python-mode. This adds syntax highlighting and many other features to your vim.

  • Support Python and 3.6+
  • Syntax highlighting
  • Virtualenv support
  • Run python code (r)
  • Add/remove breakpoints (b)
  • Improved Python indentation
  • Improved Python folding
  • Run multiple code checkers simultaneously (:PymodeLint)
  • Autofix PEP8 errors (:PymodeLintAuto)
  • Search in python documentation (K)
  • Code refactoring
  • Intellisense code-completion

Syntax checking (lint)

If you like lint, you can use this plugin ale

ALE (Asynchronous Lint Engine) is a plugin providing linting (syntax checking and semantic errors) in Vim 8 while you edit your text files.



Vim supports tabs out of the box. To open files with tabs start vim like this:

Enter fullscreen mode Exit fullscreen mode

Then use the commands :tabn and :tabp to switch between the tabs. To list all your tabs type :tabs.

To close a tab, type :tabclose and use :tabedit file to open a new tab with the file.

tabs in vim

Side bar

Many IDEs have a sidebar with all your project files. Vim can do this too, using the plugin NerdTree.

This puts a file explorer right inside your vim window. Using this plugin, you can visually browse your project directory.


Quick run

There are several ways to do a quick run. For one, you could just execute the Python command !python3

You can use a terminal multiplexer like tmux. A terminal multiplexer lets you use multiple shells in one screen. You can have vim open in one and bash in another.

You can use a window manager like sway or i3wm. The first one is for Wayland and the second one for the older X11.

Another option is the python-mode plugin 🐆

You can run !bash each time you want to enter bash, run your commands and then type exit to go back to vim.

It's also possible to use a vim mode plugin inside vscode. Which doesn't support all of vim, but does provide a vim like feel to vscode.

Top comments (5)

thebouv profile image
Anthony Bouvier

I've been a long time vi/vim user.

When I need to edit files on a server or a container.

But even if you're using Linux as your desktop environment and/or your dev machine -- why?

Again, I want to emphasize that I've used vi/vim for 20+ years now and I like it for when I need it. But I mostly see devs choose vi/vim as some sort of flex.

I live in terminals daily and still don't see a reason I'd ever choose vim as my dev editor of choice. I don't WANT to memorize more commands. I want to edit text, focus my cognitive load on the work at hand, and quite honestly use muscle memory copy and paste, cut, delete, and find that works in every other app I use.

All my personal choice of course and works best for me.

samuelabreu profile image
Samuel Abreu

I changed from vscode (which is great, btw) because after using vim only for quick edits and remotely, I really enjoyed the buffers/windows organizations and think it's great for my workflow.

Now I have a lot of lines on my init.vim and it's my live documentation on shortcuts.

otumianempire profile image
Michael Otu

Only time I use vim is on my phone (termux), when I can't find my cordless mouse or the battery is depleted and it sounds like a potato job to go and buy new pairs or I'm laying down reading and I have to experiment. Mostly for something quick, gedit. Vscode for hallelujah.

But the first time I configured vim for python programming.. it was all ❤️, ⭐ and 🦄.

waylonwalker profile image
Waylon Walker

Ale is a solid plugin that works really well out of the box and covers so many existing linters. I didn't realize for a long time, but it also supports things like go to definition, go to reference.

dmitrykankalovich profile image
Dmitry Kankalovich

I am a simple guy: I see gruvbox color theme - I like the post.