For example, say I have this piece of SQL and I want to convert all the field names to lowercase:
1 CREATE TABLE test ( 2 MYFIELD1 STRING, 3 MYFIELD2 STRING, 4 ... 5 MYFIELDN 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!
1 CREATE TABLE test ( 2 myfield1 STRING, 3 myfield2 STRING, 4 ... 5 myfieldn STRING 6 )