Search Unity

Optimize MonoDevelop to speed up your coding workflow

Discussion in 'External Tools' started by _Shockwave, Nov 23, 2012.

  1. _Shockwave

    _Shockwave

    Joined:
    Sep 2, 2012
    Posts:
    21
    This is my first contribution to the unity community and I hope it helps you guys.
    I will tell you about the things that make me code faster from a programmer's point of view.
    Keep in mind that I'm using JavaScript/UnityScript as my main language for writing scripts.
    I'll try to keep the post short and to the point :).

    Look and Feel

    • Get comfortable with Syntax highlighting (choose a theme that you enjoy and good for your eyes)
    • Customize your layout in MonoDevelop. I prefer to have the following options:
      • Search results window in the bottom left -> embedding the window enables me to see things quicker than having them interrupt my workflow when i search for things in my solution.
      • Tabs and spaces markers are enabled -> because I'm a software engineer which makes me picky about how my code is written and how perfect it should be.

    Shortcuts

    Not knowing your IDE's shortcuts is like changing gear by having to look down on the gear every time you shift up or down -_-!
    Therefore, you need to memorize some keyboard shortcuts that will make you code faster. Especially if you are using JavaScript/UnityScript as your coding language for Unity.

    Find things quickly
    • Go To Type: Ctrl+Shift+T. This shortcut is very popular in all IDEs. It allows you to open files/classes quickly without having to navigate through the solution. It also understands CamelCase in search. For example, I want to open a file called CameraFocus.js. I press Ctrl+Shift+T and start typing CFo which gives me all the files that their first word starts with C and second word starts with F followed by a small letter o.
    • Search in files: Ctrl+Shift+F. This is a very important shortcut because you can use it to find occurrences of anything in your solution (e.g. variables, methods ..etc.)
    • Show Next: F4. This goes to the next search match. Useful scenario is that you highlighted a method name and want to find all other classes that are using it, so you search in files and that shows up in your search results window, so then you press F4 and that opens another file and shows you exactly where it's used. This saves you time from moving the cursor to the next search item and double clicking it.
    • Go To Declaration: F12. As name suggests, very useful when you are trying to understand some one else's code.
    • Unity API Reference: I changed it to Ctrl+` instead of Ctrl+' because then I can do it in one hand :D.

    Refactor a lot to make your code easier to understand later.
    • Extract Method: Ctrl+Alt+M
    • Extract Local: I set this manually to Ctrl+Shift+L by going to the key bindings in Preferences.
    • Toggle Line Comments: I changed this to Ctrl+Shift+C because it is easier for my hand to reach the Shift key rather than the Alt key. This is totally a personal preference and also depends on your keyboard. This shortcut allows you to quickly comment or uncomment line(s) of code.

    General Code Editing shortcuts
    • Delete Line: I added this shortcut because its very useful to me. I made it Shift+D. Again focus on doing shortcuts with one hand.
    • Switch between open files(tabs): Ctrl+Tab
    • Quickly find occurrences of a word in a file: Ctrl+F which is the search in file shortcut.
    • Quick renaming of variables in a file: Ctrl+H which is the shortcut for replace. Now MonoDevelop doesn't seem to have a way to rename a variable/method in its refactoring keyboard shortcuts, which is unfortunate. So to get around this is to do search in files(CTRL+Shift+F) for this variable, and replace occurrences(Ctrl+H) with the name you want, then F4 to go to the other files that have that variable ;).
    • Auto Completion: Ctrl+Space I think everyone knows this but I'll add it anyway.



    Ok, I think i'll stop here. If I keep going I won't be able to finish in time haha. This should be enough for now. Tell me if you guys want me to explain how I'm using Git as my repository ;).
     
    AlanMattano and the_motionblur like this.
  2. dawgtothebone

    dawgtothebone

    Joined:
    Sep 16, 2012
    Posts:
    2
    Nice post!!
     
  3. Toasttify

    Toasttify

    Joined:
    Mar 27, 2012
    Posts:
    143
    Lots of info, thanks!
     
  4. tonycoculuzzi

    tonycoculuzzi

    Joined:
    Jun 2, 2011
    Posts:
    197
    Great stuff! Any idea how to cmd+click or ctrl+click into a declaration though? That's the one standard shortcut I miss in MonoDevelop.
     
    ppartida likes this.
  5. _Shockwave

    _Shockwave

    Joined:
    Sep 2, 2012
    Posts:
    21
    You're welcome guys.
    Thanks. There is no way of going into the declaration if you are using UnityScript/JavaScript. However, there is a workaround which is to use the Search in Files shortcut -> Ctrl+Shif+F and then type in the name of the function that you want to find.
    On the other hand, if you are using C# then you can go to declaration by pressing F12 on your keyboard.
     
  6. cstaylor8311

    cstaylor8311

    Joined:
    Mar 11, 2013
    Posts:
    9
    I've bookmarked this, I look forward to seeing if any of this is useful for me. Great post!
     
  7. kOrc

    kOrc

    Joined:
    Sep 15, 2012
    Posts:
    7
    Thanks for the tips! I had been writing up my own cheat sheet for personal use, glad to see this shared, and I've learned some from here too.

    Something I've found confusing me -- I use a Mac OSX Unity Pro at work, and a Windows 8 Unity free at home. On my work machine, I can switch tabs in Mono using [Command] + #, where # = [1][2]...[9], to jump directly to the #th open tab. I've found this extremely helpful as it is many times faster than [control]+[tab]ing or [control]+[shift]+[tab]ing through 5-10 open scripts.

    However, this shortcut doesn't work for me in my Windows version. Does anyone who has Unity Pro for Windows, or Unity Free for Mac help me verify if this is an OS-based difference or a Free/Pro-based difference (I don't trust it is, since Mono is somewhat independent of Unity). Additionally, if anyone could find out how to identify this set of shortcuts (not found with the keyword "tab") so that I could set it in my Windows environment, that would be suh-weet.

    Thanks!
     
  8. AndyMartin458

    AndyMartin458

    Joined:
    Jul 15, 2012
    Posts:
    53
    Thanks! This is great info. I'll add that to change shortcuts you can do that in Key Bindings.
     
  9. payalsharma9988

    payalsharma9988

    Joined:
    Oct 31, 2013
    Posts:
    25
    Thanks _Shockwave for this Great Info...........
     
  10. EMOTION-THEORY

    EMOTION-THEORY

    Joined:
    Jul 16, 2013
    Posts:
    68
    This is excellent, thanks for sharing!
     
  11. buckius82

    buckius82

    Joined:
    Nov 19, 2013
    Posts:
    34
    i was adjusting a script i have 275 lines of error random.range is ambiguous because i had system (for ENUM class) and UnityEngine.
    thank you the CTRL + H shortcut Saved me this thread has been bookmarked
     
  12. sandeepsmartest

    sandeepsmartest

    Joined:
    Nov 7, 2012
    Posts:
    100
    ShockWave..Thanks for sharing....what is the shortcut for the next occurrence of the variable which was previously "Ctrl+Shift+DownArrow" or "Ctrl+Shift+UpArrow" - It helped me alot in the previous version of MonoDeveloper. I am unable to find the shortcut in the version of MonoDeveloper V4.0.1. Please help me .....
    Thanks in advance...
     
  13. Deepscorn

    Deepscorn

    Joined:
    Aug 13, 2015
    Posts:
    13

    And tips on coding will appear. It's static analysis of code with tips just inside Monodevelop!
     
  14. skauth

    skauth

    Joined:
    Jun 4, 2017
    Posts:
    16
    I'm sorry... did you say you use Shift+D for deleting lines? What about when you have to write a function called ReportDamages()? How do you do a capital D there without deleting your line?