046_multi_line_regexps_spec.lua 984 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. -- vim: set foldmethod=marker foldmarker=[[,]] :
  2. -- Tests for multi-line regexps with ":s"
  3. local n = require('test.functional.testnvim')()
  4. local clear, feed, insert = n.clear, n.feed, n.insert
  5. local expect = n.expect
  6. describe('multi-line regexp', function()
  7. setup(clear)
  8. it('is working', function()
  9. insert([[
  10. 1 aa
  11. bb
  12. cc
  13. 2 dd
  14. ee
  15. 3 ef
  16. gh
  17. 4 ij
  18. 5 a8
  19. 8b c9
  20. 9d
  21. 6 e7
  22. 77f
  23. xxxxx]])
  24. -- Test if replacing a line break works with a back reference
  25. feed([[:/^1/,/^2/s/\n\(.\)/ \1/<cr>]])
  26. -- Test if inserting a line break works with a back reference
  27. feed([[:/^3/,/^4/s/\(.\)$/\r\1/<cr>]])
  28. -- Test if replacing a line break with another line break works
  29. feed([[:/^5/,/^6/s/\(\_d\{3}\)/x\1x/<cr>]])
  30. expect([[
  31. 1 aa bb cc 2 dd ee
  32. 3 e
  33. f
  34. g
  35. h
  36. 4 i
  37. j
  38. 5 ax8
  39. 8xb cx9
  40. 9xd
  41. 6 ex7
  42. 7x7f
  43. xxxxx]])
  44. end)
  45. end)