简体   繁体   English

如何在emacs中重新对齐文本表的列?

[英]How to re-align column of text table in emacs?

When I insert a table using Mx table-insert 当我使用Mx table-insert插入表时

I get the following table: 我得到下表:

+-----+-----+-----+
|     |     |     |
+-----+-----+-----+
|     |     |     |
+-----+-----+-----+
|     |     |     |
+-----+-----+-----+

But When I add content the | 但是当我添加的内容| become disaligned like this 变得像这样不和

+-----+-----+-----+
| content   |     |     |
+-----+-----+-----+
|     |     |     |
+-----+-----+-----+
|     |     |     |
+-----+-----+-----+

How do you realign the column? 你如何重新排列列?

When I press enter it just creates that: 当我按Enter键时,它只会创建:

+-----+-----+-----+
| contecnt |   |   |
|          |   |   |
+-----+-----+-----+
|     |     |     |
+-----+-----+-----+
|     |     |     |
+-----+-----+-----+

Yes, org-mode table and table-mode table functionality are interfering with one another and preventing the table from realigning properly. 是的,组织模式表和表模式表功能相互干扰并阻止表重新正确重新排列。 I'm not sure how to fix that, but you mentioned in a comment that you are using table-mode specifically because you want multi-lined cells in the table. 我不确定如何解决这个问题,但是您在评论中提到您正在使用表格模式,因为您需要表格中的多行单元格。

I suggest that instead you use an org table (with Mx org-table-create ) and then you can split long lines over multiple lines within the same cell by calling Mx org-table-wrap-region at the point where you want the split. 我建议您使用组织表(使用Mx org-table-create ),然后通过在要分割的位置调用Mx org-table-wrap-region ,可以在同一单元格内的多行上分割长行。

The table should expand as needed for words longer than the width of the column, and the entire column should widen when this happens. 对于长于列宽的单词,表格应该根据需要展开,当发生这种情况时,整个列应该加宽。 Multiple words will wrap appropriately when the width is reached if there is space to break the line. 如果有空间来破坏线,则在达到宽度时将多个单词适当地换行。 Remember to use tab to move from cell to cell in the table. 请记住使用tab键从表格中的单元格移动到单元格。

Column width can be changed manually with Mx table-widen-cell and Mx table-narrow-cell . 可以使用Mx table-widen-cellMx table-narrow-cell手动更改列宽。

Sometimes Emacs gets confused for some reason, and something like what you describe happens. 有时Emacs会因某种原因而感到困惑,而且你所描述的内容会发生。 One way to fix it is to exit table mode with Mx table-unrecognize-table , manually edit the table, then do Mx table-recognize-table . 修复它的一种方法是使用Mx table-unrecognize-table退出表模式,手动编辑表,然后执行Mx table-recognize-table It's not ideal, but sometimes is easiest. 这不是理想的,但有时候最简单。

You enter the corresponding cell and start editing the text with C-c' it opens the edit mode and automatically wraps the text accordingly. 您输入相应的单元格并开始使用C-c'编辑文本,它将打开编辑模式并自动相应地包装文本。 Once done type C-c' again and you're back in the nicely formated table. 完成后再次键入C-c' ,然后重新进入格式良好的表格中。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM