Update 2024-12-15 14:45 OpenBSD/amd64-t14

This commit is contained in:
c0dev0id
2024-12-15 14:45:59 +01:00
parent beac7b226a
commit 6d6f0e9a46
66 changed files with 12003 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Marko Nimac
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,44 @@
# traces.vim
## Overview
This plugin highlights patterns and ranges for Ex commands in Command-line mode.
It also provides live preview for `:substitute`.
## Requirements
### Vim 8.1
or
### Neovim 0.2.3
## Feature comparison
**Note**: some of the features provided by this plugin are already present in Vim/Neovim.
| | traces.vim | Vim | Neovim |
|--------------------------------------------------------------| :----------: | :---------------: | :---------------: |
| `:substitute` preview | ✓ | | ✓ |
| pattern preview for `:substitute` | ✓ | ✓<sup>[1]</sup> | ✓ |
| pattern preview for `:global`, `:vglobal`, `:sort` | ✓ | ✓<sup>[1]</sup> | ✓<sup>[2]</sup> |
| pattern preview for `:vimgrep` | | ✓<sup>[1]</sup> | ✓<sup>[2]</sup> |
| off-screen results window for `:substitute` | ✓ | | ✓ |
| off-screen results window for `:global`, `:vglobal`, `:sort` | ✓ | | |
| range preview | ✓ | | |
[1] added by patch [v8.1.0271](https://github.com/vim/vim/commit/b0acacd767a2b0618a7f3c08087708f4329580d0)
[2] available in Neovim [0.5.0](https://github.com/neovim/neovim/pull/12721)
## Example
![example](img/traces_example.gif?raw=true)
## Installation
Use plugin/runtimepath manager of choice or install manually with the following command:
### Linux
`git clone --depth 1 https://github.com/markonm/traces.vim ~/.vim/pack/plugins/start/traces.vim`
### Windows
`git clone --depth 1 https://github.com/markonm/traces.vim %HOMEPATH%/vimfiles/pack/plugins/start/traces.vim`
## Inspiration
- [vim-over](https://github.com/osyo-manga/vim-over)
- [incsearch.vim](https://github.com/haya14busa/incsearch.vim)
- [inccommand](https://neovim.io/doc/user/options.html#'inccommand')
- [nvim-incnormal](https://github.com/bfredl/nvim-incnormal)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,216 @@
*traces.txt* Range, pattern and substitute preview for Vim
Version 1.1.0
CONTENTS *traces-contents*
1. Introduction |traces-introduction|
2. Requirements |traces-requirements|
3. Options |traces-options|
|g:traces_enabled|
|g:traces_preserve_view_state|
|g:traces_substitute_preview|
|g:traces_skip_modifiers|
|g:traces_num_range_preview|
|g:traces_timeout|
|g:traces_search_timeout|
|g:traces_preview_window|
|g:traces_abolish_integration|
|g:traces_normal_preview|
4. Highlights |traces-highlights|
|hl-TracesSearch|
|hl-TracesReplace|
5. Bugs |traces-bugs|
6. Changelog |traces-changelog|
==============================================================================
INTRODUCTION *traces-introduction*
This plugin highlights |pattern|s and |:range|s for Ex commands in
Command-line mode.
Ranges composed of at least one pattern or mark specifier will be highlighted
immediately. Ranges that do not include any pattern or mark specifier will
not be highlighted because they cannot be uniquely identified as ranges
related to buffer lines (see |:command-addr|).
To force immediate preview for ranges composed entirely of absolute specifiers
({number}, ., $, %), first enter and delete '/' or some other pattern or mark
specifier. Also see |g:traces_num_range_preview|.
Patterns for the following Ex commands will be highlighted immediately as
typed:
|:substitute|
|:smagic|
|:snomagic|
|:global|
|:vglobal|
|:sort|
Live preview is implemented for the following Ex commands:
|:substitute|
|:smagic|
|:snomagic|
|:normal|
==============================================================================
REQUIREMENTS *traces-requirements*
Vim 8.1
or
Neovim 0.2.3
==============================================================================
OPTIONS *traces-options*
*g:traces_enabled*
g:traces_enabled boolean (default 1)
If value is 0, this plugin will be disabled and no
highlighting will be done.
*g:traces_preserve_view_state*
g:traces_preserve_view_state boolean (default 0)
If value is 1, view position will not be changed when
highlighting ranges or patterns outside initial view position.
*g:traces_substitute_preview*
g:traces_substitute_preview boolean (default 1)
If value is 1, |:substitute|, |:smagic| and |:snomagic| will
be previewed.
*g:traces_skip_modifiers*
g:traces_skip_modifiers boolean (default 1)
If value is 1, |cdo|, |cfdo|, |ldo|, |lfdo|, |bufdo|, |tabdo|,
|argdo| and |windo| will be ignored when processing command
line.
*g:traces_num_range_preview*
g:traces_num_range_preview boolean (default 0)
If value is 1, numerical ranges :N, and :N; will be
highlighted immediately.
Highlighted: >
:10,
:10;15
<
Not highlighted: >
:10
<
*g:traces_timeout*
g:traces_timeout number (default 1000)
If preview is slower than the timeout (in milliseconds), it
gets disabled until Command-line mode is entered again. Time
spent saving undo history is ignored. Cannot be lower than
200.
*g:traces_search_timeout*
g:traces_search_timeout number (default 500)
If searching is slower than the timeout (in milliseconds), it
gets disabled until new character is passed to Command-line.
Cannot be higher than |g:traces_timeout|.
*g:traces_preview_window*
g:traces_preview_window string (default empty)
Window used to show off-screen matches.
Set the option to Ex command which will be used to open a new
window. Use a combination of Ex commands |:new| or |:vnew| and
command modifiers |vertical|, |leftabove|, |aboveleft|,
|rightbelow|, |belowright|, |topleft| and |botright|. Prepend
"new" or "vnew" with a number to specify height or width of the
window. Preview window is opened only when selected range
exceeds visible viewport.
Example: >
let g:traces_preview_window = "botright 10new"
let g:traces_preview_window = "vertical botright new"
let g:traces_preview_window = "topleft 15new"
<
As a fallback the string is evaluated with |eval()| which
permits the following:
Example: >
" If window width is greater than 160 columns, open vertical
" window or else open horizontal window
let g:traces_preview_window =
\ "winwidth('%') > 160 ? 'bot vnew' : 'bot 10new'"
<
*g:traces_abolish_integration*
g:traces_abolish_integration boolean (default 0)
If value is 1, |:Subvert| from abolish.vim will be previewed.
*g:traces_normal_preview*
g:traces_normal_preview boolean (default 0)
WARNING: experimental, unstable
The following actions performed during the preview might break
the preview or lose the undo history.
- opening, closing or switching buffers or windows
If value is 1, |:normal| will be previewed.
Requires patch 8.2.2961 on Vim.
==============================================================================
HIGHLIGHTS *traces-highlights*
*hl-TracesSearch*
TracesSearch Search pattern highlighting. Links to |hl-Search| by default.
*hl-TracesReplace*
TracesReplace Substitute string highlighting. Links to |hl-TracesSearch| by
default.
Example: >
highlight link TracesSearch Cursor
highlight link TracesReplace DiffAdd
<
==============================================================================
BUGS *traces-bugs*
- highlighting is disabled for |:terminal| windows because of redrawing
issues
- If you have any problems or suggestions, please let me know at:
https://github.com/markonm/traces.vim
==============================================================================
CHANGELOG *traces-changelog*
1.1.0 January 21, 2019 *traces-changelog-1.1.0*
- New options
- |g:traces_num_range_preview|
- |g:traces_enabled|
- Pattern preview for |:sort|
- Various bugs fixed
1.0.0 April 30, 2018 *traces-changelog-1.0.0*
- Substitute preview
- Use |CmdlineChanged| event
- New options
- |g:traces_substitute_preview|
- |g:traces_skip_modifiers|
- Deprecated options
- |g:traces_whole_file_range|
- New highlight group |hl-TracesSearch|
- Various bugs fixed
0.1.0 December 21, 2017 *traces-changelog-0.1.0*
- Increased Vim/Neovim requirements
- Use |CmdlineEnter| and |CmdlineLeave| events
- Disable |hlsearch| when highlighting patterns
- Highlight all windows that contain current buffer
- New options
- |g:traces_whole_file_range|
- |g:traces_preserve_view_state|
- Various bugs fixed
0.0.0 September 18, 2017 *traces-changelog-0.0.0*
- Initial version.
==============================================================================
vim:tw=78:ts=8:ft=help:norl:fen:fdl=0:fdm=marker:

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

View File

@@ -0,0 +1,114 @@
if !exists('##CmdlineEnter') || exists('g:loaded_traces_plugin') || !has('timers') || &cp
finish
endif
let g:loaded_traces_plugin = 1
let s:cpo_save = &cpo
set cpo&vim
let g:traces_enabled = get(g:, 'traces_enabled', 1)
let g:traces_preserve_view_state = get(g:, 'traces_preserve_view_state')
let g:traces_substitute_preview = get(g:, 'traces_substitute_preview', 1)
let g:traces_normal_preview = get(g:, 'traces_normal_preview', 0)
let g:traces_num_range_preview = get(g:, 'traces_num_range_preview', 0)
let g:traces_skip_modifiers = get(g:, 'traces_skip_modifiers', 1)
let g:traces_preview_window = get(g:, 'traces_preview_window', '')
let g:traces_abolish_integration = get(g:, 'traces_abolish_integration', 0)
let s:view = {}
function! s:track_cmdl(...) abort
let current_cmdl = getcmdline()
if get(s:, 'previous_cmdl', '') !=# current_cmdl
let s:previous_cmdl = current_cmdl
call traces#init(current_cmdl, s:view)
endif
endfunction
function! s:cmdline_changed() abort
if exists('s:start_init_timer')
call timer_stop(s:start_init_timer)
endif
let s:start_init_timer = timer_start(1, {_-> traces#init(getcmdline(), s:view)})
endfunction
function! s:create_cmdl_changed_au(...) abort
augroup traces_augroup_cmdline_changed
autocmd!
autocmd CmdlineChanged : call s:cmdline_changed()
augroup END
" necessary when entering command line that has already been populated with
" text from mappings
call s:cmdline_changed()
endfunction
function! s:t_start() abort
if !g:traces_enabled || mode(1) =~# '^c.' || &buftype ==# 'terminal'
return
endif
if exists('##CmdlineChanged')
let s:track_cmdl_timer = timer_start(30,function('s:create_cmdl_changed_au'))
else
let s:track_cmdl_timer = timer_start(30,function('s:track_cmdl'),{'repeat':-1})
endif
endfunction
function! s:t_stop() abort
if exists('s:previous_cmdl')
unlet s:previous_cmdl
endif
if exists('s:track_cmdl_timer')
call timer_stop(s:track_cmdl_timer)
unlet s:track_cmdl_timer
endif
if exists('s:start_init_timer')
call timer_stop(s:start_init_timer)
unlet s:start_init_timer
endif
augroup traces_augroup_cmdline_changed
autocmd!
augroup END
endfunction
silent! cnoremap <unique> <expr> <c-r><c-w> traces#check_b() ? traces#get_cword() : "\<c-r>\<c-w>"
silent! cnoremap <unique> <expr> <c-r><c-a> traces#check_b() ? traces#get_cWORD() : "\<c-r>\<c-a>"
silent! cnoremap <unique> <expr> <c-r><c-f> traces#check_b() ? traces#get_cfile() : "\<c-r>\<c-f>"
silent! cnoremap <unique> <expr> <c-r><c-p> traces#check_b() ? traces#get_pfile() : "\<c-r>\<c-p>"
silent! cnoremap <unique> <expr> <c-r><c-r><c-w> traces#check_b() ? "\<c-r>\<c-r>=traces#get_cword()\<cr>" : "\<c-r>\<c-r>\<c-w>"
silent! cnoremap <unique> <expr> <c-r><c-r><c-a> traces#check_b() ? "\<c-r>\<c-r>=traces#get_cWORD()\<cr>" : "\<c-r>\<c-r>\<c-a>"
silent! cnoremap <unique> <expr> <c-r><c-r><c-f> traces#check_b() ? "\<c-r>\<c-r>=traces#get_cfile()\<cr>" : "\<c-r>\<c-r>\<c-f>"
silent! cnoremap <unique> <expr> <c-r><c-r><c-p> traces#check_b() ? "\<c-r>\<c-r>=traces#get_pfile()\<cr>" : "\<c-r>\<c-r>\<c-p>"
silent! cnoremap <unique> <expr> <c-r><c-o><c-w> traces#check_b() ? "\<c-r>\<c-r>=traces#get_cword()\<cr>" : "\<c-r>\<c-o>\<c-w>"
silent! cnoremap <unique> <expr> <c-r><c-o><c-a> traces#check_b() ? "\<c-r>\<c-r>=traces#get_cWORD()\<cr>" : "\<c-r>\<c-o>\<c-a>"
silent! cnoremap <unique> <expr> <c-r><c-o><c-f> traces#check_b() ? "\<c-r>\<c-r>=traces#get_cfile()\<cr>" : "\<c-r>\<c-o>\<c-f>"
silent! cnoremap <unique> <expr> <c-r><c-o><c-p> traces#check_b() ? "\<c-r>\<c-r>=traces#get_pfile()\<cr>" : "\<c-r>\<c-o>\<c-p>"
augroup traces_augroup
autocmd!
autocmd CmdlineEnter,CmdwinLeave : call s:t_start()
autocmd CmdlineLeave,CmdwinEnter : call s:t_stop()
autocmd CmdlineLeave : if mode(1) is 'c' | call traces#cmdl_leave() | endif
" s:view is used to restore correct view when entering command line from
" visual mode
autocmd CursorMoved * let s:view = extend(winsaveview(), {'mode': mode()})
" 'incsearch' is not compatible with traces.vim, turn it off for : command-line
" https://github.com/vim/vim/commit/b0acacd767a2b0618a7f3c08087708f4329580d0
" https://github.com/neovim/neovim/pull/12721/commits/e8a8b9ed08405c830a049c4e43910c5ce9cdb669
autocmd CmdlineEnter,CmdwinLeave : let s:incsearch = &incsearch
\| noautocmd let &incsearch = 0
autocmd CmdlineLeave,CmdwinEnter : if exists('s:incsearch') | noautocmd let &incsearch = s:incsearch | endif
if exists('+inccommand')
" 'inccommand' is not compatible with traces.vim, turn it off
" https://github.com/neovim/neovim/commit/7215d356949bf07960cc3a3d8b83772635d729d0
autocmd CmdlineEnter : noautocmd let &inccommand = ''
endif
augroup END
highlight default link TracesSearch Search
highlight default link TracesReplace TracesSearch
highlight default link TracesCursor TracesSearch
let &cpo = s:cpo_save
unlet s:cpo_save

View File

@@ -0,0 +1,764 @@
Execute (Setup):
Save g:traces_preserve_view_state, g:traces_substitute_preview,
\ &listchars, &hlsearch, &cursorline, &cursorline, &encoding,
\ &winminwidth, &winminheight
let g:traces_preserve_view_state = 0
let g:traces_substitute_preview = 1
let g:traces_normal_preview = 1
let g:traces_skip_modifiers = 1
let g:traces_num_range_preview = 0
let g:traces_preview_window = ''
let g:traces_abolish_integration = 0
function! Group(group) abort
let matches = filter(getmatches(), {idx, val -> val.group == a:group})
if !empty(matches)
return matches[0].pattern
endif
endfunction
let &listchars = 'eol:.'
set encoding=utf-8
After:
call traces#cmdl_leave()
Before:
let g:traces_preserve_view_state = 0
let g:traces_substitute_preview = 1
let g:traces_skip_modifiers = 1
let g:traces_num_range_preview = 0
call clearmatches()
#######################
# Test positioning #
#######################
Given (Ten lines):
1 one
2 two
3 three
4 four
5 five
6 six
7 seven
8 eight
9 nine
10 ten
11 foo/bar
12 foo?bar
13 \
14 four
Execute (Range):
14
call traces#init('/four', {})
Assert line('.') is 4
Execute (Range):
14
call traces#init('/four/', {})
Assert line('.') is 4
Execute (Range):
14
let @/= 'four'
call traces#init('\/', {})
Assert line('.') is 4
Execute (Range):
set nowrapscan
14
call traces#init('/four/-', {})
Assert line('.') is 14
set wrapscan
Execute (Range):
set nowrapscan
14
let @/= 'four'
call traces#init('\/-', {})
Assert line('.') is 14
set wrapscan
Execute (Range):
1
call traces#init('5;10', winsaveview())
Assert line('.') == 1
Execute (Range):
let g:traces_num_range_preview = 1
1
call traces#init('5;10', winsaveview())
Assert line('.') == 10
Execute (Range):
let g:traces_num_range_preview = 1
1
call traces#init('5;', winsaveview())
Assert line('.') == 5
Execute (Range):
let g:traces_num_range_preview = 1
1
call traces#init('5,', winsaveview())
Assert line('.') == 1
Execute (Range):
1
call traces#init('5,', winsaveview())
Assert line('.') == 1
Execute (Range):
1
call traces#init('5;', winsaveview())
Assert line('.') == 1
Execute (Range):
1
call traces#init('5', winsaveview())
Assert line('.') == 1
Execute (Range):
1
call traces#init('10;5g/', winsaveview())
Assert line('.') == 5
Execute (Range):
1
call traces#init('5;10g/', winsaveview())
Assert line('.') == 10
Execute (Range):
call traces#init('5;10s/.', {})
Assert line('.') == 5
Execute (Range):
call traces#init('5;10s?.', {})
Assert line('.') == 10
Execute (Range):
call traces#init('10;5s/.', {})
Assert line('.') == 5
Execute (Range):
call traces#init('10;5s?.', {})
Assert line('.') == 10
Execute (Range):
call traces#init('/three', {})
Assert line('.') == 3
Execute (Range):
/ten/
call traces#init('?two', {})
Assert line('.') == 2
Execute (Range):
call traces#init('/three/;/eight/', {})
Assert line('.') == 8
Execute (Range):
7
ma m
1
call traces#init('/three/;''m', {})
Assert line('.') == 7
Execute (Range):
call traces#init('/foo\/bar', {})
Assert line('.') == 11
Execute (Range):
call traces#init('/foo\/bar/foobar', {})
Assert line('.') == 11
Execute (Range):
call traces#init('/two/3', {})
Assert line('.') == 5
Execute (Range):
call traces#init('/foo?bar', {})
Assert line('.') == 12
Execute (Range):
call traces#init('?foo\?bar?', {})
Assert line('.') == 12
Execute (Range):
call traces#init('?foo\?bar', {})
Assert line('.') == 12
Execute (Range):
call traces#init('/ten/++', {})
Assert line('.') == 12
call traces#init('', {})
Assert line('.') == 1
Execute (Range):
call traces#init('/one/;11s/five', {})
Assert line('.') == 5
call traces#init('', {})
Assert line('.') == 1
Execute (Range):
call traces#init('/one/;11g/five', {})
Assert line('.') == 5
call traces#init('', {})
Assert line('.') == 1
# test g:traces_preserve_view_state = 1
Execute (Range):
let g:traces_preserve_view_state = 1
call traces#init('/ten/++', {})
Assert line('.') == 1
Execute (Range):
let g:traces_preserve_view_state = 1
call traces#init('/one/;11s/five', {})
Assert line('.') == 1
Execute (Range):
let g:traces_preserve_view_state = 1
call traces#init('/one/;11g/five', {})
Assert line('.') == 1
Execute (Range):
let g:traces_preserve_view_state = 1
call traces#init('g/five', {})
Assert line('.') == 1
Execute (Global, test invalid pattern):
6
call traces#init('g/bazbar', {})
Assert line('.') == 6
Execute (Substitute, test invalid pattern):
6
call traces#init('s/bazbar', {})
Assert line('.') == 6
Execute (Substitute, test invalid pattern):
6
call traces#init('%s/bazbar', {})
Assert line('.') == 6
Execute (Range, test invalid pattern):
6
call traces#init('/bazbar', {})
Assert line('.') == 6
Execute (Range, test invalid pattern):
6
call traces#init('?bazbar', {})
Assert line('.') == 6
Execute (Range, test invalid pattern):
6
call traces#init('?bazbar', {})
Assert line('.') == 6
Execute (Substitute, no range):
11
call traces#init('s/bar', {})
Assert line('.') == 11
Assert col('.') == 9
Given (Ten lines):
1 one
2 two
3 three
4 baz
5 five
6 six
7 seven
8 eight
9 nine
10 baz
11 foo/bar
12 foo?bar
13 \
14 four
Execute (Substitute with range):
6
call traces#init('3;11s/baz', {})
Assert line('.') == 4
Execute (Substitute with range):
6
call traces#init('3;11s?baz', {})
Assert line('.') == 10
Execute (Substitute with range):
6
call traces#init('%s/baz', {})
Assert line('.') == 10
Execute (Substitute with range):
6
call traces#init('%s?baz', {})
Assert line('.') == 4
Execute (Invalid substitute):
6
call traces#init('s/baz', {})
Assert line('.') == 6
#######################
# Test highlighting #
#######################
Given (Ten lines):
1 one
2 two
3 three
4 four
5 five
6 six
7 seven
8 eight
9 nine
10 ten
11 foo/bar
12 foo?bar
13 \
14 four
Execute (Sort):
call traces#init('%sort /\w\+/', {})
AssertEqual '\m\%>0l\%<15l\%(\m\w\+\m\)', Group('TracesSearch')
Execute (Global):
call traces#init('7,/four/g/foobar', {})
AssertEqual '\m\%>3l\%<8l\%(\mfoobar\m\)', Group('TracesSearch')
call traces#init('7,/four/g', {})
AssertEqual 0, Group('TracesSearch')
Execute (Range):
6
call traces#init('/./', {})
AssertEqual '\%>6l\%<8l\_.', Group('Visual')
call traces#init('/.//', {})
AssertEqual '\%>6l\%<8l\_.', Group('Visual')
Execute (Range):
6
call traces#init('?.?', {})
AssertEqual '\%>4l\%<6l\_.', Group('Visual')
call traces#init('?.??', {})
AssertEqual '\%>4l\%<6l\_.', Group('Visual')
Execute (Range):
6
call traces#init('/.', {})
AssertEqual '\%>6l\%<8l\_.', Group('Visual')
call traces#init('/', {})
Assert empty(getmatches())
Execute (Range):
6
call traces#init('?.', {})
AssertEqual '\%>4l\%<6l\_.', Group('Visual')
call traces#init('?', {})
Assert empty(getmatches())
Execute (Range):
6
call traces#init('/ten/;?four', {})
AssertEqual '\m\%>3l\%<5l\%(\mfour\m\)', Group('TracesSearch')
Execute (Range):
6
call traces#init('?.?;?.?;?', {})
AssertEqual '\%>3l\%<5l\_.', Group('Visual')
call traces#init('', {})
Assert empty(getmatches())
Execute (Range):
6
call traces#init('/./;/./;/', {})
AssertEqual '\%>7l\%<9l\_.', Group('Visual')
call traces#init('', {})
Assert empty(getmatches())
Execute (Range):
call traces#init('22;g', {})
AssertEqual 0, Group('Visual')
call traces#init('', {})
Assert empty(getmatches())
Execute (Range):
call traces#init(';+++s/', {})
AssertEqual '\%>0l\%<5l\_.', Group('Visual')
call traces#init('', {})
Assert empty(getmatches())
Execute (Range):
call traces#init('/one/;/eight/', {})
AssertEqual '\%>0l\%<9l\_.', Group('Visual')
call traces#init('', {})
Assert empty(getmatches())
Execute (Range):
call traces#init('1;/eight/', {})
AssertEqual '\%>0l\%<9l\_.', Group('Visual')
Execute (Range):
call traces#init(';/eight/', {})
AssertEqual '\%>0l\%<9l\_.', Group('Visual')
Execute (Range):
call traces#init(',/eight/', {})
AssertEqual '\%>0l\%<9l\_.', Group('Visual')
Execute (Range):
call traces#init(';/eight/;', {})
AssertEqual '\%>7l\%<9l\_.', Group('Visual')
Execute (Range):
call traces#init('3;/seven/', {})
AssertEqual '\%>2l\%<8l\_.', Group('Visual')
Execute (Range):
call traces#init('7;/four/', {})
AssertEqual '\%>6l\%<15l\_.', Group('Visual')
Execute (Range):
call traces#init('7,/four/', {})
AssertEqual '\%>3l\%<8l\_.', Group('Visual')
Execute (Range):
call traces#init('7,/four/s/foobar', {})
AssertEqual '\%>3l\%<8l\_.', Group('Visual')
AssertEqual '\m\%>3l\%<8l\%(\mfoobar\m\)', Group('TracesSearch')
Execute (Global):
call traces#init('7,/four/g/foobar', {})
AssertEqual '\%>3l\%<8l\_.', Group('Visual')
AssertEqual '\m\%>3l\%<8l\%(\mfoobar\m\)', Group('TracesSearch')
Execute (Global):
call traces#init('g/foobar', {})
AssertEqual '\mfoobar', Group('TracesSearch')
Execute (Range):
call traces#init('7;/four/', {})
AssertEqual '\%>6l\%<15l\_.', Group('Visual')
Execute (Substitute):
call traces#init('3;5s/\w\+/foobar', {})
AssertEqual '\%>2l\%<6l\_.', Group('Visual')
Execute (Substitute):
call traces#init('3;5s/\w\+/\r', {})
AssertEqual '\%>2l\%<9l\_.', Group('Visual')
Execute (Substitute):
call traces#init('silent! 3;5s/\w\+/\r', {})
AssertEqual '\%>2l\%<9l\_.', Group('Visual')
Execute (Substitute):
call traces#init('cdo 3;5s/\w\+/\r', {})
AssertEqual '\%>2l\%<9l\_.', Group('Visual')
Execute (Substitute):
call traces#init(':3;5s/\w\+/\r', {})
AssertEqual '\%>2l\%<9l\_.', Group('Visual')
Execute (Substitute):
call traces#init(':::: 3;5s/\w\+/\r', {})
AssertEqual '\%>2l\%<9l\_.', Group('Visual')
Execute (Substitute):
call traces#init('silent! 0;$windo silent! 3;5s/\w\+/\r', {})
AssertEqual '\%>2l\%<9l\_.', Group('Visual')
Execute (Substitute):
let g:traces_skip_modifiers = 0
call traces#init('silent! 0;$windo silent! 3;5s/\w\+/\r', {})
AssertEqual 0, Group('Visual')
Execute (Substitute):
call traces#init('3;5s/\w\+/foobar', {})
AssertEqual '\%>2l\%<6l\_.', Group('Visual')
call traces#init('3;5s', {})
AssertEqual 0, Group('Visual')
Execute (Substitute):
call traces#init('3;5s/\w\+/foobar', {})
AssertEqual '\%>2l\%<6l\_.', Group('Visual')
call traces#init('3;5sgibberish', {})
AssertEqual 0, Group('Visual')
Given (Three paragraphs):
paragraph1
paragraph1
paragraph1
paragraph2
paragraph2
paragraph2
paragraph3
paragraph3
paragraph3
Execute (Substitute):
call traces#init(',''}s', {})
call traces#init(',''}s/', {})
AssertEqual '\%>0l\%<5l\_.', Group('Visual')
#######################
# Test normal #
#######################
Given (Three lines):
one
two
three
Execute (Normal):
call traces#init('%normal! Iline ', {})
Expect:
line one
line two
line three
Execute (Normal):
call cursor(2, 3)
call traces#init('normal! a foobar', {})
Expect:
one
two foobar
three
Execute (Normal):
execute "normal ggVG\<esc>"
call traces#init('''<,''>normal! ve', {})
call traces#cmdl_leave()
call traces#init('''<,''>normal! veA word', {})
Expect:
one word
two word
three word
Execute (Normal with an error):
3d
call traces#init('%normal! isomething:asdf
', {})
call traces#cmdl_leave()
u
Expect:
one
two
three
Execute (Normal with an error):
call traces#init('%normal! vfX', {})
call traces#cmdl_leave()
AssertEqual 'n', mode()
#######################
# Test substitute #
#######################
Given (Zhongwen):
Execute (Substitute, expression with decimal number):
call traces#init('?二?+;/九/-s/\v四|六|一|十/数字/g', {})
Expect:
数字
数字
Given (Three lines):
1
2
3
Execute (Substitute, expression with decimal number):
call traces#init('%s/\d/\=submatch(0) * 0.55', {})
Expect:
0.55
1.1
1.65
Given (Three lines):
foo
foo
foo
Execute (Substitute with a backlash at the end of string):
call traces#init('%s/foo/\', {})
Expect:
\
\
\
Execute (Substitute on first line):
call traces#init('s/foo/bar', {})
Expect:
bar
foo
foo
Execute (Substitute on first and second line):
call traces#init('1;2s/foo/bar', {})
Expect:
bar
bar
foo
Execute (Substitute on every line):
call traces#init('%s/foo/bar', {})
Expect:
bar
bar
bar
Execute (Substitute on every line and revert):
call traces#init('%s/foo/bar', {})
call traces#cmdl_leave()
Expect:
foo
foo
foo
Execute (Turn off substitute preview and try to substitute):
let g:traces_substitute_preview = 0
call traces#init('%s/foo/bar', {})
Expect:
foo
foo
foo
Execute (Substitute and empty command line):
call traces#init('%s/foo/bar', {})
call traces#init('', {})
Expect:
foo
foo
foo
Given (Three lines):
foo.*
Execute (Snomagic):
call traces#init('%snoma/.*/bar', {})
Expect:
foobar
Execute (Smagic):
call traces#init('%sma/.*/bar', {})
Expect:
bar
#######################
# Test settings #
#######################
Given (Three lines):
one
two
three
Execute (Test winminwidth):
let &winminwidth = 0
let &winminheight = 0
call traces#init('%s/.', {})
Execute (Test eol):
let &listchars = ''
call traces#init('1;/three/', {})
AssertEqual '\%>0l\%<4l\(.\|^\)', Group('Visual')
let &listchars = 'eol:.'
Execute (Test hlsearch):
let &hlsearch = 1
call traces#init('1;/three/s/one', {})
AssertEqual &hlsearch, 0
call traces#cmdl_leave()
AssertEqual &hlsearch, 1
Execute (Test cursorcolumn):
let &cursorcolumn = 1
call traces#init('1;/three/s/one', {})
AssertEqual &cursorcolumn, 0
call traces#cmdl_leave()
AssertEqual &cursorcolumn, 1
Execute (Test cursorline):
let &cursorline = 1
call traces#init('1;/three/s/one', {})
AssertEqual &cursorline, 0
call traces#cmdl_leave()
AssertEqual &cursorline, 1
Execute (Test conceallevel):
let &conceallevel = 1
call traces#init('1;/three/s/one/four', {})
AssertEqual &conceallevel, 2
call traces#cmdl_leave()
AssertEqual &conceallevel, 1
Execute (Test concealcursor):
let &concealcursor = 'niv'
call traces#init('1;/three/s/one/four', {})
AssertEqual &concealcursor, 'c'
call traces#cmdl_leave()
AssertEqual &concealcursor, 'niv'
#######################
# Test undo history #
#######################
Execute:
new
AssertEqual undotree().seq_last, 0
call traces#init('s/^/foobar', {})
AssertEqual getline('.'), 'foobar'
call traces#cmdl_leave()
AssertEqual undotree().seq_last, 1
AssertEqual getline('.'), ''
call traces#init('s/^/foobar', {})
AssertEqual getline('.'), 'foobar'
call traces#cmdl_leave()
AssertEqual undotree().seq_last, 1
AssertEqual getline('.'), ''
bd
#######################
# Cleanup #
#######################
Execute (Cleanup):