Avatar of naseeam
naseeamFlag for United States of America

asked on 

How to convert indentation to space in Vim ?

I typed following command in vim to show white space characters, such as eol, tab, and space.
:set listchars=eol:$,nbsp:_,tab:>-,trail:~,extends:>,precedes:<

The file was cloned from git repository.  Indentation is setup for tabs.  How do I convert indentation to space?

 50 addtask listtasks$
 51 do_listtasks[nostamp] = "1"$
 52 python do_listtasks() {$
 53 >-import sys$
 54   print('Hello World')$
 55 >-for e in bb.data.keys(d):$
 56 >->-if d.getVarFlag(e, 'task', False):$
 57 >->->-bb.plain("%s" % e)$
 58 }$
Editors IDEsLinux Distributions* Text Editor

Avatar of undefined
Last Comment
naseeam
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of naseeam
naseeam
Flag of United States of America image

ASKER

:%s/\t/    /g
This worked!  Could you please explain each character in this command?
Avatar of skullnobrains
skullnobrains

: command mode
% probably means to apply the command to the whole file. not sure : i hardly ever use vi
s replace command
/ delimiter ... meaning s/X/Y/ replaces all instances of X with Y. "/" can be replaced with a different ascii character
Avatar of noci
noci

Additional:
% is all lines (1,$) as a line selector.
the final g on the command means to replace ALL items matching on a line not just the first one.
\t is  a visible way to type TAB   (one can also use TAB character in that spot.
Avatar of naseeam
naseeam
Flag of United States of America image

ASKER

Thank you for solving the problem.
Linux Distributions
Linux Distributions

A Linux distribution is an operating system made as a software collection based on the Linux kernel and, often, on a package management system and are available for a variety of systems. A typical Linux distribution comprises a Linux kernel, GNU tools and libraries, additional software, documentation, a window system (the most common being the X Window System), a window manager, and a desktop environment. Most Linux systems are open-source software made available both as compiled binaries and in source code form, allowing modifications to the original software. Over three hundred distributions are in active development, including commercially backed distributions (such as Fedora, openSUSE and Ubuntu) and community-driven distributions (such as Debian, Slackware, Gentoo and Arch Linux).

29K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo