|
From: | pepa65 |
Subject: | Re: Global tabgives and spacestotab config option |
Date: | Fri, 4 Jun 2021 17:06:14 +0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 |
On 6/4/21 3:18 PM, Benno Schulenberg wrote:
But instead of asking for a new feature in nano, you could also write a wrapper script that replaces (after nano exits) every group of eight leading spaces with a tab. The script could even peek into ~/.nanorc to see what tabsize is set to and use that to count the spaces.
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 Peter
[Prev in Thread] | Current Thread | [Next in Thread] |