nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Global tabgives and spacestotab config option


From: pepa65
Subject: Re: Global tabgives and spacestotab config option
Date: Wed, 9 Jun 2021 09:42:28 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 6/8/21 10:40 PM, Peter Magnusson wrote:
On 04/06/2021 12:06, pepa65 wrote:
#!/usr/bin/env bash
# spc2tab - Convert leading spaces into tabs
# Required: sed
# Usage: spc2tab <file
nanoconf=~/.nanorc s='[[:blank:]]'
tabsize=$(grep -eo "^$s*set$s+tabsize$s+[1-9][0-9]*" "$nanoconf" |tail -1 |grep 
-o '[0-9]*$')
# Use given tabsize or 8 as (nano) default
tabsize=${1:-8}
spc=$(printf '%*s' $tabsize) tab=$'\t'
sed ":a;s@^\($tab*\)$spc@\1$tab@;ta" </dev/stdin

$ spc2tab.sh <anyfilename
bash: anyfilename: No such file or directory

It seems 'anyfilename' is not in your current directory, you have to give the 
absolute path or the path relative to your current directory.

Peter




reply via email to

[Prev in Thread] Current Thread [Next in Thread]