text editor - fastest way to insert lines repeatedly? -
text editor - fastest way to insert lines repeatedly? -
what trying add together #ifdef , #endif before , after of puts. there hundreds of puts in code. string within of puts different in each case. i'm working on problem text editors vim , sublime text 2.
is there smarter way of doing such task?
#ifdef puts("blah blah blah"); ========> puts("blah blah blah"); #endif
sublime text: afair utilize multiple cursors functionality in st like: ">find_all<, puts, ctrl+shift+l (or give individual cursor each highlighted line), go type required modifications (which exact same movement/typing each line)"
of course of study wouldn't work different indentation , stuff, im afraid...
vim: in substitute should more or less this:
:%s/puts(.\{-});/#ifdef something\n &\n#endif/g (though im not sure if wouldn't need escaping here)
basically means: % - whole file s - substitute /first_part/second_part/ - substitute occurence of first_part second_part g - globally - meaning each line found among % (whole file)
and first part is: normal: 'puts(', non-greedy (if don't know mean - google it, worth know) regex character, normal: ');' should match puts'
and second: normal: '#ifdef something', newline, 4 spaces, & means 'found pattern' (basically puts of yours), newline, normal: '#endif' wrote of top of head please take business relationship things may need correction (shortcuts in st or escaping characters in substitute formula). understanding
text-editor
Comments
Post a Comment