vim 可以很好地缩进文本文件中的列表(或项目符号):
- this is item one that
is indented correctly
- this is item two that
is also indented
correctly
Run Code Online (Sandbox Code Playgroud)
我可以gqap在上面的段落中输入内容,并且格式和缩进工作正常。
然而,这在 python 注释中不起作用,并且会像这样缩进:
# - this is item one that
# is not indented correctly
# - this is item two that
# is also not indented
# correctly
Run Code Online (Sandbox Code Playgroud)
如果我gqap在上面的 python 注释中输入,vim 甚至无法识别项目符号点。并最终将整个块格式化为段落。
那么对于项目符号和缩进,如何让 vim 在 python 注释中的行为与在常规文本文件中的行为相同?
我在 Vim 中发短信时遇到问题putting。
假设我想将我的/* Comment */行粘贴到该$('table').append行下方...
/* Comment */
for (var i=1; i<=lineLength ; i++) {
$('table').append('<tr></tr>');
for (var j=1; j<=lineLength; j++) {
$('table tr:nth-last-child(1)').append('<td></td>');
}
}
Run Code Online (Sandbox Code Playgroud)
在大多数文本编辑器中,我的工作流程是
/* Comment */,点击剪切。IE
/* Comment */
for (var i=1; i<=lineLength ; i++) {
$('table').append('<tr></tr>');
| <==Pipe is position of cursor before paste; pasted lines are inserted here.
for (var j=1; j<=lineLength; j++) {
$('table tr:nth-last-child(1)').append('<td></td>');
}
}
Run Code Online (Sandbox Code Playgroud)
但对于 vim,我似乎必须这样做:
/* …作为一个完美主义者,我喜欢PHP输出有效且正确缩进的HTML.
我有一些具有IT意识的用户的复杂Web应用程序,他们希望能够查看源代码而不会看到乱码.
目前我使用这个函数我写道:
function nl($tabs = 0)
{
return "\r\n" . str_repeat("\t", $tabs);
}
Run Code Online (Sandbox Code Playgroud)
像这样使用它来添加换行符和所需数量的选项卡:
if(array_key_exists('field', $row)){
echo '<td>' . $row['field'] . '</td>' . nl(4);
}
Run Code Online (Sandbox Code Playgroud)
有内置的PHP,还是有一个类可以用来自动进行缩进?
我有这个代码:
static int kontrolaParityZavorek2(final char[] text, int zacatek) {
while (zacatek < text.length && jeOteviraciZavorka(text[zacatek])) {
int konec = kontrolaParityZavorek2(text, zacatek + 1);
if (konec >= text.length ||!jsouParove(text[zacatek], text[konec]))
{throw new RuntimeException("Chybi uzaviraci zavorka na pozici: " + konec);}
zacatek = konec + 1;
}
return zacatek;
}
Run Code Online (Sandbox Code Playgroud)
我想转到NetBeans,粘贴此代码并在1秒内自动添加代码,以便它看起来像这样:
static int kontrolaParityZavorek2(final char[] text, int zacatek) {
while (zacatek < text.length && jeOteviraciZavorka(text[zacatek])) {
int konec = kontrolaParityZavorek2(text, zacatek + 1);
if (konec >= text.length ||!jsouParove(text[zacatek], text[konec]))
{throw new RuntimeException("Chybi …Run Code Online (Sandbox Code Playgroud) auto-indent ×4
indentation ×3
vim ×2
copy-paste ×1
html ×1
java ×1
netbeans ×1
paste ×1
php ×1
view-source ×1