Test for *sub-replace-special* and *sub-replace-expression* on :substitute. Test for submatch() on :substitue. Test for *:s%* on :substitute. Test for :s replacing \n with line break. STARTTEST :so small.vim ENDTEST Results of test71: STARTTEST :set magic :set cpo& /^TEST/ j:s/A/&&/ j:s/B/\&/ j:s/C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\0\9\8\7\6\5\4\3\2\1/ j:s/D/d/ j:s/E/~/ j:s/F/\~/ j:s/G/\ugg/ j:s/H/\Uh\Eh/ j:s/I/\lII/ j:s/J/\LJ\EJ/ j:s/K/\Uk\ek/ j:s/L/ / j:s/M/\r/ j:s/N/\ / j:s/O/\n/ j:s/P/\b/ j:s/Q/\t/ j:s/R/\\/ j:s/S/\c/ j:s/T// j:s/U/\L\uuUu\l\EU/ j:s/V/\U\lVvV\u\Ev/ ENDTEST TEST_1: A B C123456789 D E F G H I J K lLl mMm nNn oOo pPp qQq rRr sSs tTt U V STARTTEST :set nomagic :set cpo& /^TEST/ j:s/A/&&/ j:s/B/\&/ j:s/\mC\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\0\9\8\7\6\5\4\3\2\1/ j:s/D/d/ j:s/E/~/ j:s/F/\~/ j:s/G/\ugg/ j:s/H/\Uh\Eh/ j:s/I/\lII/ j:s/J/\LJ\EJ/ j:s/K/\Uk\ek/ j:s/L/ / j:s/M/\r/ j:s/N/\ / j:s/O/\n/ j:s/P/\b/ j:s/Q/\t/ j:s/R/\\/ j:s/S/\c/ j:s/T// j:s/U/\L\uuUu\l\EU/ j:s/V/\U\lVvV\u\Ev/ ENDTEST TEST_2: A B C123456789 D E F G H I J K lLl mMm nNn oOo pPp qQq rRr sSs tTt U V STARTTEST :set magic& :set cpo& /^TEST/ j:s/A/\='\'/ j:s/B/\='\\'/ j:s/C/\=' '/ j:s/D/\='\ '/ j:s/E/\='\\ '/ j:s/F/\='\r'/ j:s/G/\=''/ j:s/H/\='\'/ j:s/I/\='\\'/ j:s/J/\='\n'/ j:s/K/\="\r"/ j:s/L/\="\n"/ ENDTEST TEST_3: aAa bBb cCc dDd eEe fFf gGg hHh iIi jJj kKk lLl STARTTEST :set magic& :set cpo& /^TEST/ j:s/A/\=substitute(submatch(0), '.', '\', '')/ j:s/B/\=substitute(submatch(0), '.', '\\', '')/ j:s/C/\=substitute(submatch(0), '.', ' ', '')/ j:s/D/\=substitute(submatch(0), '.', '\ ', '')/ j:s/E/\=substitute(submatch(0), '.', '\\ ', '')/ j:s/F/\=substitute(submatch(0), '.', '\r', '')/ j:s/G/\=substitute(submatch(0), '.', '', '')/ j:s/H/\=substitute(submatch(0), '.', '\', '')/ j:s/I/\=substitute(submatch(0), '.', '\\', '')/ j:s/J/\=substitute(submatch(0), '.', '\n', '')/ j:s/K/\=substitute(submatch(0), '.', "\r", '')/ j:s/L/\=substitute(submatch(0), '.', "\n", '')/ ENDTEST TEST_4: aAa bBb cCc dDd eEe fFf gGg hHh iIi jJj kKk lLl STARTTEST :set magic& :set cpo& /^TEST/ j:s/A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\=submatch(0) . submatch(9) . submatch(8) . submatch(7) . submatch(6) . submatch(5) . submatch(4) . submatch(3) . submatch(2) . submatch(1)/ j:s/B\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\=string([submatch(0, 1), submatch(9, 1), submatch(8, 1), submatch(7, 1), submatch(6, 1), submatch(5, 1), submatch(4, 1), submatch(3, 1), submatch(2, 1), submatch(1, 1)])/ ENDTEST TEST_5: A123456789 B123456789 STARTTEST :set magic& /^TEST/ :set cpo+=/ j:s/A/a/ j:s/B/%/ :set cpo-=/ j:s/C/c/ j:s/D/%/ ENDTEST TEST_6: A B C D STARTTEST :set magic& :set cpo& /^TEST_7/ j:s/A./\=submatch(0)/ j:s/B./\=submatch(0)/ j:s/C./\=strtrans(string(submatch(0, 1)))/ j:s/D.\nD/\=strtrans(string(submatch(0, 1)))/ j:s/E\_.\{-}E/\=strtrans(string(submatch(0, 1)))/ /^Q$ :s/Q[^\n]Q/\=submatch(0)."foobar"/ :" Avoid :s error breaks dotest map on Windows. ENDTEST TEST_7: A A BB CC D D E E Q Q STARTTEST :function! TitleString() let check = 'foo' =~ 'bar' return "" endfunction :set titlestring=%{TitleString()} :/^test_one/s/.*/\="foo\nbar"/ :/^test_two/s/.*/\="foo\nbar"/c y ENDTEST test_one test_two STARTTEST :g/^STARTTEST/.,/^ENDTEST/d :1;/^Results/,$wq! test.out :call getchar() ENDTEST