From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Skip Montanaro Newsgroups: gmane.emacs.help Subject: Re: Is it possible to move a column where column on right is variable width Date: Tue, 16 May 2017 20:17:59 -0500 Message-ID: References: <0b6f7632-f4c0-47c9-b3fb-b5d554c358c1@googlegroups.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1494983923 22650 195.159.176.226 (17 May 2017 01:18:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 17 May 2017 01:18:43 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Angus Comber Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 17 03:18:37 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dAnbo-0005h4-I2 for geh-help-gnu-emacs@m.gmane.org; Wed, 17 May 2017 03:18:36 +0200 Original-Received: from localhost ([::1]:44957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAnbs-0001CZ-9j for geh-help-gnu-emacs@m.gmane.org; Tue, 16 May 2017 21:18:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAnbO-0001By-R4 for help-gnu-emacs@gnu.org; Tue, 16 May 2017 21:18:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAnbF-0006dC-Tu for help-gnu-emacs@gnu.org; Tue, 16 May 2017 21:18:10 -0400 Original-Received: from mail-it0-x230.google.com ([2607:f8b0:4001:c0b::230]:35116) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dAnbF-0006bX-Es for help-gnu-emacs@gnu.org; Tue, 16 May 2017 21:18:01 -0400 Original-Received: by mail-it0-x230.google.com with SMTP id c15so72901444ith.0 for ; Tue, 16 May 2017 18:18:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=VbVksntNbHcNdvjfcxgIvxZpEZMEgGGxGoS6q6DZMeQ=; b=tZt7SaDViVg5nvlplkGxOgvCPItiWdM+KdHvPBqVwlIvJvd+AvX/XXQlnZIuSQrSQy vMveqdLpPve91O8gEO/WUej1YIRrUOtUftSTbhukWDg5PIE1g6T5jmi2UUCd80xeilZp /Jywp8XiiUUfOB97ufj0CYG4igdo4wTvhKF7t8Nmb46DZCOzD7N7Gvm63bhQql99IwuK 5RYA5KTA5SCM5KAyzTPGBqoECMdAsUUY2A7Y5BFreh3RE+3PttMqQDt5i4mggrm7wjy1 L+o/0H1ZFb79epg/n6zQho3SuonknpHQXF8p9f+FS1jXYDuUV7OLlMss9k2OaNhj2Jf5 P9JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=VbVksntNbHcNdvjfcxgIvxZpEZMEgGGxGoS6q6DZMeQ=; b=KtxXiCWrN8Ep/yWoC58konP8nYqED9A384y3I+QK/6KHw7BEJxgdOcABHxNK4s69m/ HjX81s3ydraqobNtNYkZpV7/QFsQTQhcg7ZgxJxMxtDvqmlQCh5nYL+9DoUBX1zZlaHm 0JrodEL+Nw014S5vKYj6StiNpQZg0VqfW/0zkggusl8ALqcjFNHif8P2LK6L0XCSuWcf z5VWPcKZ4IKAxxncG75XNTp19gWEtsYDD2yLFbtRrLPUpA8/dcLymH6WVTaaP/6UGLWV YwhLP2u8ECsNs+6uobV1SdHE/TuO0FfrHqyToZOFZ4fJTJrM3sTKs8DEWpASIkB3BsbH GDcA== X-Gm-Message-State: AODbwcBrOFqJaKTuGNFjO2hdzv+oqje173N14c0TMKFNDfBUkTpMuGn3 TORNXl3f1JlmPO1pZ/VyqzkpuVbuRg== X-Received: by 10.36.108.76 with SMTP id w73mr14177919itb.91.1494983880498; Tue, 16 May 2017 18:18:00 -0700 (PDT) Original-Received: by 10.107.129.215 with HTTP; Tue, 16 May 2017 18:17:59 -0700 (PDT) In-Reply-To: <0b6f7632-f4c0-47c9-b3fb-b5d554c358c1@googlegroups.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c0b::230 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:113044 Archived-At: > I tried using rectangles, eg: > > set mark at top left buffer, C-space > select area, ie selected area is all of Symbols column > Then c-x r k to remove the symbols from 1st column and save to the rectangle kill ring. > then I replace $ with tab. I think you were on the right track with rectangles, but I I would cut out the ragged description and move it in front of the symbols. So, using your example: * place point over the "H" in "HAMMERSON" * set mark * move point after the "USD" at the end of the first line. * insert a single tab (perhaps need C-q C-i). * cut the rectangle * move point to the start of the buffer * yank the rectangle. If the first line isn't the longest, continue entering TABs until you are past the length of the longest line. You will probably have to collapse multiple whitespace characters into one to get your TAB separator back. All the trailing whitespace will disappear if you have this set: (add-hook 'before-save-hook 'delete-trailing-whitespace) You might want to make that mode-specific. Other people have offered non-Emacs solutions as well. I offer two. My favorite for such simple things is awk: awk -F ' \t' '{printf("%s\t%s\n", $2, $1)}'< description.txt If I wanted to place the algorithm into a file (you won't just be downloading a single file of stock data :-), either toss the awk command into a shell script, or write a short little Python script: #!/usr/bin/env python import sys, csv rdr = csv.reader(sys.stdin, delimiter="\t") wtr = csv.writer(sys.stdout, delimiter="\t") for row in rdr: wtr.writerow(list(reversed(row))) Skip Montanaro