neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

046_multi_line_regexps_spec.lua (984B)


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