for uppercase: gggUG
for lowercase: ggguG
PS: the first 2 g’s are for moving to the beginning of the document.
PS2: works in vim, don’t know about plain vi
Can also do this using the search function in command mode
<esc> :%s/.*/\L&/
and in uppercase :
<esc> :%s/.*/\U&/