expand_cr.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #
  2. %d
  3. filetype indent on
  4. set bs=2 et sts=4 sw=4 ft=javascript
  5. call setline(1, '$(document).ready(function() {})')
  6. DelimitMateReload
  7. exec "normal 31|i\<CR>x\<Esc>"
  8. ================================================================================
  9. $(document).ready(function() {
  10. x
  11. })
  12. --------------------------------------------------------------------------------
  13. # Issue #95
  14. new
  15. let b:delimitMate_jump_expansion = 1
  16. DelimitMateReload
  17. exec "normal i(\<CR>test)x"
  18. ================================================================================
  19. (
  20. test
  21. )x
  22. --------------------------------------------------------------------------------
  23. # Remove CR expansion on BS
  24. %d
  25. exec "normal i(\<CR>\<BS>x"
  26. ================================================================================
  27. (x)
  28. --------------------------------------------------------------------------------
  29. # Consider indentation with BS inside an empty CR expansion.
  30. %d
  31. exec "normal i( \<CR>\<BS>\<BS>x"
  32. ================================================================================
  33. (x)
  34. --------------------------------------------------------------------------------
  35. # Conflict with indentation settings (cindent). Issue #95
  36. se cindent
  37. call setline(1, ['sub foo {',' while (1) {', ' ', ' }', '}'])
  38. call cursor(3, 8)
  39. normal a}x
  40. ================================================================================
  41. sub foo {
  42. while (1) {
  43. }x
  44. }
  45. --------------------------------------------------------------------------------
  46. %d
  47. call setline(1, '"{bracketed}')
  48. normal A"x
  49. ================================================================================
  50. "{bracketed}"x
  51. --------------------------------------------------------------------------------
  52. # Syntax folding enabled by autocmd breaks expansion. But ti can't be tested
  53. # with :normal
  54. new
  55. autocmd InsertEnter * let w:fdm=&foldmethod | setl foldmethod=manual
  56. autocmd InsertLeave * let &foldmethod = w:fdm
  57. set foldmethod=marker
  58. set foldmarker={,}
  59. set foldlevel=0
  60. set backspace=2
  61. exec "normal iabc {\<CR>x"
  62. ================================================================================
  63. abc {
  64. x
  65. }
  66. --------------------------------------------------------------------------------
  67. # expand_cr != 2
  68. %d_
  69. call setline(1, 'abc(def)')
  70. exec "normal $i\<CR>x"
  71. ================================================================================
  72. abc(def
  73. x)
  74. --------------------------------------------------------------------------------
  75. # expand_cr == 2
  76. %d_
  77. let delimitMate_expand_cr = 2
  78. DelimitMateReload
  79. call setline(1, 'abc(def)')
  80. exec "normal $i\<CR>x"
  81. ================================================================================
  82. abc(def
  83. x
  84. )
  85. --------------------------------------------------------------------------------
  86. # Play nice with smartindent
  87. %d_
  88. set all&
  89. set smartindent
  90. exec "normal $i{\<CR>x"
  91. ================================================================================
  92. {
  93. x
  94. }
  95. --------------------------------------------------------------------------------