• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to Set Up VIM Editor for Python Programming

2373

How to Set Up VIM Editor for Python Programming

VIM is a customizable programmable text editor. You can do anything you want with VIM if you know how VIM works and how to write VIM plugins. It is so simple to set up VIM Editor for Python Programming and this tutorial covers the ground on the same process. 


Installing VIM 

First, update the package repository cache with the following command.

root@linuxhelp:~# apt-get update
Ign:1 cdrom://Ubuntu 17.04 _Zesty Zapus_ - Release amd64 (20170412) zesty InRelease
Hit:2 cdrom://Ubuntu 17.04 _Zesty Zapus_ - Release amd64 (20170412) zesty Release
Hit:4 http://old-releases.ubuntu.com/ubuntu zesty InRelease
Hit:5 http://archive.canonical.com/ubuntu zesty InRelease                      
Hit:6 http://old-releases.ubuntu.com/ubuntu zesty-updates InRelease            
Hit:7 http://old-releases.ubuntu.com/ubuntu zesty-security InRelease     
Hit:8 http://ppa.launchpad.net/pmjdebruijn/darktable-release/ubuntu zesty InRelease
Reading package lists... Done

 

And then the VIM should be installed by making use of the following command.

root@linuxhelp:/var/lib/dpkg# apt install vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You can now run VIM with the following command:
.
.
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode

 

 

Once it is done, you need to configure VIM for Python. Make use of the following command to open the file. 

root@linuxhelp:~# vim ~/.vimrc

 

In that file you need to type the following lines.

syntax enable
set tabstop=4
set shiftwidth=4
set expandtab
set number
filetype indent on
set autoindent

Save and exit it, once you are done. 

 

You can see how it looks by making use of the following command.

root@linuxhelp:~# vim ~/.vimrc

1 syntax enable
  2 set tabstop=4
  3 set shiftwidth=4
  4 set expandtab
  5 set number
  6 filetype indent on
  7 set autoindent
~                                         
: wq


Now we install python-syntax (https://github.com/hdima/python-syntax), a syntax highlighting module on VIM for better python syntax highlighting of Python2 and Python3.   The python-syntax module must be kept on a specific directory ‘ ~/.vim/syntax’ for it to work. Do as follows. 

root@linuxhelp:~# mkdir -p ~/.vim/syntax
root@linuxhelp:~# cd ~/.vim/syntax

 

Now download Python-syntax module with ‘ wget’ command like given in the following manner.

root@linuxhelp:~#  wget https://raw.githubusercontent.com/hdima/python-syntax/master/syntax/python.vim

 

 

Now again open the configuration file that you edited previously.

root@linuxhelp:~/.vim/syntax# vim ~/.vimrc 


And add the 9th line to enable python-syntax module.

1 syntax enable
  2 set tabstop=4
  3 set shiftwidth=4
  4 set expandtab
  5 set number
  6 filetype indent on
  7 set autoindent
  8
  9 let python-highlight_all = 1

~                

Now save the file.

 

This is how you configure VIM for Python. 

Tags:
gabriel
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

Is VIM can be customized?

A

Yes, VIM is a customizable programmable text editor.

Q

where to download Python-syntax module?

A

use the link to get downloads the source of this "https://raw.githubusercontent.com/hdima/python-syntax/master/syntax/".

Q

How to do the undo functionality in vim editor in Linux?

A

You can click "Esc" at that point squeeze "u" to give the contribution of fix usefulness (undo) in vim supervisor on Linux.

Q

What are the different operating systems will have vi editor is by default?

A

Here I have to mention some of the different operating systems will have vi editor or clone in by default. Such as Unix, Dos, OS/2, Mac System 7.

Q

How to view the content of the file with line number using the vim editor on Linux?

A

You can click "Esc" at that point squeeze ":set nu" to view the content of the file with line number using the vim editor on Linux.

Related Tutorials in How to Set Up VIM Editor for Python Programming

Related Tutorials in How to Set Up VIM Editor for Python Programming

How To Create Python SimpleHTTPServer on ubuntu 18.04
How To Create Python SimpleHTTPServer on ubuntu 18.04
Jun 9, 2018
How to Install Python Anaconda in ubuntu 16.04
How to Install Python Anaconda in ubuntu 16.04
Feb 14, 2018
How to Create Webserver- Python 'SimpleHTTPServer'
How to Create Webserver- Python 'SimpleHTTPServer'
Jun 8, 2016
How to install Python V 3.6.5 on Centos 7
How to install Python V 3.6.5 on Centos 7
Oct 23, 2018
How to install ampps web server in Ubuntu
How to install ampps web server in Ubuntu
Jul 14, 2016
How to install python server on CentOS 7
How to install python server on CentOS 7
Aug 11, 2017
How To Install Sublime Text Editor In Linux
How To Install Sublime Text Editor In Linux
Jul 9, 2016
How to install OpenCV with python on CentOS7
How to install OpenCV with python on CentOS7
Sep 4, 2018

Related Forums in How to Set Up VIM Editor for Python Programming

Related Forums in How to Set Up VIM Editor for Python Programming

vim
caden class=
How to fix E575: viminfo: Illegal starting char in line
Jul 9, 2019
Python
jacob class=
Downgrade the Python version from Python 3.6.8 to python 2.7.5 default Version
Dec 17, 2019
Python
joshwariddin class=
Facing - pip error while installing Python: Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS
Sep 29, 2018
vim
jacob class=
Change true vi-compatible editor from Debian Vim-compatible
Nov 8, 2021
Ubuntu
keshavadk class=
FTP and SFTP server using Python
Apr 21, 2020
Python
carter class=
Cant able to view output in browser - python simpleHTTPServer
Apr 7, 2017
Linux
gabriel class=
pip command not found error
May 2, 2017
Python
jacob class=
Ansible “ansible_python_interpreter” Error
Oct 30, 2021
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Isaiah ?
What is the use of SUID & SGID commands

How to set the special permissions to the files and folders using SUID and SGID commands...

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.