On 2025-06-29, K otgc wrote:
> Yes, my query is originally regarding Shift+>, which seemed to be the only way
> to indent a block of code.
> Tab and spacebar would work on individual lines, but not highlighted blocks.
> Ultimately, I need the block to indent 2 spaces to match previous code's
> indentation so the code and file functions.
> How to indent highlight code is the main question then, regardless if it's
> Spacebar, Tab or Shift+>.
> According to :h 30.5, spacebar is best practice, to avoid trouble with programs
> that use a different tabstop value.
> However having to manually spacebar multiple lines in my highlighted block is
> time consuming and manually messy.
I think you are confusing the space bar with the space character.
Indenting with space characters is recommended, but that does not
mean you have to hit the space bar repeatedly at the start of every
line. Vim can do most indentation for you automatically. Reading
":help 30.3" may help you with that.
Regards,
Gary
--
--
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/20250629130511.GE24703%40phoenix.
Sunday, June 29, 2025
Re: Indent block inline with other blocks is too far
Yes, my query is originally regarding Shift+>, which seemed to be the only way to indent a block of code. --
--
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/6d010cfd-3417-4823-a3af-c888c5cf2da0n%40googlegroups.com.
Tab and spacebar would work on individual lines, but not highlighted blocks.
Ultimately, I need the block to indent 2 spaces to match previous code's indentation so the code and file functions.
How to indent highlight code is the main question then, regardless if it's Spacebar, Tab or Shift+>.
According to :h 30.5, spacebar is best practice, to avoid trouble with programs that use a different tabstop value.
However having to manually spacebar multiple lines in my highlighted block is time consuming and manually messy.
For now, tabs have been set to 2 spaces, which has carried over to the Shift+> functionality.
On Sunday, 29 June 2025 at 07:47:53 UTC+2 Christian Brabandt wrote:
Hi,There is extensive documentation and guidance around how to use tabs in the user manual at:h 30.5ThanksChrisAm 28.06.2025 um 09:20 schrieb K otgc <kontheg...@gmail.com>:Just entering :set sw=2 in .vimrc leaves tabbing at 8 spaces.The post 27 Jun 2025, 15:25:24 with 3 lines of code, is the only code that works to affect tabbing at 2 spaces.On Friday, 27 June 2025 at 18:30:52 UTC+2 Gary Johnson wrote:On 2025-06-27, K otgc wrote:
> Hello,
> I'm indenting a code block by highlighting the block and then selecting the
> greater than key.
> However this indents the block 8 spaces, which is too far past the other code
> blocks, which are only 2 spaces indented.
> I am using version: VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 02 2025
> 16:39:51)
> Is there a way to adust the indent please?
Yes. As someone else wrote, see
help >
help 'sw'
and just execute, or put in your vimrc,
:set sw=2
Regards,
Gary
--
--
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+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/71db5174-cd0d-43fe-812f-918f719733f7n%40googlegroups.com.
--
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/6d010cfd-3417-4823-a3af-c888c5cf2da0n%40googlegroups.com.
Saturday, June 28, 2025
Re: Indent block inline with other blocks is too far
Hi,
There is extensive documentation and guidance around how to use tabs in the user manual at
:h 30.5
Thanks
Chris
Am 28.06.2025 um 09:20 schrieb K otgc <konthegoldcoast@gmail.com>:
Just entering :set sw=2 in .vimrc leaves tabbing at 8 spaces.The post 27 Jun 2025, 15:25:24 with 3 lines of code, is the only code that works to affect tabbing at 2 spaces.--On Friday, 27 June 2025 at 18:30:52 UTC+2 Gary Johnson wrote:On 2025-06-27, K otgc wrote:
> Hello,
> I'm indenting a code block by highlighting the block and then selecting the
> greater than key.
> However this indents the block 8 spaces, which is too far past the other code
> blocks, which are only 2 spaces indented.
> I am using version: VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 02 2025
> 16:39:51)
> Is there a way to adust the indent please?
Yes. As someone else wrote, see
help >
help 'sw'
and just execute, or put in your vimrc,
:set sw=2
Regards,
Gary
--
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/71db5174-cd0d-43fe-812f-918f719733f7n%40googlegroups.com.
Re: Indent block inline with other blocks is too far
On 2025-06-28, K otgc wrote:
> Just entering :set sw=2 in .vimrc leaves tabbing at 8 spaces.
> The post�27 Jun 2025, 15:25:24 with 3 lines of code,�is the only code that
> works to affect tabbing at 2 spaces.
In your original post, you didn't mention tabs--you asked about >,
which is a shift operator.
There are two schools of thought about tabs. One is that tabs
should always be 8 columns for consistency and portability. The
other is that tabs should be the same as the shift width. Neither
is right or wrong, just different preferences.
Regards,
Gary
--
--
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/20250628202515.GD24703%40phoenix.
> Just entering :set sw=2 in .vimrc leaves tabbing at 8 spaces.
> The post�27 Jun 2025, 15:25:24 with 3 lines of code,�is the only code that
> works to affect tabbing at 2 spaces.
In your original post, you didn't mention tabs--you asked about >,
which is a shift operator.
There are two schools of thought about tabs. One is that tabs
should always be 8 columns for consistency and portability. The
other is that tabs should be the same as the shift width. Neither
is right or wrong, just different preferences.
Regards,
Gary
--
--
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/20250628202515.GD24703%40phoenix.
Re: Indent block inline with other blocks is too far
Noice, good mana and potions your way :-)
--
--
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/075a24c8-e4b4-4477-a639-951e35208947n%40googlegroups.com.
On Saturday, 28 June 2025 at 10:41:47 UTC+2 dva...@internode.on.net wrote:
On 27.06.25 06:25, K otgc wrote:> I ended up using the below, but unsure which of the 3 choices is easiest.> The Tab doesn't indent a highlighted block, so I need the Shift+> to indent> the highlighted lines. Fortunately Shift+> seems to use the Tab spacing> amount.> set expandtab> set tabstop=2> set shiftwidth=2They are not separate choices, but elements of one choice.set tabstop=2 shiftwidth=2changes from default to a 2-space width, whileset expandtabavoids it all coming undone when you share the file with someone with some other tabstop setting. It does that by inserting 2 spaces instead of a tab, thus protecting your code from foreign interference.set autoindentis productivity enhancing, as you can then hit <tab> on the first line inside a block to indent it, and subsequent lines in the block will automatically hold that indentation, without you having to find the mouse and faff with it.A quick way to outdent after the block is to hit ^D on the first line after, e.g. the closing '}'in C. It isn't even necessary to remember to do it before typing the post-block line - the ^D also outdents any time while you're still in insert mode on the line.In this way, you type your way through the indented block, then back out again, without moving your hands from the keyboard - no slowing for the curve, at all.Erik
--
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/075a24c8-e4b4-4477-a639-951e35208947n%40googlegroups.com.
Re: Indent block inline with other blocks is too far
On 27.06.25 06:25, K otgc wrote:
> I ended up using the below, but unsure which of the 3 choices is easiest.
> The Tab doesn't indent a highlighted block, so I need the Shift+> to indent
> the highlighted lines. Fortunately Shift+> seems to use the Tab spacing
> amount.
> set expandtab
> set tabstop=2
> set shiftwidth=2
They are not separate choices, but elements of one choice.
set tabstop=2 shiftwidth=2
changes from default to a 2-space width, while
set expandtab
avoids it all coming undone when you share the file with someone with some other tabstop setting. It does that by inserting 2 spaces instead of a tab, thus protecting your code from foreign interference.
set autoindent
is productivity enhancing, as you can then hit <tab> on the first line inside a block to indent it, and subsequent lines in the block will automatically hold that indentation, without you having to find the mouse and faff with it.
A quick way to outdent after the block is to hit ^D on the first line after, e.g. the closing '}'in C. It isn't even necessary to remember to do it before typing the post-block line - the ^D also outdents any time while you're still in insert mode on the line.
In this way, you type your way through the indented block, then back out again, without moving your hands from the keyboard - no slowing for the curve, at all.
Erik
--
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/56af4924-2553-4bbe-8fea-10997aefabb9%40localhost.
Re: Indent block inline with other blocks is too far
Just entering :set sw=2 in .vimrc leaves tabbing at 8 spaces.
--
--
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/71db5174-cd0d-43fe-812f-918f719733f7n%40googlegroups.com.
The post 27 Jun 2025, 15:25:24 with 3 lines of code, is the only code that works to affect tabbing at 2 spaces.
On Friday, 27 June 2025 at 18:30:52 UTC+2 Gary Johnson wrote:
On 2025-06-27, K otgc wrote:
> Hello,
> I'm indenting a code block by highlighting the block and then selecting the
> greater than key.
> However this indents the block 8 spaces, which is too far past the other code
> blocks, which are only 2 spaces indented.
> I am using version: VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 02 2025
> 16:39:51)
> Is there a way to adust the indent please?
Yes. As someone else wrote, see
help >
help 'sw'
and just execute, or put in your vimrc,
:set sw=2
Regards,
Gary
--
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/71db5174-cd0d-43fe-812f-918f719733f7n%40googlegroups.com.
Friday, June 27, 2025
Re: Indent block inline with other blocks is too far
On 2025-06-27, K otgc wrote:
> Hello,
> I'm indenting a code block by highlighting the block and then selecting the
> greater than key.
> However this indents the block 8 spaces, which is too far past the other code
> blocks, which are only 2 spaces indented.
> I am using version: VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 02 2025
> 16:39:51)
> Is there a way to adust the indent please?
Yes. As someone else wrote, see
help >
help 'sw'
and just execute, or put in your vimrc,
:set sw=2
Regards,
Gary
--
--
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/20250627163144.GC24703%40phoenix.
> Hello,
> I'm indenting a code block by highlighting the block and then selecting the
> greater than key.
> However this indents the block 8 spaces, which is too far past the other code
> blocks, which are only 2 spaces indented.
> I am using version: VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 02 2025
> 16:39:51)
> Is there a way to adust the indent please?
Yes. As someone else wrote, see
help >
help 'sw'
and just execute, or put in your vimrc,
:set sw=2
Regards,
Gary
--
--
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/20250627163144.GC24703%40phoenix.
Re: Indent block inline with other blocks is too far
Thank you.
--
--
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/8439a1b5-f8a1-4856-b981-193737fc701dn%40googlegroups.com.
I ended up using the below, but unsure which of the 3 choices is easiest.
The Tab doesn't indent a highlighted block, so I need the Shift+> to indent the highlighted lines. Fortunately Shift+> seems to use the Tab spacing amount.
set expandtab
set tabstop=2
set shiftwidth=2
On Friday, 27 June 2025 at 13:17:57 UTC+2 Paul wrote:
Check out `:help 'shiftwidth'`.
--
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/8439a1b5-f8a1-4856-b981-193737fc701dn%40googlegroups.com.
Re: Indent block inline with other blocks is too far
Check out `:help 'shiftwidth'`.
--
--
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/aF590LK1slvdyKL4%40kitt.
--
--
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/aF590LK1slvdyKL4%40kitt.
Re: Indent block inline with other blocks is too far
On 27.06.25 02:12, K otgc wrote:
> Hello,
> I'm indenting a code block by highlighting the block and then selecting the
> greater than key.
> However this indents the block 8 spaces, which is too far past the other
> code blocks, which are only 2 spaces indented.
> I am using version: VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 02
> 2025 16:39:51)
> Is there a way to adust the indent please?
In .vimrc, set "tabstop". For a couple of decades, I've had:
set tabstop=3 expandtab ai
as a 3-space tab looks good on an "if" block.
Expanding tabs to an equivalent number of spaces avoids indenting changing when you share the code with someone from last century, still stuck on 8-space tabs.
Setting autoindent (aka ai) causes "Copy indent from current line when starting a new line (typing <CR> in Insert mode or when using the "o" or "O" command)." as ":help ai" explains.
If you also:
set listchars=tab:>-,trail:-
then tabs will be shown as '>', and trailing spaces as '-'. If a shared
file comes back with tabs, rather than being entirely space-expanded,
then that's visible, and you can then expandtab with your tabstop
setting, forcing consistency.
Erik
--
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/19f2ed8d-40cb-4478-84d6-f3a427270943%40localhost.
Indent block inline with other blocks is too far
Hello,
--
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/77b23fb3-8ce3-4a3b-90b3-20db8c1e62cen%40googlegroups.com.
I'm indenting a code block by highlighting the block and then selecting the greater than key.
However this indents the block 8 spaces, which is too far past the other code blocks, which are only 2 spaces indented.
I am using version: VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 02 2025 16:39:51)
Is there a way to adust the indent please?
-- --
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/77b23fb3-8ce3-4a3b-90b3-20db8c1e62cen%40googlegroups.com.
Saturday, June 14, 2025
Re: Vim 9 script question
I found that I had mistakenly removed execute from all Map(.....) portions, causing them to fail to map to actual keys.
https://github.com/seanexplus/vim-unimpaired/commit/f2ef4fa34e01a8b552037c35525a19f15c94826b
I've now completed testing and fixing most of the functionality. During this process, I learned:
Some Vim script patterns that use strings to define actions must be converted to lambda syntax in Vim 9 script, such as filter() and substitute().
https://github.com/seanexplus/vim-unimpaired/commit/fb372df8d17f7e1760ded1d927efcd9e3c629094
When using substitute() in Vim 9 script, if the lambda includes expressions like nr2char(submatch(1)), it must be rewritten as nr2char(str2nr(submatch(1))).
https://github.com/seanexplus/vim-unimpaired/commit/21659e0da4d1acad5a8dbbc100276f426fa2c18f
In Vim script, you can simply use +/- to move to the next/previous line, but in Vim 9 script you must use the cursor() function.
https://github.com/seanexplus/vim-unimpaired/commit/3bf942ff6f39dd77fcca4ed2090fdfafccbf5312
In Vim script, you can operate on registers using @@, but in Vim 9 script you have to use setreg()/getreg().
In Vim script, you can use {funcname}(param) to call function by name, but in Vim 9 script you have to use function(funcname)(param)
Where <sfile> is used in Vim script, <script>/<stack> must be used in Vim 9 script.
https://github.com/seanexplus/vim-unimpaired/commit/01ec3e9eb389081b2f01b364c09e2a731949c11a
Salman Halim <salmanhalim@gmail.com> 於 2025年6月11日 晚上8:45 寫道:Use .. in Vim 9 (mappings 2 and 3 below). Also, you have v.count and v:count. They probably aren't both correct (all of them have that).What happens when you just type the whole thing on the command line directly?SalmanOn Wed, Jun 11, 2025, 08:21 Yu Lang Chiang <seanexplus@gmail.com> wrote:I tried the following combinations:<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.1435Maxim 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.--
--
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/0C87B90E-C27A-466E-B58E-60A4A837C3B4%40gmail.com.
--
--
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/CANuxnEdyMUNHo5ZEBmV_JJm338GtjwpKMSpb6aXOfLb2DApDiw%40mail.gmail.com.
Friday, June 13, 2025
Re: Vim 9 script question
Hello Lang Chiang,
Good to hear your problem is solved!
Could you share with all of us
- exactly where the problem's root cause was, and
- the how of way it was resolved?
I am sure that would benefit many of us.
Thank you,
Eric
On 2025-06-12 05:16, Yu Lang Chiang wrote:
--I've identified that the root cause was in another part of the code, and it's now resolved. Thank you all for your assistance.
Salman Halim <salmanhalim@gmail.com> 於 2025年6月11日 週三 下午8:45寫道:
--Use .. in Vim 9 (mappings 2 and 3 below). Also, you have v.count and v:count. They probably aren't both correct (all of them have that).
What happens when you just type the whole thing on the command line directly?
Salman
On Wed, Jun 11, 2025, 08:21 Yu Lang Chiang <seanexplus@gmail.com> wrote:
I tried the following combinations:--
<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.
--
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/0C87B90E-C27A-466E-B58E-60A4A837C3B4%40gmail.com.
--
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/CANuxnEdyMUNHo5ZEBmV_JJm338GtjwpKMSpb6aXOfLb2DApDiw%40mail.gmail.com.
--
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/CALZ2XgjzgUjmDeHC%3D2TJUyYzg1zfKx%2BdzAy84FRZFZjPv%3DThjA%40mail.gmail.com.
Thursday, June 12, 2025
Re: Vim 9 script question
I've identified that the root cause was in another part of the code, and it's now resolved. Thank you all for your assistance.
Salman Halim <salmanhalim@gmail.com> 於 2025年6月11日 週三 下午8:45寫道:
--Use .. in Vim 9 (mappings 2 and 3 below). Also, you have v.count and v:count. They probably aren't both correct (all of them have that).What happens when you just type the whole thing on the command line directly?SalmanOn Wed, Jun 11, 2025, 08:21 Yu Lang Chiang <seanexplus@gmail.com> wrote:I tried the following combinations:--<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.1435Maxim 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.
--
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/0C87B90E-C27A-466E-B58E-60A4A837C3B4%40gmail.com.
--
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/CANuxnEdyMUNHo5ZEBmV_JJm338GtjwpKMSpb6aXOfLb2DApDiw%40mail.gmail.com.
--
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/CALZ2XgjzgUjmDeHC%3D2TJUyYzg1zfKx%2BdzAy84FRZFZjPv%3DThjA%40mail.gmail.com.
Wednesday, June 11, 2025
Re: Vim 9 script question
Use .. in Vim 9 (mappings 2 and 3 below). Also, you have v.count and v:count. They probably aren't both correct (all of them have that).
What happens when you just type the whole thing on the command line directly?
Salman
On Wed, Jun 11, 2025, 08:21 Yu Lang Chiang <seanexplus@gmail.com> wrote:
I tried the following combinations:--<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.1435Maxim 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.
--
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/0C87B90E-C27A-466E-B58E-60A4A837C3B4%40gmail.com.
--
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/CANuxnEdyMUNHo5ZEBmV_JJm338GtjwpKMSpb6aXOfLb2DApDiw%40mail.gmail.com.
Subscribe to:
Posts (Atom)