简体   繁体   English

如何在emacs组织模式表中格式化一列数字?

[英]How can I format a column of numbers in an emacs org mode table?

I have a table in this form, in emacs org-mode . 我在emacs org-mode有一个表格。 Please, is there a way to format the numbers in columns 3 and 4 to line the decimal points up vertically? 请问,是否有办法格式化第3列和第4列中的数字以垂直排列小数点?

Note, an aside: I sorted the resulting file using bash sort command, and found that the extra | 注意,旁白:我使用bash sort命令对生成的文件进行sort ,并发现额外的| at the start of each line is counted as column 1, so, for instance the column headed OUTPUT is number 4 in this context. 在每行的开头计为第1列,因此,例如,在此上下文中, OUTPUTOUTPUT列为4。

| CALL  | CHAN   |   OUTPUT |    INPUT | QTHR   | LOCATION       | NGR        | REGION   | CTCSS | KEEPER | Internet |
| GB3AH | RB11   |  433.275 |  434.875 | JO02KP | East Dereham   | TF94300990 | EAST ENG |  94.8 | G8PON  |          |
| GB3AS | RV48   |    145.6 |      145 | IO84LS | Wigton,Cumbria | NY33724123 | N.ENG    |    77 | G4KFN  |          |
| GB3AG | RV58   |  145.725 |  145.125 | IO86ON | Forfar         | NO48904170 | SCOT     |  94.8 | GM1CMF | Echolink |
| GB3AY | RV52   |   145.65 |   145.05 | IO75OR | Dalry          | NS26605190 | SCOT     | 103.5 | GM3YKE |          |
| GB3BA | RB01   |  433.025 |  434.625 | IO87SC | Banchory       | NJ72150255 | SCOT     |    67 | GM1XEA |          |
| GB3BD | RB06   |   433.15 |   434.75 | IO92RA | Ampthill       | TL01303860 | SE ENG   |    77 | G8MGP  |          |
| GB3AA | 23cm   |     1297 |     1291 | IO81RO | Alveston,Avon  | ST62608820 | SW ENG   | 118.8 | G4CJZ  |          |
| GB3AI | RV55   | 145.6875 | 145.0875 | IO91QQ | Amersham       | SU97089767 | SW ENG   |    77 | G0RDI  | Echolink |
| GB3AL | RV59   | 145.7375 | 145.1375 | IO91QP | Amersham       | SU95709550 | SW ENG   |    77 | G0RDI  |          |
| GB3AM | R50-13 |    50.84 |    51.34 | IO91QP | Amersham       | SU95709550 | SW ENG   |    77 | G0RDI  |          |

Here are the steps: 以下是步骤:

  1. This is an optional one, to make things a bit more visual. 这是一个可选的,使事情更具视觉效果。 Cc } turns on the overlays for row and column numbers. Cc}打开行号和列号的叠加层。 Same combination turns the off. 相同的组合将关闭。 Note that these are not the changes in your buffer, they're just tooltips. 请注意,这些不是缓冲区中的更改,它们只是工具提示。 You might want to do Cc - on the first line, to see the column numbers. 您可能想要在第一行执行抄送 ,以查看列号。
  2. Move cursor to OUTPUT column and insert a new column with CS-right . 将光标移动到OUTPUT列并插入一个CS-right的新列。
  3. Your cursor should now be in the new column. 您的光标现在应该在新列中。 Type in $4=$3;%0.3f , ie copy the third column to the fourth, and format it as a floating point with 3 precision. 键入$4=$3;%0.3f$4=$3;%0.3f第三列复制到第四列,并将其格式化为具有3精度的浮点。 Press return, and just one cell will fill in. Press Cu Cc * to recalculate all cells. 按返回键,只需填写一个单元格。按Cu Cc *重新计算所有单元格。 This can also be done with Cc Cc , with cursor on #+TBLFM: line. 这也可以用Cc Cc完成,光标在#+TBLFM: line上。
  4. You can remove the old column with CM-left if you want, and delete the table formula below. 如果需要,可以使用CM-left删除旧列,并删除下面的表格公式。

UPDATE: 更新:

Thanks to input from @phils, here's the alternative way: 感谢@phils的输入,这是另一种方式:

  1. Move your cursor to any number in column 3, eg 433.275 . 将光标移动到第3列中的任何数字,例如433.275
  2. Press Cc = , cursor moves to minibuffer. Cc = ,光标移动到迷你缓冲区。
  3. Enter $0;%0.3f and press return. 输入$0;%0.3f并按回车键。 Here $0 refers to the current column, $3 would also work if it were column 3. 这里$0表示当前列,如果是第3列, $3也可以工作。
  4. Either press Cu Cc * anywhere in the document, or move the cursor to #+TBLFM: line and press Cc Cc . 在文档中的任何位置按Cu Cc * ,或将光标移动到#+TBLFM: line并按Cc Cc
  5. Repeat the same process for column 4. 对第4列重复相同的过程。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将组织文件中的最新条目输出并格式化到终端? - How can I output and format the latest entry in an org file to the terminal? Shell:如何根据解析的数据(数字)制作文本模式条形图? - Shell: How can I make a text-mode bar chart from parsed data (numbers)? 在bash中,当B列具有相同内容时,如何将A列中的所有数字相加? - In bash, how can I add up all numbers from column A when column B has the same content? 如何格式化我的grep输出以显示行尾的行号,以及命中计数? - How can I format my grep output to show line numbers at the end of the line, and also the hit count? 如何在Emacs中的术语模式下转到命令开头? - How to go to beginning of command in term mode in Emacs? Bash:如何(1)从包含一列数字的文件的“ i”行中读取数字,以及(2)将值分配给变量? - Bash: how can I (1) read in a number from line “i” in a file that contains a column of numbers and (2) assign the value to a variable? 如何在bash中创建多列html表? - How can I create a multi-column html table in bash? 如何使用循环创建bash脚本以创建具有5列/ 10行格式的乘法表 - How do I create a bash script, using loops, to create a Multiplication Table with 5 column/10 row format 如何使Emacs的shell模式成为我的配置文件的源? - How to make Emacs 's shell mode source my profile file? 如何显示在emacs的shell模式下读取命令的结果? - How to show the result of command read in emacs's shell mode?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM