Блог пользователя prac64

Автор prac64, история, 6 лет назад, По-английски

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 ?

  • Проголосовать: нравится
  • -17
  • Проголосовать: не нравится

»
6 лет назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

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

»
6 лет назад, # |
Rev. 4   Проголосовать: нравится +6 Проголосовать: не нравится

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 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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