vim python: substitute 'spaces' indent to 'tabs'?

R

Rocky Zhou

I am accustomed to vi my pthon scripts with 'tab' indent. But when I
copy some code to my script, the indent may be 'spaces'. So I wanna a
way to substitute those 'spaces' to be 'tabs' conveniently.

For example, I:
expand -t4 test.py >/tmp/test2.py
vi /tmp/test2.py

Then in vim, the indents should be:
/^\( \{4\}\)*/
but I don't know how to substitute this to that:
/^\(\t\{\4\}\)*/

Is there any way?

Thanks.
 
F

forgems

I am accustomed to vi my pthon scripts with 'tab' indent. But when I
copy some code to my script, the indent may be 'spaces'. So I wanna a
way to substitute those 'spaces' to be 'tabs' conveniently.

For example, I:
expand -t4 test.py >/tmp/test2.py
vi /tmp/test2.py

Then in vim, the indents should be:
/^\( \{4\}\)*/
but I don't know how to substitute this to that:
/^\(\t\{\4\}\)*/

Is there any way?

Thanks.

:set noet
:retab
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top