-1

I am editing tab-delimited data in a plaintext file (that was originally a spreadsheet) and I'd like to quickly jump forward to the next entry, the character after the next "tab" character.

So far the closest I've gotten is /\t/e+1. This works pretty well except that if comes to a blank entry - just a tab character with no word afterwards - the cursor appears at the end of the blank region rather than at the beginning.

Is there a good built-in method for this? Is there a way to make the cursor appear at the beginning of the tab for blank entries?

0
0

I don't think there is a built-in way to do it. Usual way is to map your own key to do what you want. In your case it might be something like:

nnoremap g<tab> /\t\zs\S<CR>

The difference to your regex is \zs\S meaning that it matches till \zs but actual match is the following part of regex \S (non-whitespace). And you don't have to specify e+1 option as it matches on the first non whitespace after a tab.

If you want to stop at any char, use . instead of \S:

nnoremap g<tab> /\t\zs.<CR>
1
  • 1
    you might want to add an operator-pending mapping? Sep 30 '21 at 17:03
0

You got a mapping answer, so I will just concentrate on the second part of your question:

Is there a way to make the cursor appear at the beginning of the tab for blank entries?

By default, the cursor will always be put on the end of a tab. You can switch it off, by setting :set list together with some nice tab highlighting: :set listchars=nbsp:χ,conceal:·,tab:>—,trail:•,precedes:…,extends:…,eol:¶

But there is no way to make this happen depending on the following character.

(originally from here: https://vi.stackexchange.com/a/2242/71)

0

If you can live with the fact that you would be able to position the cursor beyond the end of a line, you can

set virtualedit=all

One effect of this is that you are able to put the cursor halfway into a tab. Consequently, /\t/e+1 would put the cursor at the start of the second of two consecutive tabs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.