forked from 2072/PHP-Indenting-for-VIm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVimPHPIndentHelpFile.txt
94 lines (70 loc) · 2.62 KB
/
VimPHPIndentHelpFile.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
PHP *ft-php-indent* *php-indent* *php-indenting*
NOTE: PHP files will be indented correctly only if PHP |syntax| is active.
If you are editing a file in Unix 'fileformat' and '\r' characters are present
before new lines, indentation won't proceed correctly ; you have to remove
those useless characters first with a command like: >
:%s /\r$//g
Or, you can simply |:let| the variable PHP_removeCRwhenUnix to 1 and the
script will silently remove them when Vim loads a PHP file (at each |BufRead|).
OPTIONS: ~
PHP indenting can be altered in several ways by modifying the values of some
global variables:
*php-comment*
To not enable auto-formating of comments by default (if you want to use your
own 'formatoptions'): >
:let g:PHP_autoformatcomment = 0
Else, 't' will be removed from the 'formatoptions' string and "qrowcb" will be
added, see |fo-table|for more information.
-------------
To add extra indentation to single-line comments: >
:let g:PHP_outdentSLComments = N
With N being the number of 'shiftwidth' to add.
Only single-line comments will be affected such as: >
# Comment
// Comment
/* Comment */
-------------
To add extra indentation to every PHP lines with N being the number of
'shiftwidth' to add: >
:let g:PHP_default_indenting = N
For example, with N = 1, this will give:
>
<?php
if (!isset($History_lst_sel))
if (!isset($History_lst_sel))
if (!isset($History_lst_sel)) {
$History_lst_sel=0;
} else
$foo="bar";
$command_hist = TRUE;
?>
(Notice the extra indentation between the PHP container markers and the code)
-------------
To indent PHP tags as the surrounding code: >
:let g:PHP_outdentphpescape = 0
-------------
To automatically remove '\r' characters when the 'fileformat' is set to Unix: >
:let g:PHP_removeCRwhenUnix = 1
-------------
To indent braces at the same level than the code they contain: >
:let g:PHP_BracesAtCodeLevel = 1
This will give the following result: >
if ($foo)
{
foo();
}
Instead of: >
if ($foo)
{
foo();
}
NOTE: Indenting will be a bit slower if this option is used because some
optimizations won't be available.
-------------
To indent 'case:' and 'default:' statements in switch() blocks: >
:let g:PHP_vintage_case_default_indent = 1
In PHP braces are not required inside 'case/default' blocks therefore 'case:'
and 'default:' are indented at the same level than the 'switch()' to avoid
meaningless indentation. You can use the above option to return to the
traditional way.
vim:tw=78:ts=8:ft=help:norl: