Created
April 10, 2017 16:51
-
-
Save farhaanbukhsh/935670c84deeb43dd43967187ce8ced9 to your computer and use it in GitHub Desktop.
This is vimscript to migrate to ES2015 standards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"" Put the following function in your `.vimrc` and place the cursor on the | |
"" `var <ComponentName>` line once the cursor is there in the `command` mode | |
"" press spacebar to execute the function, check that your spacebar is not | |
"" mapped to any other function enjoy the migration to ES2015 | |
"" | |
"" Author : Farhaan Bukhsh <farhaan@fedoraproject.org> | |
"" React migrate | |
function ReactMigrate() | |
let curr_line = getline('.') | |
let replaceVar = substitute(curr_line, 'var', 'class', 'g') | |
call setline('.', replaceVar) | |
let curr_line = getline('.') | |
let replaceClass = substitute(curr_line, '= | |
React.createClass', 'extends React.Component', 'g') | |
call setline('.', replaceClass) | |
normal f( | |
normal %2x``x | |
endfunction | |
nnoremap <space> :call ReactMigrate() <CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment