For example, say I have this piece of SQL and I want to convert all the field names to lowercase:
1CREATE TABLE test ( 2MYFIELD1 STRING, 3MYFIELD2 STRING, 4... 5MYFIELDN STRING 6)
Doing it with macros it tedious, and with multiple cursor, at least in Vim, it can be annoying, especially if you have lots of tables create like that, spanning multiple lines.
Enter normal mode
Normal mode comes to the rescue here: you just need to know which commands you would execute on one
line to get the desired result (in this case
_g~w) and the range of lines where the commands
should be executed (in this case
2,5). Then it’s just a matter of typing
:2,5norm _g~w and,
almost magically, the code will be transformed in what we wanted!
1CREATE TABLE test ( 2myfield1 STRING, 3myfield2 STRING, 4... 5myfieldn STRING 6)