Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A list of useful Python commands for Vim?

Tags:

I was looking for a quick way to autoformat/pretty-print JSON in Vim the other day and found this great little command on Stack Overflow: :%!python -m json.tool

That sent me on a search for a list of other Python tools to pretty-print common web files, but I couldn't find much. Is there a good resource/list of Python tools that they find particularly useful for cleaning up poorly formatted web stuff inside Vim (e.g. HTML, XML, JavaScript, etc.)?

like image 888
johnmdonahue Avatar asked Aug 11 '11 00:08

johnmdonahue


People also ask

What are some common Python commands?

A. Some common Python commands are input, print, range, round, pip install, len, sort, loop commands like for and while so on and so forth.


1 Answers

Python

Are you just looking for a resource for Python one-liners? You could browse through the Python standard library documentation to find more inspiration.

Or simply google "python one-liners json.tool" to find additional resources. For example, this Reddit post: Suggestion for a Python blogger: figure out what what all the stdlib main functionality is, and document it

Command line

Vim supports more than just Python (e.g. HTML Tidy as Keith suggested). Any tool that can accept pipe/standard input will integrate well with Vim.

The % command just picks a range that contains the entire file, and ! filters that range through an external program.

See :help :% and :help :!

like image 177
Merlyn Morgan-Graham Avatar answered Sep 19 '22 11:09

Merlyn Morgan-Graham