annotate src/testdir/test_gn.vim @ 23304:e438ec7ffd5d

Added tag v8.2.2197 for changeset 9af15022894c85b0c050d2e61fbbc327b2882c0e
author Bram Moolenaar <Bram@vim.org>
date Wed, 23 Dec 2020 13:00:05 +0100
parents 381bd66762ea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test for gn command
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_gn_command()
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
4 noautocmd new
16376
3b5d401a58ce patch 8.1.1193: typos and small problems in test files
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
5 " replace a single char by itself quoted:
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 call setline('.', 'abc x def x ghi x jkl')
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
7 let @/ = 'x'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 exe "norm! cgn'x'\<esc>.."
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 call assert_equal("abc 'x' def 'x' ghi 'x' jkl", getline('.'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 sil! %d_
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
11
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " simple search match
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call setline('.', 'foobar')
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
14 let @/ = 'foobar'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 exe "norm! gncsearchmatch"
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call assert_equal('searchmatch', getline('.'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
18
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 " replace a multi-line match
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call setline('.', ['', 'one', 'two'])
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
21 let @/ = 'one\_s*two\_s'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 exe "norm! gnceins\<CR>zwei"
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal(['','eins','zwei'], getline(1,'$'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
25
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 " test count argument
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call setline('.', ['', 'abcdx | abcdx | abcdx'])
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
28 let @/ = '[a]bcdx'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 exe "norm! 2gnd"
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 call assert_equal(['','abcdx | | abcdx'], getline(1,'$'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
32
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 " join lines
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 call setline('.', ['join ', 'lines'])
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
35 let @/ = '$'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 exe "norm! 0gnd"
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 call assert_equal(['join lines'], getline(1,'$'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
39
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 " zero-width match
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 call setline('.', ['', 'zero width pattern'])
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
42 let @/ = '\>\zs'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 exe "norm! 0gnd"
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 call assert_equal(['', 'zerowidth pattern'], getline(1,'$'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
46
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 " delete first and last chars
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call setline('.', ['delete first and last chars'])
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
49 let @/ = '^'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 exe "norm! 0gnd$"
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
51 let @/ = '\zs'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 exe "norm! gnd"
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 call assert_equal(['elete first and last char'], getline(1,'$'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
55
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 " using visual mode
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 call setline('.', ['', 'uniquepattern uniquepattern'])
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 exe "norm! /[u]niquepattern/s\<cr>vlgnd"
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 call assert_equal(['', ' uniquepattern'], getline(1,'$'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
61
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 " backwards search
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 call setline('.', ['my very excellent mother just served us nachos'])
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
64 let @/ = 'mother'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 exe "norm! $cgNmongoose"
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 call assert_equal(['my very excellent mongoose just served us nachos'], getline(1,'$'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
68
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 " search for single char
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 call setline('.', ['','for (i=0; i<=10; i++)'])
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
71 let @/ = 'i'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 exe "norm! cgnj"
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 call assert_equal(['','for (j=0; i<=10; i++)'], getline(1,'$'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
75
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 " search hex char
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 call setline('.', ['','Y'])
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 set noignorecase
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
79 let @/ = '\%x59'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 exe "norm! gnd"
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 call assert_equal(['',''], getline(1,'$'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
83
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 " test repeating gdn
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 call setline('.', ['', '1', 'Johnny', '2', 'Johnny', '3'])
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
86 let @/ = 'Johnny'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 exe "norm! dgn."
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 call assert_equal(['','1', '', '2', '', '3'], getline(1,'$'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
90
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 " test repeating gUgn
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 call setline('.', ['', '1', 'Depp', '2', 'Depp', '3'])
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
93 let @/ = 'Depp'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 exe "norm! gUgn."
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 call assert_equal(['', '1', 'DEPP', '2', 'DEPP', '3'], getline(1,'$'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
97
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 " test using look-ahead assertions
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 call setline('.', ['a:10', '', 'a:1', '', 'a:20'])
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
100 let @/ = 'a:0\@!\zs\d\+'
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 exe "norm! 2nygno\<esc>p"
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 call assert_equal(['a:10', '', 'a:1', '1', '', 'a:20'], getline(1,'$'))
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 sil! %d _
11488
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
104
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
105 " test using nowrapscan
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
106 set nowrapscan
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
107 call setline(1, 'foo bar baz')
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
108 exe "norm! /bar/e\<cr>"
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
109 exe "norm! gnd"
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
110 call assert_equal(['foo baz'], getline(1,'$'))
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
111 sil! %d_
9473793c7bb5 patch 8.0.0627: "gn" selects only one character with 'nowrapscan'
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
112
12539
6d3584b60170 patch 8.0.1148: gN doesn't work on last match with 'wrapscan' off
Christian Brabandt <cb@256bit.org>
parents: 11488
diff changeset
113 " search upwards with nowrapscan set
6d3584b60170 patch 8.0.1148: gN doesn't work on last match with 'wrapscan' off
Christian Brabandt <cb@256bit.org>
parents: 11488
diff changeset
114 call setline('.', ['foo', 'bar', 'foo', 'baz'])
6d3584b60170 patch 8.0.1148: gN doesn't work on last match with 'wrapscan' off
Christian Brabandt <cb@256bit.org>
parents: 11488
diff changeset
115 set nowrapscan
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
116 let @/ = 'foo'
12539
6d3584b60170 patch 8.0.1148: gN doesn't work on last match with 'wrapscan' off
Christian Brabandt <cb@256bit.org>
parents: 11488
diff changeset
117 $
6d3584b60170 patch 8.0.1148: gN doesn't work on last match with 'wrapscan' off
Christian Brabandt <cb@256bit.org>
parents: 11488
diff changeset
118 norm! dgN
6d3584b60170 patch 8.0.1148: gN doesn't work on last match with 'wrapscan' off
Christian Brabandt <cb@256bit.org>
parents: 11488
diff changeset
119 call assert_equal(['foo', 'bar', '', 'baz'], getline(1,'$'))
6d3584b60170 patch 8.0.1148: gN doesn't work on last match with 'wrapscan' off
Christian Brabandt <cb@256bit.org>
parents: 11488
diff changeset
120 sil! %d_
6d3584b60170 patch 8.0.1148: gN doesn't work on last match with 'wrapscan' off
Christian Brabandt <cb@256bit.org>
parents: 11488
diff changeset
121
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
122 " search using the \zs atom
21552
cbc570e66d11 patch 8.2.1326: Vim9: skipping over white space after list
Bram Moolenaar <Bram@vim.org>
parents: 20199
diff changeset
123 call setline(1, [' nnoremap', '', 'nnoremap'])
14000
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
124 set wrapscan&vim
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
125 let @/ = '\_s\zsnnoremap'
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
126 $
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
127 norm! cgnmatch
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
128 call assert_equal([' nnoremap', '', 'match'], getline(1,'$'))
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
129 sil! %d_
96933f0ecbd1 patch 8.1.0018: using "gn" may select wrong text when wrapping
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
130
18426
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
131 " make sure it works correctly for one-char wide search items
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
132 call setline('.', ['abcdefghi'])
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
133 let @/ = 'a'
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
134 exe "norm! 0fhvhhgNgU"
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
135 call assert_equal(['ABCDEFGHi'], getline(1,'$'))
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
136 call setline('.', ['abcdefghi'])
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
137 let @/ = 'b'
18500
c0445cb7cfe0 patch 8.1.2244: 'wrapscan' is not used for "gn"
Bram Moolenaar <Bram@vim.org>
parents: 18448
diff changeset
138 " this gn wraps around the end of the file
18426
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
139 exe "norm! 0fhvhhgngU"
18500
c0445cb7cfe0 patch 8.1.2244: 'wrapscan' is not used for "gn"
Bram Moolenaar <Bram@vim.org>
parents: 18448
diff changeset
140 call assert_equal(['aBCDEFGHi'], getline(1,'$'))
18426
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
141 sil! %d _
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
142 call setline('.', ['abcdefghi'])
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
143 let @/ = 'f'
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
144 exe "norm! 0vllgngU"
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
145 call assert_equal(['ABCDEFghi'], getline(1,'$'))
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
146 sil! %d _
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
147 call setline('.', ['12345678'])
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
148 let @/ = '5'
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
149 norm! gg0f7vhhhhgnd
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
150 call assert_equal(['12348'], getline(1,'$'))
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
151 sil! %d _
18448
35e0ab1f2975 patch 8.1.2218: "gN" is off by one in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 18426
diff changeset
152 call setline('.', ['12345678'])
35e0ab1f2975 patch 8.1.2218: "gN" is off by one in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 18426
diff changeset
153 let @/ = '5'
35e0ab1f2975 patch 8.1.2218: "gN" is off by one in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 18426
diff changeset
154 norm! gg0f2vf7gNd
35e0ab1f2975 patch 8.1.2218: "gN" is off by one in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 18426
diff changeset
155 call assert_equal(['1678'], getline(1,'$'))
35e0ab1f2975 patch 8.1.2218: "gN" is off by one in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 18426
diff changeset
156 sil! %d _
20199
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
157 set wrapscan&vim
18426
3b80bdbdc832 patch 8.1.2207: "gn" doesn't work quite right
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
158
20199
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
159 " Without 'wrapscan', in visual mode, running gn without a match should fail
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
160 " but the visual mode should be kept.
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
161 set nowrapscan
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
162 call setline('.', 'one two')
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
163 let @/ = 'one'
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
164 call assert_beeps('normal 0wvlgn')
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
165 exe "normal y"
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
166 call assert_equal('tw', @")
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
167
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
168 " with exclusive selection, run gn and gN
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
169 set selection=exclusive
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
170 normal 0gny
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
171 call assert_equal('one', @")
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
172 normal 0wgNy
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
173 call assert_equal('one', @")
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18500
diff changeset
174 set selection&
22549
5055805908f5 patch 8.2.1823: "gN" does not select the matched string
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
175 endfunc
5055805908f5 patch 8.2.1823: "gN" does not select the matched string
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
176
5055805908f5 patch 8.2.1823: "gN" does not select the matched string
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
177 func Test_gN_repeat()
5055805908f5 patch 8.2.1823: "gN" does not select the matched string
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
178 new
5055805908f5 patch 8.2.1823: "gN" does not select the matched string
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
179 call setline(1, 'this list is a list with a list of a list.')
5055805908f5 patch 8.2.1823: "gN" does not select the matched string
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
180 /list
5055805908f5 patch 8.2.1823: "gN" does not select the matched string
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
181 normal $gNgNgNx
5055805908f5 patch 8.2.1823: "gN" does not select the matched string
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
182 call assert_equal('list with a list of a list', @")
5055805908f5 patch 8.2.1823: "gN" does not select the matched string
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
183 bwipe!
5055805908f5 patch 8.2.1823: "gN" does not select the matched string
Bram Moolenaar <Bram@vim.org>
parents: 21552
diff changeset
184 endfunc
9647
847518911c0b commit https://github.com/vim/vim/commit/6835dc61aebca2b602d85a9d63c449ace58683b4
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185
22578
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
186 func Test_gN_then_gn()
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
187 new
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
188
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
189 call setline(1, 'this list is a list with a list of a last.')
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
190 /l.st
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
191 normal $gNgNgnx
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
192 call assert_equal('last', @")
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
193
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
194 call setline(1, 'this list is a list with a lust of a last.')
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
195 /l.st
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
196 normal $gNgNgNgnx
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
197 call assert_equal('lust of a last', @")
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
198
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
199 bwipe!
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
200 endfunc
381bd66762ea patch 8.2.1837: using "gn" after "gN" does not work
Bram Moolenaar <Bram@vim.org>
parents: 22549
diff changeset
201
15239
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
202 func Test_gn_multi_line()
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
203 new
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
204 call setline(1, [
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
205 \ 'func Tm1()',
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
206 \ ' echo "one"',
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
207 \ 'endfunc',
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
208 \ 'func Tm2()',
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
209 \ ' echo "two"',
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
210 \ 'endfunc',
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
211 \ 'func Tm3()',
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
212 \ ' echo "three"',
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
213 \ 'endfunc',
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
214 \])
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
215 /\v^func Tm\d\(\)\n.*\zs".*"\ze$
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
216 normal jgnrx
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
217 call assert_equal(' echo xxxxx', getline(5))
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
218 bwipe!
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
219 endfunc
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 14000
diff changeset
220
9909
3ee84d270ea7 commit https://github.com/vim/vim/commit/9e4d8215d386100ab660d7d11e6620fd148b605e
Christian Brabandt <cb@256bit.org>
parents: 9647
diff changeset
221 " vim: shiftwidth=2 sts=2 expandtab