[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs: adding 1 to every number made of 2 digits inside a marked reg
From: |
Arthur Miller |
Subject: |
Re: Emacs: adding 1 to every number made of 2 digits inside a marked region. |
Date: |
Mon, 27 Sep 2021 03:02:34 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Michael Heerdegen <michael_heerdegen@web.de> writes:
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
>> Imagine I've got the following in a text file opened under Emacs:
>>
>> some 34
>> word 30
>> another 38
>> thing 59
>> to 39
>> say 10
>> here 47
>>
>> and I want to turn into this, adding 1 to every number made of 2 digits:
>>
>> some 35
>> word 31
>> another 39
>> thing 60
>> to 40
>> say 11
>> here 48
>
> You might want to give Calc a try for such things. It doesn't perfectly
> handle the editing part though since it doesn't know about rectangle
> commands (AFAICT - at least for insertion).
>
> So here is how I would do it:
>
> - mark the rectangular region spanning the numbers
> - `C-x * r': this will grab the number column as a matrix and pop up
> Calc
> - `1 RET +': will add 1 to all entries
>
> You now have the result as a matrix. What you have to do now manually
> using conventional rectangle commands is to kill the original numbers
> from the buffer (they are already marked, so `C-x r k'), and then kill
> and yank the numbers as rectangle from the Calc buffer.
>
> Calc also allows to add numbers in a row or column in any buffer in a
> similarly easy way. The Calc tutorial has some examples doing such
> things.
>
> Michael.
Oh ... sent previous before I was done, forgott I wasnn't in org-mode :-)
Anyway I am sorry for the noise. I thought it would be this easy:
| some | 34 | |
| word | 30 | |
| another | 38 | |
| thing | 59 | |
| to | 39 | |
| say | 10 | |
| here | 47 | |
#+TBLFM: $3='(apply '1+ $2);N'
- RE: [External] : Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., (continued)
- RE: [External] : Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Drew Adams, 2021/09/23
- Re: [External] : Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Emanuel Berg, 2021/09/23
- RE: [External] : Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Drew Adams, 2021/09/23
- Re: [External] : Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Emanuel Berg, 2021/09/23
- RE: [External] : Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Drew Adams, 2021/09/23
- Re: [External] : Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Gregory Heytings, 2021/09/24
- Re: [External] : Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Emanuel Berg, 2021/09/24
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Andreas RÃ¶hler, 2021/09/23
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Michael Heerdegen, 2021/09/26
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Arthur Miller, 2021/09/26
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region.,
Arthur Miller <=
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Emanuel Berg, 2021/09/26
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Hongyi Zhao, 2021/09/27
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Emanuel Berg, 2021/09/27
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Arthur Miller, 2021/09/27
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Emanuel Berg, 2021/09/27
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Arthur Miller, 2021/09/27
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Arthur Miller, 2021/09/26