Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to match one or more whitespaces in Vim

Tags:

vim

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?

like image 500
Léo Léopold Hertz 준영 Avatar asked May 08 '09 09:05

Léo Léopold Hertz 준영


People also ask

How to replace multiple spaces with single space 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.

How to see whitespaces in vim?

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.

How do I match a pattern in vim?

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.


1 Answers

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.

like image 91
Lucas Lindström Avatar answered Oct 23 '22 15:10

Lucas Lindström