I want match spaces at the beginning of lines in Vim
PseudoCode of what I want to do
^( )*
I know the following from manual
notation meaning equivalent decimal value(s) ----------------------------------------------------------------------- <Space> space 32 *space*
I am not sure how to use the decimal value 32.
How can you match one or more whitespaces in Vim?
The basic construct of the command is s#search#replace#. Sometimes you see it as s///. The % before the s tells the regex to work on all lines in the vim buffer, not just the current. The space followed by \+ matches one or more spaces.
Show All White Spaces: To see all the spaces inserted within this file of data, you need to add the “hls” command on the command area of Vim. So, after adding the text within the Vim text file, navigate towards the normal mode by pressing the Esc key. Press the “:” character to open the command area.
In normal mode, press / to start a search, then type the pattern ( \<i\> ), then press Enter. If you have an example of the word you want to find on screen, you do not need to enter a search pattern. Simply move the cursor anywhere within the word, then press * to search for the next occurrence of that whole word.
Typing
/^ \+
In command mode will match one or more space characters at the beginning of a line.
Typing
/^\s\+
In command mode will match one or more whitespace characters (tabs etc. as well as spaces) at the beginning of a line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With