Refactorings for javascript in vim.
Requirements:
- Vim 8 or NeoVim v0.2.0
- Node 5
with vim-plug
Plug 'oesse/vim-jsrf', { 'do': 'npm install' }
with pathogen
cd ~/.vim/bundle
git clone git://github.com/oesse/vim-jsrf.git
cd vim-jsrf && npm install
In a javascript file use <leader>r
as the prefix for refactoring commands in normal and visual mode. Available refactorings:
default mapping | name | description |
---|---|---|
<leader>rv |
extract variable | Extract the expression under the cursor to new const variable |
<leader>re |
expand object | Put each property of object literal on a line of its own |
<leader>rc |
collapse object | Put the object literal on a single line |
You can change the refactorings prefix in your vimrc:
let g:jsrf_map_leader = '\'