Reputation: 9275
I used __version__
variable for different files within my module. For example,
""" foo.py """
__version__ = '0.0.1'
""" bar.py """
__version__ = '1.0.1.111'
I am looking for any Vim command/plugin to automatically increase the version number string. E.g, press F12,
'0.0.1' => '0.0.2'
'1.0.1.111' => '1.0.1.112'
Upvotes: 1
Views: 161
Reputation: 6026
That should actually work:
:g/^__version__/exe "normal! $b\<C-A>"
What it does is the following:
it executes $\<C-A>
on every line where __version__
is found.
$
goes to the last character on the line (minor version), and <C-A>
increments the number under the cursor, as nbari said.
That can be modified for the first part of the version number it is:
:g/^__version__/exe "normal! \<C-A>"
And so on.
Upvotes: 2
Reputation: 26965
In vim by pressing ctrl+a in normal mode will increase the number + 1 under the cursor and ctrl+x will decrese it.
So in this case:
""" foo.py """
__version__ = '0.0.1'
by putting the cursor in 1 and pressing ctrl+a will increment the value to 2:
__version__ = '0.0.2'
This works if you just want to bump the patch semver version, but to bump to a major, minor probably a plugin.
Something like this probably could be adapted https://github.com/nbari/semverbump in this case the script bumps the version based on the git tag.
Upvotes: 1