新新200新新新新旗新新旗新新旗新新旗新新旗新新旗新200新新旗新新旗200新新新旗新新200新新新新旗新新旗新新旗新新旗新新旗新新旗新旗 [英] Emacs keybinding to comment selection/multiple lines for SQL file?

查看:97
本文介绍了新新200新新新新旗新新旗新新旗新新旗新新旗新新旗新200新新旗新新旗200新新新旗新新200新新新新旗新新旗新新旗新新旗新新旗新新旗新旗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我在Emacs 24中编辑的.sql文件,我正在寻找一种方式来评论一个选择或一行。基本上,我想要一个键绑定在行开始(单行注释)或 / * 添加 - 围绕所选区域的 * / (用于变量行注释)。



也许有些东西可以添加到我的.emacs中以启用这样的键盘绑定? (我是Emacs的一个新手)谢谢。



编辑



经过一番探索,我发现 Mx注释区域来做单行注释的技巧。这也是非常有用的:
评论指南Emacs



仍然如何做变量行注释?

解决方案

FWIW,对于行尾评论,我使用 comment-dwim (例如; 在Lisp行的末尾)。我使用它来创建评论,并重新发布。



我做 使用 comment-dwim 来评论或取消注释一段文本,即使它确实让你在某种程度上这样做(在这方面这是有限的,特别是关于嵌套和注释字符的数量)



我更喜欢 注释区域 。我将 comment-region 绑定到 C-x C - ; 。它允许我控制或更改; chars的数量用于注释(在Lisp模式下)。它可以让我轻松地取消注释一段文本。它可以让我评论已经包含已注释的文本块(嵌套)的一段文本。它可以让我取消给定级别的文本块(不要求给定的级别)。



我不能特别谈谈SQL模式注释,但尝试 comment-region ,看看它是不是你想要的。确保学习使用不同的前缀arg的可能性。



FWIW,我不知道你的意思是可变行注释 。如果您的意思是(un)评论一个文本块,那么请参阅上面的内容。如果你的意思是不同的,那么请详细说明。



请注意,在SQL代码中 - 就像在Lisp代码中一样 - 您可以使用单行注释语法( - for SQL; ; 为Lisp)注释掉文本的 。您不需要在SQL中使用 /*...*/ 。例如,我在我的SQL代码中这样做。


I have a .sql file that I am editing in Emacs 24, and I am looking for a way to comment out a selection or a line. Basically, I want a keybinding to add -- at the line start (for single line comments) or /* and */ around the selected region (for variable line comments).

Perhaps there is something that I can add to my .emacs to enable such a keybinding? (I am a bit of a novice to Emacs) Thanks.

EDIT

After a little exploring, I found M-x comment-region to do the trick for single line comments. This was also very helpful: Comment Guide in Emacs

Still, how can I do variable line comments?

解决方案

FWIW, I use comment-dwim only for end-of-line comments (e.g., ; at the end of a Lisp line). I use it there to create the comment and also to reindent it.

I do not use comment-dwim to comment or uncomment a block of text, even though it does let you do that to some extent (it is limited in this regard, especially regarding nesting and the number of comment chars to use).

I prefer comment-region for that. I bind comment-region to C-x C-;. It lets me control or change the number of ; chars to use for commenting (in Lisp mode). And it lets me easily uncomment a block of text. And it lets me comment a block of text that already contains commented blocks of text (nesting). And it lets me uncomment a block of text a given level (unnesting a given level).

I cannot speak particularly about SQL mode commenting, but try comment-region and see if it doesn't do what you want. Be sure to learn the use of different prefix arg possibilities.

FWIW, I don't know what you mean by "variable line comments". If you mean (un)commenting a block of text, then see above. If you mean something different, then please elaborate.

Note that in SQL code --- just as in Lisp code --- you can use the single-line comment syntax (-- for SQL; ; for Lisp) to comment out a block of text. You need not use /*...*/ in SQL for that. I do that in my SQL code, for instance.

这篇关于新新200新新新新旗新新旗新新旗新新旗新新旗新新旗新200新新旗新新旗200新新新旗新新200新新新新旗新新旗新新旗新新旗新新旗新新旗新旗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆