I’ve had this problem many times:
I have a piece of source code, but if I copy and paste it into WordPress and enclose it with the <code>...</code> tags, the beginning spaces are “compressed” into one.
Thus I’d like to know how I could change all the spaces only at the beginning of the line by , so that, for example,
extend: 'Ext.panel.Panel',
becomes
extend: 'Ext.panel.Panel',
There are three approaches to implement the desired edit that I can
see, listed below in the order of my personal preference.
A substitution using the preceding-atom matching syntax
(see
:help \@<=):If brevity of the command is crucial, one can shorten it
using the “very magic” mode (see
:help \v) by changingthe non-capturing group (
:help \%() to a capturing one:A two-staged substitution that splits a line just after the leading
spaces, replaces those spaces, and rejoins that line:
Another two-step substitution that replaces each of the leading
spaces by certain symbol that does not occur in the text, and changes
that symbol to
: