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

Автор ahmadexe, история, 5 месяцев назад, По-английски

Sublime randomly stops indenting on new line and cursor starts pointing onto first character of the line instead of continuing indent. Since I am using a snippet, when I press tab to reintroduce the indentation, the tab actually moves my cursor to the end. (see video) https://www.youtube.com/watch?v=2jljt4HbwGc (issue on 29 sec) Happens on line 14

This behavior happens randomly. Also with simple declarations and even calling out functions. No idea why it happens. I don’t have much idea with indentation settings, please let me know which configuration is right one for C++ competitive programming

Here is my sublime preferences file

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

»
5 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Yes sometimes the cursor skipping to end of file frustates me too

»
5 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

for eg. If you use three placeholders like $1, $2, and $3, the last one should be $0. This happens because it’s trying to find the last placeholder, which is actually $0. Let me know if it works!

»
5 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

If you use brackets in your loops it will work fine like this:

    for(int i =0; i < n; i++) { 
        cin >> a[i]; 
    } // pressing enter takes you 
    // here

Or you can press enter once after your for loop declaration, like this: (For this I believe you should have smart_indent = on)

    for(int i =0 ; i < n; i++) //pressing enter here takes you to here1
        // [here1]
        cin >> a[i]; //pressing enter here would take you to here2
    //[here2]

Or if you stop having one-line for-loops the problem goes away lol

This indent problem only happens in the line after the next line of loop declaration (with smart indent off) and occurs in the line after the loop declaration (with smart indent on)

i too face the same problem im just used to it now lol. i automatically press tab once after one-line loops

  • »
    »
    5 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Yes, thanks for your tips. I have turned smart indent back on Now it has resolved my aforementioned issue. But as you stated, it does mess up my indentation after for loops in a single line. So, will do something like this from now on:

    for (int i = 0; i < n; i++) 
        cin >> a[i];