Isn't
:%s/.)/hello)/
simpler? Maybe that's because I know nothing about macros. Thanks for the explanation.
:%s/.)/hello)/
simpler? Maybe that's because I know nothing about macros. Thanks for the explanation.
The PAPI library has a utility program papi_avail which prints a table of supported performance counters. The lines may look like this:
PAPI_VEC_SP 0x80000069 Yes Single precision vector/SIMD instructions
PAPI_VEC_DP 0x8000006a Yes Double precision vector/SIMD instructions
PAPI_REF_CYC 0x8000006b No Reference clock cycles
For a course project, I wanted to turn this into a C-array like this: {PAPI_VEC_SP, "Single precision vector/SIMD instructions"},
{PAPI_VEC_DP, "Double precision vector/SIMD instructions"},
{PAPI_REF_CYC, "Reference clock cycles"},
Using :norm, this transformation can be achieved in the following way: :'<,'>norm I{^[eldedecw, "^[A"},
(where ^[ is a literal escape, typed CTRL-V ESC.)Anecdotally, it is faster for me to type up such a line than an equivalent regular expression, since I use vi normal mode commands much more than regular expressions.
/^\(\S*\)\s*\S*\s*\S*\s*\(\p*\)
:%s//{\1, "\2"},
"Now they have two problems."As a side note, I love how Vim is basically a functional programming language for text editing.
{ down { down {
to insert all three leftmost brackets. up up up
to go to first bracket. shift+left
to select first bracket. cmd+d cmd+d cmd+d
to select all three next brackets including the first. ctrl+shift right
to move all three cursors to the end of word. comma space "
to type your characters with all three cursors. cmd+right
to go to end of line with all three cursors. " } ,
to type your characters with all three cursors.21 presses (29 keys), compared to your 32. And all I had to think about was where the cursor was.
(Not to be pedantic, of course!)