Sunday, February 7, 2016

Re: tabstop motion

On 2016-02-07 02:32, Christopher Mills wrote:
> The column positions of interest would all be at tabstops, say
> tabstop=2. I want, in normal mode, to "tab over" to the column of
> interest, go into replace mode (R), or virtual replace mode (gR),
> and type data.
>
> In other words I want a tabstop motion.

While it's not a motion, you might want something like

:nnoremap <expr> g<tab> (((col('.') / &ts) + 1) * &ts)."<bar>"
:vnoremap <expr> g<tab> (((col('.') / &ts) + 1) * &ts)."<bar>"
:onoremap <expr> g<tab> (((col('.') / &ts) + 1) * &ts)."<bar>"

which will jump to the next tab-stop, regardless of your 'tabstop'
setting.

I fiddled around a bit to try and get it to accept a count, but my
scripting/mapping-fu is weak. Somehow one would need to replace the
"1" in that mapping with the count that comes from before the command
was issued. I tried wrapping it with the invocation of the
expression-register, but it issued the 'jump to column X" N times,
rather than using that N in the calculation.

If you want to use 'shiftwidth' instead of 'tabstop', just change the
"&ts" to "&sw' throughout

> In normal mode, the tab key appears to be unassigned although the
> Vim Help seems to indicate it should be equivalent to CTRL-I (goto
> newer position in jump list).

This is correct.

> Why isn't the tab key a motion?

I do find this curious. If you do a gross motion, then control+O to
jump back in the jump-list, then control+I (AKA "tab") is indeed a
motion, but Vim doesn't treat it as one. I'm not sure I'd ever want
to do that with the default configuration, but the fact that it moves
the cursor yet can't be used as a motion to an operator surprises me.

-tim


--
--
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.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment