1

I've got a line like this:

* [ ] Find a way to efficiently move a task from one area to another   #8ab879

I want to create a map that selects just "Find a way to efficiently move a task from one area to another" in a visual block. The brackets may or may not be there. The #8ab879 may or may not be there.

Here's what I got:

nnoremap \bw ma^/[A-z]<cr>n:set nohls<cr>v$F#be

Which doesn't quite work (the last bracket is selected) and my method seems awfully convoluted.

1
  • 1
    Just open up a ASCII table and check all characters between A and z or if you are on Linux execute the shell command echo {A..z}. This range also contains [ ] ^ _ and the backtick.
    – Ralf
    May 2 '19 at 7:33
4

Use ^ followed by search()

nnoremap <leader>^ ^:call search('\w', '', line('.'))<cr>

Note: this uses \w which is [A-Za-z0-9_]. You may want to make it just [A-Za-z] for your use case.

For more help see:

:h ^
:h search()
:h line()

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