Kay Gosho
Posted on April 17, 2018
This is a small snippet.
Create this function in your shell:
# .bashrc / .zshrc
camelcase() {
perl -pe 's#(_|^)(.)#\u$2#g'
}
If you use fish:
# .config/fish/config.fish
function camelcase
perl -pe 's#(_|^)(.)#\u$2#g'
end
Then, you can convert standard input to CamelCase:
~> echo array_map | camelcase
ArrayMap
These functions are useful themselves. Furthermore, you can use them in Vim.
Select snake_case lines to be converted, then type !camelcase
then press return key.
Appendix
You can convert CamelCase to snake_case with this function:
function snakecase
perl -pe 's#([A-Z])#_\L$1#g' | perl -pe 's#^_##'
end
We can enhance vim using command line function.
Hope this article helps you have a better CUI experience in Vim.
💖 💪 🙅 🚩
Kay Gosho
Posted on April 17, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.