Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tpope/vim-abolish
abolish.vim: Work with several variants of a word at once
https://github.com/tpope/vim-abolish
Last synced: 10 days ago
JSON representation
abolish.vim: Work with several variants of a word at once
- Host: GitHub
- URL: https://github.com/tpope/vim-abolish
- Owner: tpope
- Created: 2008-08-02T04:04:00.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2024-08-07T21:16:02.000Z (4 months ago)
- Last Synced: 2024-11-16T03:08:49.468Z (27 days ago)
- Language: Vim Script
- Homepage: https://www.vim.org/scripts/script.php?script_id=1545
- Size: 63.5 KB
- Stars: 2,794
- Watchers: 31
- Forks: 87
- Open Issues: 38
-
Metadata Files:
- Readme: README.markdown
- Contributing: CONTRIBUTING.markdown
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
- writingvim - abolish
README
# abolish.vim
I sat on this plugin for 3 years before releasing it, primarily
because it's so gosh darn hard to explain. It's three superficially
unrelated plugins in one that share a common theme: working with
variants of a word.## Abbreviation
I know how to spell "separate". I know how to spell "desperate". My
fingers, however, have trouble distinguishing between the two, and I
invariably have a 50 percent chance of typing "seperate" or "desparate"
each time one of these comes up. At first, I tried abbreviations::iabbrev seperate separate
:iabbrev desparate desperateBut this falls short at the beginning of a sentence.
:iabbrev Seperate Separate
:iabbrev Desparate DesperateTo be really thorough, we need uppercase too!
:iabbrev SEPERATE SEPARATE
:iabbrev DESPARATE DESPERATEOh, but consider the noun form, and the adverb form!
:iabbrev seperation separation
:iabbrev desparation desperation
:iabbrev seperately separately
:iabbrev desparately desperately
:iabbrev Seperation separation
:iabbrev Desparation Desperation
:iabbrev Seperately Separately
:iabbrev Desparately Desperately
:iabbrev SEPERATION SEPARATION
:iabbrev DESPARATION DESPERATION
:iabbrev SEPERATELY SEPARATELY
:iabbrev DESPARATELY DESPERATELYWait, there's also "separates", "separated", "separating",
"separations", "separator"...Abolish.vim provides a simpler way. The following one command produces
48 abbreviations including all of the above.:Abolish {despa,sepe}rat{e,es,ed,ing,ely,ion,ions,or} {despe,sepa}rat{}
My current configuration has 25 Abolish commands that create hundreds of
corrections my fingers refuse to learn.## Substitution
One time I had an application with a domain model called
"facility" that needed to be renamed to "building". So, a simple
search and replace, right?:%s/facility/building/g
Oh, but the case variants!
:%s/Facility/Building/g
:%s/FACILITY/BUILDING/gWait, the plural is more than "s" so we need to get that too!
:%s/facilities/buildings/g
:%s/Facilities/Buildings/g
:%s/FACILITIES/BUILDINGS/gAbolish.vim has your back. One command to do all six, and you can
repeat it with `&` too!:%Subvert/facilit{y,ies}/building{,s}/g
From a conceptual level, one way to think about how this substitution
works is to imagine that in the braces you are declaring the
requirements for turning that word from singular to plural. In
the facility example, the same base letters in both the singular
and plural form of the word are `facilit` To turn "facility" to a
plural word you must change the `y` to `ies` so you specify
`{y,ies}` in the braces.To convert the word "building" from singular to plural, again
look at the common letters between the singular and plural forms:
`building`. In this case you do not need to remove any letter
from building to turn it into plural form and you need to
add an `s` so the braces should be `{,s}`.A few more examples:
Address to Reference
:Subvert/address{,es}/reference{,s}/g
Blog to Post (you can just do this with a regular :s also)
:Subvert/blog{,s}/post{,s}/g
Child to Adult
:Subvert/child{,ren}/adult{,s}/g
Be amazed as it correctly turns the word children into the word adults!
Die to Spinner
:Subvert/di{e,ce}/spinner{,s}/g
You can abbreviate it as `:S`, and it accepts the full range of flags
including things like `c` (confirm).There's also a variant for searching and a variant for grepping.
## Coercion
Want to turn `fooBar` into `foo_bar`? Press `crs` (coerce to
snake\_case). MixedCase (`crm`), camelCase (`crc`), UPPER\_CASE
(`cru`), dash-case (`cr-`), and dot.case (`cr.`) are all just 3
keystrokes away.## Installation
Install using your favorite package manager, or use Vim's built-in package
support:mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/abolish.git
vim -u NONE -c "helptags abolish/doc" -c q## Self-Promotion
Like abolish.vim? Follow the repository on
[GitHub](https://github.com/tpope/vim-abolish) and vote for it on
[vim.org](http://www.vim.org/scripts/script.php?script_id=1545). And if
you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
[Twitter](http://twitter.com/tpope) and
[GitHub](https://github.com/tpope).## License
Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.
See `:help license`.