In Vim normal mode, the 0 command takes you to the first column on the line and ^ takes you to the logical start of line (e.g. the first non-whitespace character). In the regex world, ^ matches the first character on the line, whitespace or not. Does Vim have a pattern that behaves like its '^' command--matching the logical beginning of a line?
Tell me more
×
Super User is a question and answer site for
computer enthusiasts and power users. It's 100% free, no registration required.
|
|
|||
|
|
|
There's no shortcut to match the first non-whitespace character on a line, you have to build the pattern yourself, like:
If you don't want to include the whitespace in your match, you have to use a zero-width assertion, like:
Not exactly pretty, but at least it gets the job done. |
|||
|
|
|
To match the first non-whitespace character, you'd just use If you use For instance, this line starts with a space:
This vim command will remove the leading space:
resulting in the following:
So, the regex will behave as you expect, even if the command doesn't. |
|||||||||||||||||
|