<C-U>exe "" . (v.count ? v:count : "") . "bprevious"<CR>
<C-U>exe "" .. (v.count ? v:count : "") .. "bprevious"<CR>
<C-U>execute "" .. (v.count ? v:count : "") .. "bprevious"<CR>
<C-U>execute "" . (v.count ? v:count : "") . "bprevious"<CR>
None of them work.
Vim has been updated to version 9.1.1435
Maxim Kim <habamax@gmail.com> 於 2025年6月11日 上午11:05 寫道:vim9script enforces spaces between operators, your mappings are defined in vim9script context so it expects spaces between concatenation operator .:<C-U>exe "" . (v.count ? v:count : "") . "bprevious"<CR>On Tuesday, June 3, 2025 at 4:45:56 PM UTC+10 Yu Lang Chiang wrote:Recently I've been trying to learn Vim 9 script by rewriting Vim plugins into Vim 9 script. While attempting to modify *vim-unimpaired*, I discovered that functions related to setting up mappings do not work properly when ported to Vim 9 script. For example, in the `plugin/unimpaired.vim` file, the function `MapNextFamilty` is problematic.
**Original version:**
```vim
execute 'nnoremap <silent> '.prefix.'previous) :<C-U>exe "'.cmd.'previous'.end
execute 'nnoremap <silent> '.prefix.'next) :<C-U>exe "'.cmd.'next'.end
execute 'nnoremap '.prefix.'first) :<C-U><C-R>=v:count ? v:count . "' . a:current . '" : "' . a:cmd . 'first"<CR><CR>' . zv
execute 'nnoremap '.prefix.'last) :<C-U><C-R>=v:count ? v:count . "' . a:current . '" : "' . a:cmd . 'last"<CR><CR>' . zv
execute 'nnoremap <silent> '.map.'Previous :<C-U>exe "'.cmd.'previous'.end
execute 'nnoremap <silent> '.map.'Next :<C-U>exe "'.cmd.'next'.end
execute 'nnoremap <silent> '.map.'First :<C-U>exe "'.cmd.'first'.end
execute 'nnoremap <silent> '.map.'Last a:<C-U>exe "'.cmd.'last'.end
```
**Vim 9 script version:**
```vim
execute 'nnoremap <silent> ' .. prefix .. 'previous) :<C-U>exe "' .. tcmd .. 'previous' .. end
execute 'nnoremap <silent> ' .. prefix .. 'next) :<C-U>exe "' .. tcmd .. 'next' .. end
execute 'nnoremap ' .. prefix .. 'first) :<C-U><C-R>=v:count ? v:count . "' .. current .. '" : "' .. cmd .. 'first"<CR><CR>' .. zv
execute 'nnoremap ' .. prefix .. 'last) :<C-U><C-R>=v:count ? v:count . "' .. current .. '" : "' .. cmd .. 'last"<CR><CR>' .. zv
execute 'nnoremap <silent> ' .. tmap .. 'Previous :<C-U>exe "' .. tcmd .. 'previous' .. end
execute 'nnoremap <silent> ' .. tmap .. 'Next :<C-U>exe "' .. tcmd .. 'next' .. end
execute 'nnoremap <silent> ' .. tmap .. 'First :<C-U>exe "' .. tcmd .. 'first' .. end
execute 'nnoremap <silent> ' .. tmap .. 'Last :<C-U>exe "' .. tcmd .. 'last' .. end
```
When inspecting the mappings using:
```vim
echo maparg('<Plug>('unimpaired-commmand')', 'n')
```
you find that both versions produce identical mappings. For example:
- **Original version:**
```
:<C-U>exe "".(v.count ? v:count : "")."bprevious"<CR>
```
- **Vim 9 script version:**
```
:<C-U>exe "".(v.count ? v:count : "")."bprevious"<CR>
```
Despite the mappings appearing the same, the one defined in the Vim 9 script version does not work. Even after removing `<silent>`, no error messages are reported. Any advice?
**Test Environment:**
- **OS:** Fedora Linux 42 (x86-64)
- **Vim:** 9.1.1418
My repository is https://github.com/seanexplus/vim-unimpaired/tree/master . All vim 9 script rewriting is in vim-9-test branch.--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/98ea42d5-faba-46f9-b642-f1c82d957d71n%40googlegroups.com.
No comments:
Post a Comment