The context is that I am copy pasting React props definition into the function arguments, so that I don't have to type the variable names one by one:
// Select these 3 lines with V3j
MyComponent.propTypes = {
formName: PropTypes.string.isRequired,
formPurpose: PropTypes.string.isRequired,
formPlaceholder: PropTypes.string.isRequired,
};
To remove the : PropTypes.string.isRequired and change it to ={variableNameHere} I'm using the following Vim regex:
:'<,'>s/\(.*\)\zs:.*/={\1}/g
This should capture the variable name, remove everything after : and put the capture inside the curly brackets on ={}.
The result is the following:
formName={ formName}
formPurpose={ formPurpose}
formPlaceholder={ formPlaceholder}
There's an unwanted space after { and I can't figure out what is that space in the regex. Any ideas?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)