简体   繁体   English

如何在emacs中正确缩进?

[英]how to make proper indentation in emacs?

我只想选择一些文本,然后按TAB键以缩进所选文本的整个区域,以缩进4个空格。

That will vary with your major mode. 这将因您的主要模式而异。 In the python mode, (which is what I think you want based on the 4 spaces thing and seeing you around on the python tag) use Ctrl - c < and Ctrl - c > 在python模式下,(这是我想基于4个空格并在python标签上看到的内容,您想要的)使用Ctrl - c <Ctrl - c >

In the C major mode, just press tab and it will indent according to the rules specified in the major mode. 在C大调模式下,只需按Tab键,它将根据大调模式中指定的规则缩进。

Also note, that directly above the mini-buffer, you will see the name of the major mode, which is normally the name of the language that you are working with. 还要注意,在迷你缓冲区的正上方,您将看到主模式的名称,通常是您正在使用的语言的名称。 If you left click on that, you will see a list of commonly used commands and their key bindings. 如果您单击鼠标左键,则会看到常用命令及其键绑定的列表。

If you're indenting code, read about program indenting . 如果要缩进代码,请阅读有关程序缩进的信息 Basically, every programming mode has its own tab width (which determines the amount of indentation). 基本上,每种编程模式都有其自己的制表符宽度 (确定缩进量)。 To indent the line that the cursor is in, just press the tab key. 要缩进光标所在的行,只需按Tab键即可。 To indent multiple lines, select them and use CM-\\ (ie ESC C-\\ ). 要缩进多行,请选择它们并使用CM-\\ (即ESC C- \\ )。

For text editing, read about plain indentation . 对于文本编辑,请阅读有关普通缩进的信息 Again, tab will indent, and Cx tab will indent multiple lines by the same amount. 同样,制表符将缩进,而Cx 制表符将以相同的数量缩进多行。 Note that you can pass numeric arguments to functions bound to keys by first typing M- n , where n is the number. 请注意,您可以通过首先键入M- n来将数字参数传递给绑定到键的函数,其中n是数字。 Thus M-4 Cx tab will indent selected lines by 4 spaces. 因此, M-4 Cx 选项卡会将选定的行缩进4个空格。

Lastly, tabify and untabify will convert spaces to tabs and tabs to spaces, respectively. 最后, tabify和untabify分别将空格转换为制表符,并将制表符转换为空格。 You can bind these to key sequences in your emacs config file (.emacs or .emacs.d/init.el) using global-set-key . 您可以使用global-set-key将这些绑定到emacs配置文件(.emacs或.emacs.d / init.el)中的键序列。

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

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