我正在尝试折叠一些PHP代码,并且在文章结尾处包含了一些我想折叠的代码的简化版本。
我尝试了以下vim命令,但仅以下ex命令有效。non-ex命令不起作用,并在状态行中产生一条红色的白色消息:我找不到任何折叠。
:help folding
:help fold-commands
:help foldmethod
:set foldmethod=syntax
zi - toggle folding
zj - move to top of next fold
zk - move to bottom of previous fold
za - toggle current fold open and closed
zo - open current fold
zc - close current fold
zA - toggle all current folds at the current cursor position
zO - open all current folds at the current cursor position
zC - close all current folds at the current cursor position
如何获取vim来查找折叠(例如,我想在{
和}
之间或在(
和之间折叠代码)
。
这是一些示例代码(只是为了证明它在语法上是正确的,因此vim命令应该可以工作):
function getTree() {
return array(
"node1" => array(
"node11" => array(
"node111" => "leaf111",
"node112" => "leaf112",
"node113" => "leaf113",
),
"node12" => array(
"node121" => "leaf121",
"node122" => "leaf122",
"node123" => "leaf123",
),
"node13" => array(
"node131" => "leaf131",
"node132" => "leaf132",
"node133" => "leaf133",
),
),
"node2" => array(
"node21" => array(
"node211" => "leaf211",
"node212" => "leaf212",
"node213" => "leaf213",
),
"node22" => array(
"node221" => "leaf221",
"node222" => "leaf222",
"node223" => "leaf223",
),
"node23" => array(
"node231" => "leaf231",
"node232" => "leaf232",
"node233" => "leaf233",
),
),
"node3" => array(
"node31" => array(
"node311" => "leaf311",
"node312" => "leaf312",
"node313" => "leaf313",
),
"node32" => array(
"node321" => "leaf321",
"node322" => "leaf322",
"node323" => "leaf323",
),
"node33" => array(
"node331" => "leaf331",
"node332" => "leaf332",
"node333" => "leaf333",
),
),
);
}