Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7841853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:11:15+00:00 2026-06-02T16:11:15+00:00

I have a single line text file of csv values I would like to

  • 0

I have a single line text file of csv values

I would like to able to ‘pretty-print’ the file to span multiple lines to make it more readable

The 1st no. represents the no. of csv values in the next section and so on

e.g.

3,1,2,3,3,4,5,6

would be converted to:

3,1,2,3
3,4,5,6

I know a little about making macros, e.g.

C-x (
C-s RET ,
C-x )

using this I can do:

C-u 3 C-x e to move 3 csv values along

My sticking point is how to use the value from file to paste into the arg to C-u

maybe I should be using an e-lisp function instead as its a function I would like to ‘save’ for continual use across emacs sessions. Is it possible to save macros as such?

any ideas gratefully received

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:11:16+00:00Added an answer on June 2, 2026 at 4:11 pm

    I find elisp easier to think about than keyboard macros. How about this:

    (defun csv-line-breaks ()
      (interactive)
      (while (search-forward "," nil t 
                             (1+ (string-to-number (thing-at-point 'word))))
        (delete-char -1)
        (insert "\n")))
    
    (global-set-key (kbd "C-c b") 'csv-line-breaks)
    

    With this in your .emacs (or just evaluate the code in your scratch buffer), you put point at the beginning of the line, then hit C-c b to break the line up into the chunks you want.

    What this does:

    1. Looping over the buffer until it runs out of values, and for each loop:
    2. Read the first value. (thing-at-point 'word) grabs anything it finds between whitespace of punctuation (more or less).
    3. Convert the value, which is actually a string, into a number
    4. Add one to that number, and move forward that many commas
    5. Delete the previous comma
    6. Insert a new line
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text in the form of separate lines, where each line has CSV-like
I have a text file of lacs of line and a single line is
I have a large data file consisting of a single line of text. The
I have thousands of text files, and each file contains just a single line
I have a single line CEikLabel in my application that needs to scroll text.
I have a sproc that returns a single line and column with a text,
I need to have various text view on a single line. And I want
I have a file (10-20MB) containing data, where each line is a single piece
I have a text file that contains a data like ID Name Path IsTrue
Using C I would like to read in the contents of a text file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.