“评论”的键盘快捷键NANO 中的一条线?
我爱纳米。它总是在那里,它可以切片和切块,而且它不是 VIM!
但是我不断地敲击Command /
- 无意中 - 当我继续操作时,出于习惯。大多数IDE都使用这种约定来“注释掉”一行。 NANO 有很棒的语法突出显示..所以它知道我的文档的上下文..但我还没有找到一种方法让它执行这个基本但相对重要的功能..手动注释是为了鸟儿.
我想这有点超级用户问题,但根据我的经验,这会引起一堆茫然的目光,然后一些人问 Nano 是谁,所以......在这里......
哦,还有 PS,任何人的布朗尼积分知道如何让 DashCode 也能够做到这一点...如果它能够执行此技巧,它将是有史以来最好的 Javascript IDE...并且我确信 Apple 正是因为这个原因而省略了该功能,哈哈。
I love NANO. It's always there, it can slice and dice, and its NOT VIM!
But I am constantly hitting Command /
- inadvertently - as I go along, out of habit.. Most IDE's use this convention to "comment out" a line.
NANO has great syntax highlighting.. so it knows the context of my documents.. but I haven't been able to figure out a way to get it to perform this basic, yet relatively important function.. Hand-commenting is for the birds.
I suppose this is sorta a super-user question, but in my experience, this would get a bunch of blank stares and then a few people asking who Nano was, so... here it is...
Oh and PS, brownie points for anyone that knows how to get DashCode to be able to do this as well... It would be the finest Javascript IDE EVER if it could perform this trick... and I'm convinced Apple omitted the feature for just that reason, lol.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现的最简单的解决方法:
注释:
将光标设置在应注释掉的第一行
按两次“MR”(或“Alt-r”;以替换正则表达式)
搜索:“^”
替换为:'#'
替换此实例?:'y'
按“y”将每一行注释掉
Comment-in:
相同的过程,将 '# ' 替换为 ''
The simplest workaround I've found:
Comment-out:
set the cursor at the first row that should be commented-out
hit twice 'M-R' (or 'Alt-r'; in order to Replace a RegExp)
Search for: '^'
Replace with: '# '
Replace this instance?: 'y'
press 'y' for each row to be commented-out
Comment-in:
The same procedure, replacing '# ' by ''
nano 2.6 中的新增功能
(2016 年 6 月 17 日)
(http://git.savannah.gnu.org/cgit/nano.git/tree/NEWS)
自定义
如果您不喜欢默认映射,请注意以下:
使用
Ctrl-/
通过使用bind ^/ comment main
在 ~.nanorc 中重新绑定它是不可能的。在 Linux 控制台上,这相当于退格键 (https://savannah.gnu.org/bugs/? 53248)。一些可能的替代方案可能是:
Meta-;
(emacs)Alt-/
(micro< /a>)New in nano 2.6
(2016 June 17)
(http://git.savannah.gnu.org/cgit/nano.git/tree/NEWS)
Customization
If you do not like the default mapping, note following:
Using
Ctrl-/
by rebinding it in ~.nanorc withbind ^/ comment main
is not possible. On a linux console this is equivalent to a backspace (https://savannah.gnu.org/bugs/?53248).Some possible alternatives could be:
Meta-;
(emacs)Alt-/
(micro)虽然接受的答案在法律上是正确的,但如果您还不精通 Nano,它并没有真正的帮助。
事实上,从 Nano 2.6 开始,此功能就以 M-3 (Meta-3) 的形式提供。但它的实际含义(参见doc)是注释\取消注释可以通过这些热键完成:
并且由于通常您需要注释掉几行,因此您可以使用 Alt + a (或Meta + a / Esc + a)切换到选择模式,允许选择多行。然后注释命令将立即应用于所有选定的行。
相关问题:如何在nano中一次注释多行?
While accepted answer is de jure correct, it doesn't really help if you're not proficient in Nano already.
Indeed since Nano 2.6 this functionality is available as M-3 (Meta-3). But what it actually means (see doc) is that comment\uncomment can be done via these hotkeys:
And since usually you need to comment out several lines, you can use Alt + a (or Meta + a / Esc + a) to switch to selection mode which will allow to select several lines. Then comment command will be applied on all selected lines at once.
Related question: How to comment multiple lines in nano at once?