How can I convert spaces to tabs in Vim or Linux?

Posted by cwd on Stack Overflow See other posts from Stack Overflow or by cwd
Published on 2012-02-01T23:02:22Z Indexed on 2014/08/24 16:20 UTC
Read the original article Hit count: 175

Filed under:
|
|
|

I've looked over several questions on Stack Overflow for how to convert spaces to tabs without finding what I need. There seem to be more questions about how to convert tabs to spaces, but I'm trying to do the opposite.

In Vim I've tried :retab and :retab! without luck, but I believe those are actually for going from tabs to spaces anyways.

I tried both expand and unexpand at the command prompt without any luck.

Here is the file in question:

http://gdata-python-client.googlecode.com/hg-history/a9ed9edefd61a0ba0e18c43e448472051821003a/samples/docs/docs_v3_example.py

How can I convert leading spaces to tabs using either Vim or the shell?

© Stack Overflow or respective owner

Related posts about linux

Related posts about tabs