Codementor Events

Setup vim to work with Python

Published Sep 23, 2018
Setup vim to work with Python

In this blog, we will look into setting up vim to work with Python scripts.

Steps below

$ sudo apt remove -y vim-tiny
> Remove vim-tiny which is the default installation package.

$ sudo apt-get update
> Update package list.

$ sudo apt install -y vim
> Install the full version of Vim.

$ sudo apt-get install vim-gnome
> Install the full version of vim-gnome

Create a file in your home directory named .vimrc that contains the following
and copy below lines:

syntax enable
filetype indent on
set et
set sw=4
set smarttab
map <f2> :w|!python %

When you edit a file with a .py extension, you should now have color syntax highlighting and auto indenting. Pressing the key should run your program, and bring you back to the editor when the program completes.

To learn to use vim, run the following command at a unix command prompt:
$ vimtutor

Discover and read more posts from Abhishake Gupta
get started
post commentsBe the first to share your opinion
Show more replies