I have a vim (well, sed really) find and replace pattern I use for resetting the AUTO_INCREMENT
property in mySQL CREATE TABLE
statements:
:%s/AUTO_INCREMENT=[0-9]*/AUTO_INCREMENT=1/g
I use this command often, and would like to create a shortcut in vim. I know I will have to edit my .vimrc, but I can't figure out the cmap
syntax.
My end goal is to be able to run
:reset-auto-increment
And run the above find and replace globally throughout the file.
Answer
For that goal, I think a user-defined command would be better than a cmap. See
:help 40.2
:help user-commands
Vim requires that user-defined commands begin with an upper-case letter and contain only letters and digits. No hyphens. So your command will have to be something like ResetAutoIncrement.
command ResetAutoIncrement %s/AUTO_INCREMENT=[0-9]*/AUTO_INCREMENT=1/g
You can avoid typing the whole command name each time you use it by typing just the first few characters, then hitting Tab.
No comments:
Post a Comment