I would like to search for all uppercase words in a file but I have no idea how to do it (or if it's possible). I found this solution here on stackoverflow, but it doesn't work on vim.
From command mode, assuming you do not have the option ignorecase
set:
/\<[A-Z]\+\>
or
/\v<[A-Z]+>
Finds any string of capital letters greater than length one surrounded by word boundaries. The second form uses 'very-magic'. :help magic
for details
The shortest answer: /\<\u\+\>
If you want a list of all the matching uppercase words (i.e. you aren't interested in jumping from one word to the other), you can use:
echo filter(split(join(getline(1, '$'), ' '), '\v(\s|[[:punct:]])'), 'v:val =~ "\\v<\\u+>"')
With:
getline(1, '$')
that returns a list of all the lines from the current bufferjoin(lines, ' ')
that flattens this list of linessplit(all_text, separators_regex)
that build a list of word-like elementsfilter(words, uppercase-condition)
that selects only the uppercase words.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