Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Using the repeat command (`.`) after inserting a tab does nothing

Open cloudranger opened this issue 7 years ago • 14 comments

Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT

What happened: after inserting a tab, the . key cannot be used to repeat the last command (but repeat works for any other character, it seems to be only tab which does not work)

What did you expect to happen: I expected the . to insert a tab for me

How to reproduce it (as minimally and precisely as possible): position to start of a line of text i [tab] [ESC] position to start of next line . (to repeat last command) nothing happens.

Environment:

  • Extension Name: vim
  • Extension Version: 0.10.13
  • OS Version: Linux x64 4.4.0-38-generic
  • VSCode version: 1.19.1

cloudranger avatar Jan 27 '18 17:01 cloudranger

Probably related, number prefixes don't work with tab - 5i<Tab><Esc> inserts one tab, not five.

parkovski avatar Feb 06 '18 18:02 parkovski

So interestingly, it's only if <tab> is the only type of action performed. iabc<tab><esc>. works as expected.

Chillee avatar Feb 08 '18 20:02 Chillee

Yep, just the tab on its own. So you can't repeat inserting a tab on its own. Any other character in there and it works just fine. Also, from the comment above by @parkovski, using a number prefix inserts only one tab as he says, but if you then use the repeat command (.) no tab is inserted but the cursor marches backwards one character

cloudranger avatar Feb 08 '18 21:02 cloudranger

For me, . is just altogether broken right now. Do anything in insert mode, switch to normal mode with Esc, hit ., and nothing happens.

rnewman avatar Feb 13 '18 21:02 rnewman

@rnewman That's a separate bug, one that I can't replicate at least. Could you open up a new issue, and post any errors you might have in your dev console? (Help > Toggle Developer Tools)

Chillee avatar Feb 14 '18 00:02 Chillee

This behaviour seems consistent with vanilla VIM. In VIM, if I go i<tab><esc>., it doesn't re-insert <tab>.

However, I can repro the case where 5i<Tab><Esc> is indeed not supported on this extension.

jpoon avatar Feb 20 '18 05:02 jpoon

Thats interesting.

I have been using vi and vim for the last 30 years on a variety of unix platforms and it has always worked for me.

I have just tried it now on Ubuntu 16.04 LTS (vim 7.4.1689), Debian 8 (Jessie) (vim 7.4.576) and Mac OS 10.11.6 (vim 7.3) and re-insert of tab works on all of them.

So what version of vanilla vim are you using and on which platform ?

cloudranger avatar Feb 20 '18 17:02 cloudranger

It's something to do with indent handling. Trailing tab indents are not repeated.

Vim 8.0.1420, Mac, launched with vim --clean -v:

  • i<Space><Space><Esc>. inserts four spaces.
  • i<Tab><Esc>. does not insert two tabs; only one remains.
  • i<Tab>a<Esc>. inserts two tabs: \t\taa.
  • ia<Tab><Esc>. inserts aa\t (note a single trailing tab — the first one inserted).

rnewman avatar Feb 20 '18 17:02 rnewman

It is because we do not handle the same as a

https://github.com/VSCodeVim/Vim/blob/5fe14b435ba7879d7c2fdd00d69a11a5c0a553e4/src/actions/commands/insert.ts#L218

So we never capture it as a documentChangeEvent, hmm

xconverge avatar Jul 01 '18 19:07 xconverge

Can we just enable that handling? In vim, if you use tab to autocomplete or whatever, the "repeat" command respects the insertion as it should. In fact, overriding this to do anything else breaks the semantics of the dot command altogether (which really should just repeat whatever you just did).

edit: It occurs to me that a setting to enable the behavior would work too.

jeremyong avatar Aug 04 '20 16:08 jeremyong

i've noticed that

itypesomestuff<esc>...

goes to insert mode, types 'typesomestuff' and repeats as expected

however...

itypesomestuff<esc><esc>...

does not repeat.

it seems that . repeats the esc and i believe it should not. in neovim, for example, it does not.

jkassis avatar Jul 30 '21 18:07 jkassis

ahhh... looks like i remapped escape to also run :nohl. maybe this is happening for others? everyone check your mappings?

jkassis avatar Jul 30 '21 18:07 jkassis

I'm also having this issue, it's been open since 2018? Any way to get this fixed?

tonhe avatar Jul 25 '23 15:07 tonhe

I am seeing this problem as well. Really makes it difficult to tab indent a large block of existing code.

jwlv avatar Jan 23 '24 18:01 jwlv