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: Peter Magnusson
Subject: Re: Global tabgives and spacestotab config option
Date: Tue, 8 Jun 2021 17:40:22 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0

On 04/06/2021 12:06, pepa65 wrote:

Not sure how the wrapperscript would fit into the workflow, but I came up with this:


#!/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


Thats great, but it doesnt seem to be working for me:  

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

Am I using the right syntax?

/Peter


reply via email to

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