Notepad Automatic Highlight

Viewed 198

I have a CSV file that I handle its data through notepad++, I Would like to highlight all text that come after a specific number of commas in each row , Is there a good way for applying this automatically ?

2 Answers

You can define your own "programming language" for your CSV file. You can change default CSV style, or use custom extension for your file like .csvc. Define the rules and it will be applied automatically each time you open the file.

The "Mark" command in Notepad++'s search will do this. To highlight any text after the third comma on a line use a search string based on ^\w,\w,\w,\K.+$. The change to look for more commas, or fewer, is obvious. This simple search pattern looks for single 'word' characters separated by commas. The \K says to discard anything found so far and then the .+$ finds the text wanted by the question and the action of "Mark"ing it highlights that test. Enter the search string into the Mark dialogue and select regular expressions. "Bookmark lines" can be selected or not depending on whether the found lines should be bookmarked. Then click on "Mark All".

Moving the \K, in the search string, to before the commas allows finds text including and after the third comma.

To allow for variable length strings separated by commas on the lines, change the search string to ^[^\r\n,]+,[^\r\n,]+,[^\r\n,]+,\K.+$. This could also be written as ^([^\r\n,]+,){3}\K.+$.

Related