delimitMate.txt 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. *delimitMate.txt* Trying to keep those beasts at bay! v2.7 *delimitMate*
  2. MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  3. MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMMMM MMMMMMMMMMMMMMMMMMMMM ~
  4. MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMM MMM MMMMMMMMMMMMMMMMMMMMM
  5. MMMM MMMMMMMMM MMMMMMMMMMMMMMMMMMMMM MMM M M MMMMMMMMMM MMMMMMMMM ~
  6. MMMM MMM MMM MM MM M M MMM MM MM MM MM MMM MMM MMM MM
  7. MM MM M MM MMMMMM MMMMMMM MMM MMMMM MM M MMM MMM M M ~
  8. M M MM MM MM MM M M MM MMM MMM MMMMM MMMMM MMM MMM M
  9. M M MM MMMMM MM MM M M MM MMM MMM MMMMM MMM MMM MMM MMMM ~
  10. M M MM M MM MM MM M M MM MMM MMM MMMMM MM M MMM MMM M M
  11. MM MMM MMM MM MM M M MM MMM MM MMMMM MMM MMM MMM MM ~
  12. MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  13. ==============================================================================
  14. 0.- CONTENTS *delimitMate-contents*
  15. 1. Introduction____________________________|delimitMateIntro|
  16. 2. Customization___________________________|delimitMateOptions|
  17. 2.1 Options summary____________________|delimitMateOptionSummary|
  18. 2.2 Options details____________________|delimitMateOptionDetails|
  19. 3. Functionality___________________________|delimitMateFunctionality|
  20. 3.1 Automatic closing & exiting________|delimitMateAutoClose|
  21. 3.2 Expansion of space and CR__________|delimitMateExpansion|
  22. 3.3 Backspace__________________________|delimitMateBackspace|
  23. 3.4 Smart Quotes_______________________|delimitMateSmartQuotes|
  24. 3.5 Balancing matching pairs___________|delimitMateBalance|
  25. 3.6 FileType based configuration_______|delimitMateFileType|
  26. 3.7 Syntax awareness___________________|delimitMateSyntax|
  27. 4. Commands________________________________|delimitMateCommands|
  28. 5. Mappings________________________________|delimitMateMappings|
  29. 6. Functions_______________________________|delimitMateFunctions|
  30. 7. Autocommands____________________________|delimitMateAutocmds|
  31. 8. TODO list_______________________________|delimitMateTodo|
  32. 9. Maintainer______________________________|delimitMateMaintainer|
  33. 10. Credits_________________________________|delimitMateCredits|
  34. 11. History_________________________________|delimitMateHistory|
  35. ==============================================================================
  36. 1.- INTRODUCTION *delimitMateIntro*
  37. This plug-in provides automatic closing of quotes, parenthesis, brackets,
  38. etc.; besides some other related features that should make your time in insert
  39. mode a little bit easier.
  40. Most of the features can be modified or disabled permanently, using global
  41. variables, or on a FileType basis, using autocommands.
  42. NOTE 1: If you have any trouble with this plugin, please run |:DelimitMateTest|
  43. in a new buffer to see what is not working.
  44. NOTE 2: Abbreviations set with |:iabbrev| will not be expanded by delimiters
  45. used on delimitMate, you should use <C-]> (read |i_CTRL-]|) to expand them on
  46. the go.
  47. ==============================================================================
  48. 2. CUSTOMIZATION *delimitMateOptions*
  49. You can create your own mappings for some features using the global functions.
  50. Read |delimitMateFunctions| for more info.
  51. ------------------------------------------------------------------------------
  52. 2.1 OPTIONS SUMMARY *delimitMateOptionSummary*
  53. The behaviour of this script can be customized setting the following options
  54. in your vimrc file. You can use local options to set the configuration for
  55. specific file types, see |delimitMateOptionDetails| for examples.
  56. |'loaded_delimitMate'| Turns off the script.
  57. |'delimitMate_autoclose'| Tells delimitMate whether to automagically
  58. insert the closing delimiter.
  59. |'delimitMate_matchpairs'| Tells delimitMate which characters are
  60. matching pairs.
  61. |'delimitMate_quotes'| Tells delimitMate which quotes should be
  62. used.
  63. |'delimitMate_nesting_quotes'| Tells delimitMate which quotes should be
  64. allowed to be nested.
  65. |'delimitMate_expand_cr'| Turns on/off the expansion of <CR>.
  66. |'delimitMate_expand_space'| Turns on/off the expansion of <Space>.
  67. |'delimitMate_jump_expansion'| Turns on/off jumping over expansions.
  68. |'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
  69. |'delimitMate_smart_matchpairs'| Turns on/off the "smart matchpairs" feature.
  70. |'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
  71. feature.
  72. |'delimitMate_excluded_regions'| Turns off the script for the given regions or
  73. syntax group names.
  74. |'delimitMate_excluded_ft'| Turns off the script for the given file types.
  75. |'delimitMate_eol_marker'| Determines what to insert after the closing
  76. matchpair when typing an opening matchpair on
  77. the end of the line.
  78. |'delimitMate_apostrophes'| Tells delimitMate how it should "fix"
  79. balancing of single quotes when used as
  80. apostrophes. NOTE: Not needed any more, kept
  81. for compatibility with older versions.
  82. ------------------------------------------------------------------------------
  83. 2.2 OPTIONS DETAILS *delimitMateOptionDetails*
  84. Add the shown lines to your vimrc file in order to set the below options.
  85. Buffer variables take precedence over global ones and can be used along with
  86. autocmd to modify delimitMate's behavior for specific file types, read more in
  87. |delimitMateFileType|.
  88. Note: Use buffer variables only to set options for specific file types using
  89. :autocmd, use global variables to set options for all buffers. Read more in
  90. |g:var| and |b:var|.
  91. ------------------------------------------------------------------------------
  92. *'loaded_delimitMate'*
  93. *'b:loaded_delimitMate'*
  94. This option prevents delimitMate from loading.
  95. e.g.: >
  96. let loaded_delimitMate = 1
  97. au FileType mail let b:loaded_delimitMate = 1
  98. <
  99. ------------------------------------------------------------------------------
  100. *'delimitMate_offByDefault'*
  101. Values: 0 or 1.~
  102. Default: 0~
  103. If this option is set to 1, delimitMate will load, but will not take
  104. effect in any buffer unless |:DelimitMateSwitch| is called in that
  105. buffer.
  106. ------------------------------------------------------------------------------
  107. *'delimitMate_autoclose'*
  108. *'b:delimitMate_autoclose'*
  109. Values: 0 or 1. ~
  110. Default: 1 ~
  111. If this option is set to 0, delimitMate will not add a closing delimiter
  112. automagically. See |delimitMateAutoClose| for details.
  113. e.g.: >
  114. let delimitMate_autoclose = 0
  115. au FileType mail let b:delimitMate_autoclose = 0
  116. <
  117. ------------------------------------------------------------------------------
  118. *'delimitMate_matchpairs'*
  119. *'b:delimitMate_matchpairs'*
  120. Values: A string with |'matchpairs'| syntax, plus support for multi-byte~
  121. characters.~
  122. Default: &matchpairs ~
  123. Use this option to tell delimitMate which characters should be considered
  124. matching pairs. Read |delimitMateAutoClose| for details.
  125. e.g: >
  126. let delimitMate_matchpairs = "(:),[:],{:},<:>"
  127. au FileType vim,html let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
  128. <
  129. ------------------------------------------------------------------------------
  130. *'delimitMate_quotes'*
  131. *'b:delimitMate_quotes'*
  132. Values: A string of characters separated by spaces. ~
  133. Default: "\" ' `" ~
  134. Use this option to tell delimitMate which characters should be considered as
  135. quotes. Read |delimitMateAutoClose| for details.
  136. e.g.: >
  137. let delimitMate_quotes = "\" ' ` *"
  138. au FileType html let b:delimitMate_quotes = "\" '"
  139. <
  140. ------------------------------------------------------------------------------
  141. *'delimitMate_nesting_quotes'*
  142. *'b:delimitMate_nesting_quotes'*
  143. Values: A list of quotes. ~
  144. Default: [] ~
  145. When adding a third quote listed in this option is inserted, three quotes will
  146. be inserted to the right of the cursor and the cursor will stay in the middle.
  147. If more quotes are inserted the number of quotes on both sides of the cursor
  148. will stay balanced.
  149. e.g.: >
  150. let delimitMate_nesting_quotes = ['"','`']
  151. au FileType python let b:delimitMate_nesting_quotes = ['"']
  152. <
  153. For Python this is set by default by the plugin.
  154. ------------------------------------------------------------------------------
  155. *'delimitMate_expand_cr'*
  156. *'b:delimitMate_expand_cr'*
  157. Values: 0, 1 or 2 ~
  158. Default: 0 ~
  159. This option turns on/off the expansion of <CR>. Read |delimitMateExpansion|
  160. for details. NOTE This feature requires that 'backspace' is either set to 2 or
  161. has "eol" and "start" as part of its value.
  162. e.g.: >
  163. let delimitMate_expand_cr = 1
  164. au FileType mail let b:delimitMate_expand_cr = 1
  165. <
  166. ------------------------------------------------------------------------------
  167. *'delimitMate_expand_space'*
  168. *'b:delimitMate_expand_space'*
  169. Values: 1 or 0 ~
  170. Default: 0 ~
  171. This option turns on/off the expansion of <Space>. Read |delimitMateExpansion|
  172. for details.
  173. e.g.: >
  174. let delimitMate_expand_space = 1
  175. au FileType tcl let b:delimitMate_expand_space = 1
  176. <
  177. ------------------------------------------------------------------------------
  178. *'delimitMate_expand_inside_quotes'*
  179. *'b:delimitMate_expand_inside_quotes'*
  180. Values: 1 or 0 ~
  181. Default: 0 ~
  182. When this option is set to 1 the expansion of space and cr will also be
  183. applied to quotes. Read |delimitMateExpansion| for details.
  184. e.g.: >
  185. let delimitMate_expand_inside_quotes = 1
  186. au FileType mail let b:delimitMate_expand_inside_quotes = 1
  187. <
  188. ------------------------------------------------------------------------------
  189. *'delimitMate_jump_expansion'*
  190. *'b:delimitMate_jump_expansion'*
  191. Values: 1 or 0 ~
  192. Default: 0 ~
  193. This option turns on/off the jumping over <CR> and <Space> expansions when
  194. inserting closing matchpairs. Read |delimitMateExpansion| for details.
  195. e.g.: >
  196. let delimitMate_jump_expansion = 1
  197. au FileType tcl let b:delimitMate_jump_expansion = 1
  198. <
  199. ------------------------------------------------------------------------------
  200. *'delimitMate_smart_quotes'*
  201. *'b:delimitMate_smart_quotes'*
  202. Values: String with an optional ! at the beginning followed by a regexp ~
  203. Default:~
  204. '\%(\w\|[^[:punct:][:space:]]\|\%(\\\\\)*\\\)\%#\|\%#\%(\w\|[^[:space:][:punct:]]\)' ~
  205. A bang (!) at the beginning is removed and used to "negate" the pattern. The
  206. remaining text is used as a regexp to be matched on the current line. A single
  207. quote is inserted when the pattern matches and a bang is not present. The bang
  208. changes that, so a single quote is inserted only if the regexp does not match.
  209. This feature is disabled when the variable is set to an empty string, with the
  210. exception of apostrophes.
  211. Note that you need to use '\%#' to match the position of the cursor. Keep in
  212. mind that '\%#' matches with zero width, so if you need to match the char
  213. under the cursor (which would be the one to the right on insert mode) use
  214. something like '\%#.'.
  215. e.g.: >
  216. let delimitMate_smart_quotes = '\w\%#'
  217. au FileType tcl let b:delimitMate_smart_quotes = '!\s\%#\w'
  218. <
  219. ------------------------------------------------------------------------------
  220. *'delimitMate_smart_matchpairs'*
  221. *'b:delimitMate_smart_matchpairs'*
  222. Values: Regexp ~
  223. Default: '^\%(\w\|\!\|[£$]\|[^[:space:][:punct:]]\)' ~
  224. This regex is matched against the text to the right of cursor, if it's not
  225. empty and there is a match delimitMate will not autoclose the pair. At the
  226. moment to match the text, an escaped bang (\!) in the regex will be replaced
  227. by the character being inserted, while an escaped number symbol (\#) will be
  228. replaced by the closing pair.
  229. e.g.: >
  230. let delimitMate_smart_matchpairs = ''
  231. au FileType tcl let b:delimitMate_smart_matchpairs = '^\%(\w\|\$\)'
  232. <
  233. ------------------------------------------------------------------------------
  234. *'delimitMate_balance_matchpairs'*
  235. *'b:delimitMate_balance_matchpairs'*
  236. Values: 1 or 0 ~
  237. Default: 0 ~
  238. This option turns on/off the balancing of matching pairs. Read
  239. |delimitMateBalance| for details.
  240. e.g.: >
  241. let delimitMate_balance_matchpairs = 1
  242. au FileType tcl let b:delimitMate_balance_matchpairs = 1
  243. <
  244. ------------------------------------------------------------------------------
  245. *'delimitMate_excluded_regions'*
  246. Values: A string of syntax group names names separated by single commas. ~
  247. Default: Comment ~
  248. This options turns delimitMate off for the listed regions, read |group-name|
  249. for more info about what is a region.
  250. e.g.: >
  251. let delimitMate_excluded_regions = "Comment,String"
  252. <
  253. ------------------------------------------------------------------------------
  254. *'delimitMate_excluded_ft'*
  255. Values: A string of file type names separated by single commas. ~
  256. Default: Empty. ~
  257. This options turns delimitMate off for the listed file types, use this option
  258. only if you don't want any of the features it provides on those file types.
  259. e.g.: >
  260. let delimitMate_excluded_ft = "mail,txt"
  261. <
  262. ------------------------------------------------------------------------------
  263. *'delimitMate_insert_eol_marker'*
  264. Values: Integer ~
  265. Default: 1 ~
  266. Whether to insert the eol marker (EM) or not. The EM is inserted following
  267. rules:
  268. 0 -> never
  269. 1 -> when inserting any matchpair
  270. 2 -> when expanding car return in matchpair
  271. e.g.: >
  272. au FileType c,perl let b:delimitMate_insert_eol_marker = 2
  273. <
  274. ------------------------------------------------------------------------------
  275. *'delimitMate_eol_marker'*
  276. Values: String. ~
  277. Default: Empty. ~
  278. The contents of this string will be inserted after the closing matchpair or
  279. quote when the respective opening matchpair or quote is inserted at the end
  280. of the line.
  281. e.g.: >
  282. au FileType c,perl let b:delimitMate_eol_marker = ";"
  283. <
  284. ------------------------------------------------------------------------------
  285. *'delimitMate_apostrophes'*
  286. Values: Strings separated by ":". ~
  287. Default: No longer used. ~
  288. NOTE: This feature is turned off by default, it's been kept for compatibility
  289. with older version, read |delimitMateSmartQuotes| for details.
  290. If auto-close is enabled, this option tells delimitMate how to try to fix the
  291. balancing of single quotes when used as apostrophes. The values of this option
  292. are strings of text where a single quote would be used as an apostrophe (e.g.:
  293. the "n't" of wouldn't or can't) separated by ":". Set it to an empty string to
  294. disable this feature.
  295. e.g.: >
  296. let delimitMate_apostrophes = ""
  297. au FileType tcl let delimitMate_apostrophes = ""
  298. <
  299. ==============================================================================
  300. 3. FUNCTIONALITY *delimitMateFunctionality*
  301. ------------------------------------------------------------------------------
  302. 3.1 AUTOMATIC CLOSING AND EXITING *delimitMateAutoClose*
  303. With automatic closing enabled, if an opening delimiter is inserted the plugin
  304. inserts the closing delimiter and places the cursor between the pair. With
  305. automatic closing disabled, no closing delimiters is inserted by delimitMate,
  306. but when a pair of delimiters is typed, the cursor is placed in the middle.
  307. When the cursor is inside an empty pair or located next to the left of a
  308. closing delimiter, the cursor is placed outside the pair to the right of the
  309. closing delimiter.
  310. When |'delimitMate_smart_matchpairs'| is not empty and it matches the text to
  311. the right of the cursor, delimitMate will not automatically insert the closing
  312. pair.
  313. Unless |'delimitMate_matchpairs'| or |'delimitMate_quotes'| are set, this
  314. script uses the values in '&matchpairs' to identify the pairs, and ", ' and `
  315. for quotes respectively.
  316. <S-Tab> will jump over a single closing delimiter or quote, <C-G>g will jump
  317. over contiguous delimiters and/or quotes.
  318. The following table shows the behaviour, this applies to quotes too (the final
  319. position of the cursor is represented by a "|"):
  320. With auto-close: >
  321. Type | You get
  322. =======================
  323. ( | (|)
  324. -----------|-----------
  325. () | ()|
  326. -----------|-----------
  327. (<S-Tab> | ()|
  328. -----------|-----------
  329. {("<C-G>g | {("")}|
  330. <
  331. Without auto-close: >
  332. Type | You get
  333. =========================
  334. () | (|)
  335. --------------|----------
  336. ()) | ()|
  337. --------------|----------
  338. ()<S-Tab> | ()|
  339. --------------|----------
  340. {}()""<C-G>g | {("")}|
  341. <
  342. NOTE: Abbreviations will not be expanded by delimiters used on delimitMate,
  343. you should use <C-]> (read |i_CTRL-]|) to expand them on the go.
  344. ------------------------------------------------------------------------------
  345. 3.2 EXPANSION OF SPACE AND CAR RETURN *delimitMateExpansion*
  346. When the cursor is inside an empty pair of any matchpair, <Space> and <CR> can be
  347. expanded, see |'delimitMate_expand_space'| and
  348. |'delimitMate_expand_cr'|:
  349. Expand <Space> to: >
  350. You start with | You get
  351. ==============================
  352. (|) | ( | )
  353. <
  354. Expand <CR> to: >
  355. You start with | You get
  356. ==============================
  357. (|) | (
  358. | |
  359. | )
  360. <
  361. When you have |'delimitMate_jump_expansion'| enabled, if there is an existing
  362. closing paren/bracket/etc. on the next line, delimitMate will make the cursor
  363. jump over any whitespace/<CR> and place it after the existing closing
  364. delimiter instead of inserting a new one.
  365. When |'delimitMate_expand_cr'| is set to 2, the following will also happen: >
  366. You start with | You get
  367. ==============================
  368. (foo|) | (foo
  369. | |
  370. | )
  371. <
  372. Since <Space> and <CR> are used everywhere, I have made the functions involved
  373. in expansions global, so they can be used to make custom mappings. Read
  374. |delimitMateFunctions| for more details.
  375. ------------------------------------------------------------------------------
  376. 3.3 BACKSPACE *delimitMateBackspace*
  377. If you press backspace inside an empty pair, both delimiters are deleted. When
  378. expansions are enabled, <BS> will also delete the expansions.
  379. If you type <S-BS> (shift + backspace) instead, only the closing delimiter
  380. will be deleted. NOTE that this will not usually work when using Vim from the
  381. terminal, see 'delimitMate#JumpAny()' below to see how to fix it.
  382. e.g. typing at the "|": >
  383. What | Before | After
  384. ==============================================
  385. <BS> | call expand(|) | call expand|
  386. ---------|-------------------|-----------------
  387. <BS> | call expand( | ) | call expand(|)
  388. ---------|-------------------|-----------------
  389. <BS> | call expand( | call expand(|)
  390. | | |
  391. | ) |
  392. ---------|-------------------|-----------------
  393. <S-BS> | call expand(|) | call expand(|
  394. <
  395. ------------------------------------------------------------------------------
  396. 3.4 SMART QUOTES *delimitMateSmartQuotes*
  397. Only one quote will be inserted following a quote, a "\", following or
  398. preceding a keyword character, or when the number of quotes in the current
  399. line is odd. This should cover closing quotes after a string, opening quotes
  400. before a string, escaped quotes and apostrophes. See more details about
  401. customizing this feature on |'delimitMate_smart_quotes'|.
  402. e.g. typing at the "|": >
  403. What | Before | After
  404. =======================================
  405. " | Text | | Text "|"
  406. " | "String| | "String"|
  407. " | let i = "| | let i = "|"
  408. 'm | I| | I'm|
  409. <
  410. ------------------------------------------------------------------------------
  411. 3.4 SMART MATCHPAIRS *delimitMateSmartMatchpairs*
  412. This is similar to "smart quotes", but applied to the characters in
  413. |'delimitMate_matchpairs'|. The difference is that delimitMate will not
  414. auto-close the pair when the regex matches the text on the right of the
  415. cursor. See |'delimitMate_smart_matchpairs'| for more details.
  416. e.g. typing at the "|": >
  417. What | Before | After
  418. =======================================
  419. ( | function| | function(|)
  420. ( | |var | (|var
  421. <
  422. ------------------------------------------------------------------------------
  423. 3.5 BALANCING MATCHING PAIRS *delimitMateBalance*
  424. When inserting an opening paren and |'delimitMate_balance_matchpairs'| is
  425. enabled, delimitMate will try to balance the closing pairs in the current
  426. line.
  427. e.g. typing at the "|": >
  428. What | Before | After
  429. =======================================
  430. ( | | | (|)
  431. ( | |) | (|)
  432. (( | |) | ((|))
  433. <
  434. ------------------------------------------------------------------------------
  435. 3.6 FILE TYPE BASED CONFIGURATION *delimitMateFileType*
  436. delimitMate options can be set globally for all buffers using global
  437. ("regular") variables in your |vimrc| file. But |:autocmd| can be used to set
  438. options for specific file types (see |'filetype'|) using buffer variables in
  439. the following way: >
  440. au FileType mail,text let b:delimitMate_autoclose = 0
  441. ^ ^ ^ ^ ^
  442. | | | | |
  443. | | | | - Option value.
  444. | | | - Option name.
  445. | | - Buffer variable.
  446. | - File types for which the option will be set.
  447. - Don't forget to put this event.
  448. <
  449. NOTE that you should use buffer variables (|b:var|) only to set options with
  450. |:autocmd|, for global options use regular variables (|g:var|) in your vimrc.
  451. ------------------------------------------------------------------------------
  452. 3.7 SYNTAX AWARENESS *delimitMateSyntax*
  453. The features of this plug-in might not be always helpful, comments and strings
  454. usualy don't need auto-completion. delimitMate monitors which region is being
  455. edited and if it detects that the cursor is in a comment it'll turn itself off
  456. until the cursor leaves the comment. The excluded regions can be set using the
  457. option |'delimitMate_excluded_regions'|. Read |group-name| for a list of
  458. regions or syntax group names.
  459. NOTE that this feature relies on a proper syntax file for the current file
  460. type, if the appropiate syntax file doesn't define a region, delimitMate won't
  461. know about it.
  462. ==============================================================================
  463. 4. COMMANDS *delimitMateCommands*
  464. ------------------------------------------------------------------------------
  465. :DelimitMateReload *:DelimitMateReload*
  466. Re-sets all the mappings used for this script, use it if any option has been
  467. changed or if the filetype option hasn't been set yet.
  468. ------------------------------------------------------------------------------
  469. :DelimitMateOn *:DelimitMateOn*
  470. Enable delimitMate mappings.
  471. ------------------------------------------------------------------------------
  472. :DelimitMateOff *:DelimitMateOff*
  473. Disable delimitMate mappings.
  474. ------------------------------------------------------------------------------
  475. :DelimitMateSwitch *:DelimitMateSwitch*
  476. Switches the plug-in on and off.
  477. ------------------------------------------------------------------------------
  478. :DelimitMateTest *:DelimitMateTest*
  479. This command tests every mapping set-up for this script, useful for testing
  480. custom configurations.
  481. The following output corresponds to the default values, it will be different
  482. depending on your configuration. "Open & close:" represents the final result
  483. when the closing delimiter has been inserted, either manually or
  484. automatically, see |delimitMateExpansion|. "Delete:" typing backspace in an
  485. empty pair, see |delimitMateBackspace|. "Exit:" typing a closing delimiter
  486. inside a pair of delimiters, see |delimitMateAutoclose|. "Space:" the
  487. expansion, if any, of space, see |delimitMateExpansion|. "Visual-L",
  488. "Visual-R" and "Visual" shows visual wrapping, see
  489. |delimitMateVisualWrapping|. "Car return:" the expansion of car return, see
  490. |delimitMateExpansion|. The cursor's position at the end of every test is
  491. represented by an "|": >
  492. * AUTOCLOSE:
  493. Open & close: (|)
  494. Delete: |
  495. Exit: ()|
  496. Space: ( |)
  497. Visual-L: (v)
  498. Visual-R: (v)
  499. Car return: (
  500. |)
  501. Open & close: {|}
  502. Delete: |
  503. Exit: {}|
  504. Space: { |}
  505. Visual-L: {v}
  506. Visual-R: {v}
  507. Car return: {
  508. |}
  509. Open & close: [|]
  510. Delete: |
  511. Exit: []|
  512. Space: [ |]
  513. Visual-L: [v]
  514. Visual-R: [v]
  515. Car return: [
  516. |]
  517. Open & close: "|"
  518. Delete: |
  519. Exit: ""|
  520. Space: " |"
  521. Visual: "v"
  522. Car return: "
  523. |"
  524. Open & close: '|'
  525. Delete: |
  526. Exit: ''|
  527. Space: ' |'
  528. Visual: 'v'
  529. Car return: '
  530. |'
  531. Open & close: `|`
  532. Delete: |
  533. Exit: ``|
  534. Space: ` |`
  535. Visual: `v`
  536. Car return: `
  537. |`
  538. <
  539. ==============================================================================
  540. 5. MAPPINGS *delimitMateMappings*
  541. delimitMate doesn't override any existing map, so you may encounter that it
  542. doesn't work as expected because a mapping is missing. In that case, the
  543. conflicting mappings should be resolved by either disabling the conflicting
  544. mapping or creating a custom mappings.
  545. In order to make custom mappings easier and prevent overwritting existing
  546. ones, delimitMate uses the |<Plug>| + |hasmapto()| (|usr_41.txt|) construct
  547. for its mappings.
  548. These are the default mappings for the extra features:
  549. <BS> is mapped to <Plug>delimitMateBS
  550. <S-BS> is mapped to <Plug>delimitMateS-BS
  551. <S-Tab> is mapped to <Plug>delimitMateS-Tab
  552. <C-G>g is mapped to <Plug>delimitMateJumpMany
  553. The rest of the mappings correspond to parens, quotes, CR, Space, etc. and they
  554. depend on the values of the delimitMate options, they have the following form:
  555. <Plug>delimitMate + char
  556. e.g.: for "(":
  557. ( is mapped to <Plug>delimitMate(
  558. e.g.: If you have <CR> expansion enabled, you might want to skip it on pop-up
  559. menus:
  560. imap <expr> <CR> pumvisible()
  561. \ ? "\<C-Y>"
  562. \ : "<Plug>delimitMateCR"
  563. ==============================================================================
  564. 6. FUNCTIONS *delimitMateFunctions*
  565. ------------------------------------------------------------------------------
  566. delimitMate#WithinEmptyPair() *delimitMate#WithinEmptyPair()*
  567. Returns 1 if the cursor is inside an empty pair, 0 otherwise.
  568. e.g.: >
  569. inoremap <expr> <CR> delimitMate#WithinEmptyPair() ?
  570. \ "<Plug>delimitMateCR" :
  571. \ "external_mapping"
  572. <
  573. ------------------------------------------------------------------------------
  574. delimitMate#ShouldJump() *delimitMate#ShouldJump()*
  575. Returns 1 if there is a closing delimiter or a quote to the right of the
  576. cursor, 0 otherwise.
  577. ------------------------------------------------------------------------------
  578. delimitMate#JumpAny() *delimitMate#JumpAny()*
  579. This function returns a mapping that will make the cursor jump to the right
  580. when delimitMate#ShouldJump() returns 1, returns the argument "key" otherwise.
  581. e.g.: You can use this to create your own mapping to jump over any delimiter.
  582. >
  583. inoremap <expr> <C-Tab> delimitMate#JumpAny()
  584. <
  585. ==============================================================================
  586. 7. AUTOCOMMANDS *delimitMateAutocmds*
  587. delimitMate emits 2 |User| autocommands to make it easier for users to
  588. leverage delimitMate's support for per-filetype customization.
  589. ------------------------------------------------------------------------------
  590. delimitMate_map *delimitMate_map*
  591. This |User| event is emittted just prior to delimitMate defining its
  592. buffer-local key mappings. You can use this command to define your own
  593. mappings that are disabled when delimitMate is turned off or excludes the
  594. current filetype.
  595. >
  596. au User delimitMate_map call s:delimitMate_map()
  597. function s:delimitMate_map()
  598. imap <buffer><expr> <C-Tab> delimitMate#JumpAny()
  599. endfunction
  600. <
  601. ------------------------------------------------------------------------------
  602. delimitMate_unmap *delimitMate_unmap*
  603. This |User| event is emitted just after delimitMate clears its buffer-local
  604. key mappings. You can use this command to clear your own mappings that you set
  605. in response to |delimitMate_map|.
  606. >
  607. au User delimitMate_unmap call s:delimitMate_unmap()
  608. function s:delimitMate_unmap()
  609. silent! iunmap <buffer> <C-Tab>
  610. endfunction
  611. <
  612. Note: This event may be emitted before |delimitMate_map|, and may be emitted
  613. multiple times in a row without any intervening |delimitMate_map| events.
  614. ==============================================================================
  615. 8. TODO LIST *delimitMateTodo*
  616. - Automatic set-up by file type.
  617. - Make block-wise visual wrapping work on un-even regions.
  618. ==============================================================================
  619. 9. MAINTAINER *delimitMateMaintainer*
  620. Hi there! My name is Israel Chauca F. and I can be reached at:
  621. mailto:israelchauca@gmail.com
  622. Feel free to send me any suggestions and/or comments about this plugin, I'll
  623. be very pleased to read them.
  624. ==============================================================================
  625. 10. CREDITS *delimitMateCredits*
  626. Contributors: ~
  627. - Kim Silkebækken ~
  628. Fixed mappings being echoed in the terminal.
  629. - Eric Van Dewoestine ~
  630. Implemented smart matchpairs.
  631. Some of the code that makes this script was modified or just shamelessly
  632. copied from the following sources:
  633. - Ian McCracken ~
  634. Post titled: Vim, Part II: Matching Pairs:
  635. http://concisionandconcinnity.blogspot.com/
  636. - Aristotle Pagaltzis ~
  637. From the comments on the previous blog post and from:
  638. http://gist.github.com/144619
  639. - Karl Guertin ~
  640. AutoClose:
  641. http://www.vim.org/scripts/script.php?script_id=1849
  642. - Thiago Alves ~
  643. AutoClose:
  644. http://www.vim.org/scripts/script.php?script_id=2009
  645. - Edoardo Vacchi ~
  646. ClosePairs:
  647. http://www.vim.org/scripts/script.php?script_id=2373
  648. This script was inspired by the auto-completion of delimiters on TextMate.
  649. ==============================================================================
  650. 11. HISTORY *delimitMateHistory*
  651. Version Date Release notes ~
  652. |---------|------------|-----------------------------------------------------|
  653. 2.8 2013-07-15 * Current release:
  654. - Add :DelimitMateOn & :DelimitMateOff.
  655. |---------|------------|-----------------------------------------------------|
  656. 2.7 2013-07-15 * - Lots of bug fixes.
  657. - Add delimitMate_offByDefault.
  658. - Add delimitMate_eol_marker.
  659. - Reduce the number of mappings.
  660. - Stop using setline().
  661. - Better handling of nested quotes.
  662. - Allow a custom pattern for smart_quotes.
  663. |---------|------------|-----------------------------------------------------|
  664. 2.6 2011-01-14 * - Add smart_matchpairs feature.
  665. - Add mapping to jump over contiguous delimiters.
  666. - Fix behaviour of b:loaded_delimitMate.
  667. |---------|------------|-----------------------------------------------------|
  668. 2.5.1 2010-09-30 * - Remove visual wrapping. Surround.vim offers a much
  669. better implementation.
  670. - Minor mods to DelimitMateTest.
  671. |---------|------------|-----------------------------------------------------|
  672. 2.5 2010-09-22 * - Better handling of mappings.
  673. - Add report for mappings in |:DelimitMateTest|.
  674. - Allow the use of "|" and multi-byte characters in
  675. |'delimitMate_quotes'| and |'delimitMate_matchpairs'|.
  676. - Allow commands to be concatenated using |.
  677. |---------|------------|-----------------------------------------------------|
  678. 2.4.1 2010-07-31 * - Fix problem with <Home> and <End>.
  679. - Add missing doc on |'delimitMate_smart_quotes'|,
  680. |delimitMateBalance| and
  681. |'delimitMate_balance_matchpairs'|.
  682. |---------|------------|-----------------------------------------------------|
  683. 2.4 2010-07-29 * - Unbalanced parens: see :help delimitMateBalance.
  684. - Visual wrapping now works on block-wise visual
  685. with some limitations.
  686. - Arrow keys didn't work on terminal.
  687. - Added option to allow nested quotes.
  688. - Expand Smart Quotes to look for a string on the
  689. right of the cursor.
  690. |---------|------------|-----------------------------------------------------|
  691. 2.3.1 2010-06-06 * - Fix: an extra <Space> is inserted after <Space>
  692. expansion.
  693. |---------|------------|-----------------------------------------------------|
  694. 2.3 2010-06-06 * - Syntax aware: Will turn off when editing comments
  695. or other regions, customizable.
  696. - Changed format of most mappings.
  697. - Fix: <CR> expansion doesn't break automatic
  698. indentation adjustments anymore.
  699. - Fix: Arrow keys would insert A, B, C or D instead
  700. of moving the cursor when using Vim on a terminal.
  701. |---------|------------|-----------------------------------------------------|
  702. 2.2 2010-05-16 * - Added command to switch the plug-in on and off.
  703. - Fix: some problems with <Left>, <Right> and <CR>.
  704. - Fix: A small problem when inserting a delimiter at
  705. the beginning of the line.
  706. |---------|------------|-----------------------------------------------------|
  707. 2.1 2010-05-10 * - Most of the functions have been moved to an
  708. autoload script to avoid loading unnecessary ones.
  709. - Fixed a problem with the redo command.
  710. - Many small fixes.
  711. |---------|------------|-----------------------------------------------------|
  712. 2.0 2010-04-01 * New features:
  713. - All features are redo/undo-wise safe.
  714. - A single quote typed after an alphanumeric
  715. character is considered an apostrophe and one
  716. single quote is inserted.
  717. - A quote typed after another quote inserts a single
  718. quote and the cursor jumps to the middle.
  719. - <S-Tab> jumps out of any empty pair.
  720. - <CR> and <Space> expansions are fixed, but the
  721. functions used for it are global and can be used in
  722. custom mappings. The previous system is still
  723. active if you have any of the expansion options
  724. set.
  725. - <S-Backspace> deletes the closing delimiter.
  726. * Fixed bug:
  727. - s:vars were being used to store buffer options.
  728. |---------|------------|-----------------------------------------------------|
  729. 1.6 2009-10-10 * Now delimitMate tries to fix the balancing of single
  730. quotes when used as apostrophes. You can read
  731. |delimitMate_apostrophes| for details.
  732. Fixed an error when |b:delimitMate_expand_space|
  733. wasn't set but |delimitMate_expand_space| wasn't.
  734. |---------|------------|-----------------------------------------------------|
  735. 1.5 2009-10-05 * Fix: delimitMate should work correctly for files
  736. passed as arguments to Vim. Thanks to Ben Beuchler
  737. for helping to nail this bug.
  738. |---------|------------|-----------------------------------------------------|
  739. 1.4 2009-09-27 * Fix: delimitMate is now enabled on new buffers even
  740. if they don't have set the file type option or were
  741. opened directly from the terminal.
  742. |---------|------------|-----------------------------------------------------|
  743. 1.3 2009-09-24 * Now local options can be used along with autocmd
  744. for specific file type configurations.
  745. Fixes:
  746. - Unnamed register content is not lost on visual
  747. mode.
  748. - Use noremap where appropiate.
  749. - Wrapping a single empty line works as expected.
  750. |---------|------------|-----------------------------------------------------|
  751. 1.2 2009-09-07 * Fixes:
  752. - When inside nested empty pairs, deleting the
  753. innermost left delimiter would delete all right
  754. contiguous delimiters.
  755. - When inside an empty pair, inserting a left
  756. delimiter wouldn't insert the right one, instead
  757. the cursor would jump to the right.
  758. - New buffer inside the current window wouldn't
  759. have the mappings set.
  760. |---------|------------|-----------------------------------------------------|
  761. 1.1 2009-08-25 * Fixed an error that ocurred when mapleader wasn't
  762. set and added support for GetLatestScripts
  763. auto-detection.
  764. |---------|------------|-----------------------------------------------------|
  765. 1.0 2009-08-23 * Initial upload.
  766. |---------|------------|-----------------------------------------------------|
  767. `\|||/´ MMM \|/ www __^__ ~
  768. (o o) (o o) @ @ (O-O) /(o o)\\ ~
  769. ooO_(_)_Ooo__ ooO_(_)_Ooo___oOO_(_)_OOo___oOO__(_)__OOo___oOO__(_)__OOo_____ ~
  770. _____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
  771. __|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_ ~
  772. _____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____ ~
  773. vim:tw=78:et:ts=8:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent: