J'essaie de plier du code PHP, et j'ai inclus une version abrégée d'une partie du code que j'essaie de plier à la fin de l'article.
J'ai essayé les commandes vim suivantes, mais seules les commandes ex ci-dessous fonctionnent. Les commandes non-ex ne fonctionnent pas et produisent un message blanc sur rouge dans la ligne d'état disant: Je ne trouve aucun pli.
: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
Comment puis-je demander à vim de trouver les plis (par exemple, je veux plier le code entre {
et }
, ou entre (
et )
.
Voici un exemple de code (juste pour montrer qu'il est syntaxiquement correct et que les commandes vim devraient donc fonctionner):
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",
),
),
);
}
la source