GitHub - idbrii/vim-gimmename: When you can't come up with a name, vim c...
source link: https://github.com/idbrii/vim-gimmename
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
vim-gimmename
When you're bad at coming up with names on the spot, gimmename is an alternative to naming everything temp1, temp2, etc. It might not be good names, but they'll be unique and you won't get them confused with your other temp variables.
Requirements
From within vim, install our required python package (assuming your pyx default is python3):
:! python3 -m pip install coolname " or :! python3 -m pip install -r ~/.vim/bundle/gimmename/requirements.txt
Usage
While typing, if you can't think of a variable name, use these insert mode mappings to gimmename:
<C-x><C-z><C-s>
-- snakecase<C-x><C-z><C-d>
-- camelcase<C-x><C-z><C-m>
-- mixedcase<C-x><C-z><C-z>
-- current style defined in b:gimmename_style or g:gimmename_style
Example:
def <C-x><C-z><C-z>(items): <C-x><C-z><C-z> = [i for i in items if type(i) == str] pass
Results in something like:
def skilled_unicorn(): spicy_pigeon = [i for i in items if type(i) == str] pass
Customization
Set the default style in your vimrc:
let g:gimmename_style = 'snakecase' let g:gimmename_style = 'camelcase' let g:gimmename_style = 'mixedcase'
Override styles in your ftplugins:
" in ~/.vim/ftplugin/python.vim let b:gimmename_style = 'snakecase' " in ~/.vim/ftplugin/cs.vim let b:gimmename_style = 'mixedcase'
Define your own mappings in your vimrc:
let g:gimmename_no_mappings = 1 imap <C-\><C-\> <Plug>(gimmename-current-style) imap <C-\><C-s> <Plug>(gimmename-snakecase) imap <C-\><C-d> <Plug>(gimmename-camelcase) imap <C-\><C-m> <Plug>(gimmename-mixedcase)
Inspiration
vim-gimmename was inspired by this post about
codelf.
I was a bit horrified at the idea of blasting the user with tons of variable
names that contain their token, but even more uncomfortable with all the
variables being temp(n+1)
. I'd recently messed around with the coolname
python package, so vim-gimmename was an obvious reaction.
License
MIT License
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK