prac64's blog

By prac64, history, 6 years ago, In English

Hi Codeforces,

I use sublime-text3 editor to write codes, and CMD to run them. But sublime text does not have a feature to replace all endl's with '\n' , I tried recording a macro, but that only records characters printed on the screen, so that failed.

I don't use #define because that looks bad in the code and has resulted in frustrations before(forgetting that endl is not flushing the buffer and hence getting no output on incorrectly terminating programs).

Can someone write a script or snippet or anything that can do the above operation in 2-3 keystrokes ? Alternatively, point me to resources that can help me learn how to do that ?

  • Vote: I like it
  • -17
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it +7 Vote: I do not like it

Can't you just search for and replace "endl" with "\n" ?

»
6 years ago, # |
Rev. 4   Vote: I like it +6 Vote: I do not like it

CTRL+H (Replace) | Find: endl | TAB -> Replace: '\n' | Replace all | Or you could press ALT+ENTER after Find: endl and replace every occurence with '\n' manually, which is faster imo

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I don't know how to bind some external commands on specified hotkeys in sublime, but I know it's possible to make a build system which does this. The script is

sed 's/endl/"\\n"/g' -i $file