Netbeans unindent (Shift+Tab) 在光标位于行内时不起作用(无选择)?
Netbeans unindent (Shift+Tab) not working when cursor is inside the line (no selection)?
在 Neatbeans 中,取消缩进在选择多行时按预期工作。但是请考虑以下内容,其中管道字符 |表示编辑器中的光标位置:
(a) 光标在行首(无选择)
|hello world!
(b) 光标在行内(未选择)
hell|o world!
在 Netbeans 中,当我在版本 (a) 上按下 Shift+Tab 时,缩进被删除。这是我所期望的。
但是,当我在版本 (b) 上按 Shift+Tab 时,什么也没有发生。这与我习惯的代码编辑器不同。我希望缩进被删除,或者光标移动到行的开头,这样下一个 Shift+Tab 将删除缩进。
Netbeans 中是否有一个配置可以在光标位于行内时通过 Shift+Tab 取消缩进?
TLDR:NetBeans 处理 indenting/unindenting 的方式似乎存在错误。
I would expect the indentation to be removed
我没有看到任何关于取消缩进在 NetBeans 中应该如何工作的正式文档,但它似乎将文本从光标右侧移到左侧,只要左侧只有空格光标。虽然这与取消缩进在其他代码编辑器(如 Intellij IDEA 和 Eclipse)中的工作方式不同,即使光标位于文本中,整行也会向左移动,但这不一定是不正确的。
如果您想在 NetBeans 中取消缩进,有两个简单的选择:将光标定位在行的开头,或者 select 一些文本 - 任何东西! - 在取消缩进之前的那一行。
NetBeans 错误报告中的一些评论 Bug 212353 - Shift+Tab (Delete tab) shortcut does not work in editor 可能是相关的:
Please note that those actions should be inverse - I mean when you
select a block and you hit <TAB> <TAB> <Shift-TAB> <Shift-TAB>
you
should always end up with the same text. The same should be true if
you change the order to <Shift-TAB> <Shift-TAB> <TAB> <TAB>
you
should end up with the same text.
也就是说,NetBeans 并未遵守该标准。使用您的第二个示例,按 <TAB><TAB>
可以正常工作,但随后按 <SHIFT><TAB>
什么也不做,因此不可能“ 以相同的文本 结束”。这看起来像是一个错误(至少在 Apache NetBeans 11.2 中是这样)。你可以 raise a bug report here.
还值得注意的是,<Shift>
+ <Tab>
实际上被定义为 "Delete TAB" 的键盘映射,而不是 "unindenting"。
Is there a config in Netbeans that makes unindent via Shift+Tab work
when the cursor is inside the line?
我不这么认为。使用 Tools > Options > Keymap
,您所能做的就是将快捷键从 <Shift>
+ <Tab>
更改为其他内容,但这不会改变行为。
要将行向左移动,无论光标位置如何,您都可以使用 "Shift line left" 编辑器操作。在默认的 NetBeans 映射中,它被分配给 Alt+Shift+KP_LEFT 和 Alt+Shift-LEFT
只需打开键盘映射选项页面并搜索操作 "shift line"
这与您的要求不完全相同,但您可以尝试将该操作重新映射到 "Shift-Tab" 并查看它是否有效。
在 Neatbeans 中,取消缩进在选择多行时按预期工作。但是请考虑以下内容,其中管道字符 |表示编辑器中的光标位置:
(a) 光标在行首(无选择)
|hello world!
(b) 光标在行内(未选择)
hell|o world!
在 Netbeans 中,当我在版本 (a) 上按下 Shift+Tab 时,缩进被删除。这是我所期望的。 但是,当我在版本 (b) 上按 Shift+Tab 时,什么也没有发生。这与我习惯的代码编辑器不同。我希望缩进被删除,或者光标移动到行的开头,这样下一个 Shift+Tab 将删除缩进。
Netbeans 中是否有一个配置可以在光标位于行内时通过 Shift+Tab 取消缩进?
TLDR:NetBeans 处理 indenting/unindenting 的方式似乎存在错误。
I would expect the indentation to be removed
我没有看到任何关于取消缩进在 NetBeans 中应该如何工作的正式文档,但它似乎将文本从光标右侧移到左侧,只要左侧只有空格光标。虽然这与取消缩进在其他代码编辑器(如 Intellij IDEA 和 Eclipse)中的工作方式不同,即使光标位于文本中,整行也会向左移动,但这不一定是不正确的。
如果您想在 NetBeans 中取消缩进,有两个简单的选择:将光标定位在行的开头,或者 select 一些文本 - 任何东西! - 在取消缩进之前的那一行。
NetBeans 错误报告中的一些评论 Bug 212353 - Shift+Tab (Delete tab) shortcut does not work in editor 可能是相关的:
Please note that those actions should be inverse - I mean when you select a block and you hit
<TAB> <TAB> <Shift-TAB> <Shift-TAB>
you should always end up with the same text. The same should be true if you change the order to<Shift-TAB> <Shift-TAB> <TAB> <TAB>
you should end up with the same text.
也就是说,NetBeans 并未遵守该标准。使用您的第二个示例,按 <TAB><TAB>
可以正常工作,但随后按 <SHIFT><TAB>
什么也不做,因此不可能“ 以相同的文本 结束”。这看起来像是一个错误(至少在 Apache NetBeans 11.2 中是这样)。你可以 raise a bug report here.
还值得注意的是,<Shift>
+ <Tab>
实际上被定义为 "Delete TAB" 的键盘映射,而不是 "unindenting"。
Is there a config in Netbeans that makes unindent via Shift+Tab work when the cursor is inside the line?
我不这么认为。使用 Tools > Options > Keymap
,您所能做的就是将快捷键从 <Shift>
+ <Tab>
更改为其他内容,但这不会改变行为。
要将行向左移动,无论光标位置如何,您都可以使用 "Shift line left" 编辑器操作。在默认的 NetBeans 映射中,它被分配给 Alt+Shift+KP_LEFT 和 Alt+Shift-LEFT
只需打开键盘映射选项页面并搜索操作 "shift line"
这与您的要求不完全相同,但您可以尝试将该操作重新映射到 "Shift-Tab" 并查看它是否有效。