Tips and Tricks to be a Productive Coder
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
presentation.md
readme.md

readme.md

Developer Productivity Guide

Overview

Become a more productive developer, within this short and sweet guide you might learn something that you have always wondered how to do or never knew existed! This guide will mostly talk about your JetBrains IDE and some other tips that would apply on both platforms Windows and Mac.

Here's the outline of what I will be talking about:

  1. Any JetBrains IDE (IntelliJ, PHPStorm, WebStorm, etc...) [https://www.jetbrains.com/help/idea/2016.2/]
  2. Emmet (http://emmet.io/)
  3. Command Line Terminal Tips
  4. ZSH Configuration
  5. Performance Optimizations

JetBrains IDE (IntelliJ, PHPStorm, WebStorm, etc...):

Initial Setup:

  • We want to activate our F1, F2, F3 to use as our standard function keys so that we can use as much shortcuts as we can: Go to System Preferences / Keyboard / Keyboard and uncheck the item that says "Use all F1, F2, etc. as standard function keys."
  • If we ever want to use our special keys we just hold FN key and change the volume for example.

This section will be organized by component:

  1. Editor ESC
  • Moving the cursor efficiently
  • Selecting / Highlighting
  • Manipulating
  • Using the mouse
  • Code Completion
  1. Project Navigation CMD 1
  2. Version Control CMD 9
  3. Embedded Terminal ALT F12
  4. Preferences CMD ,
  5. Searching Efficiently
  • Shortcut hotkeys for searching
  1. Shortcut Hot keys you can not live without
  2. Productivity Guide

Editor

Basic Shortcut Keys

We want to try to keep our hands on the keyboard and learn and memorize shortcut hotkeys as much as possible! Take your time on these and get them stuck in your head and in the long run you will thank yourself.

1. Moving the cursor efficiently

Description Shortcut Key
Moving your cursor to the next or previous line CTRL N or CTRL P
Moving to end or beginning of the line of code CMD or CMD
Moving forward in line of code CTRL F
Moving backward in line of code CTRL B
Moving word by word in line of code ALT or ALT

2. Selecting / Highlighting

Description Shortcut Key
Highlight the next occurrence of highlighted code CMD G
Highlight the previous occurrence of highlighted code SHIFT CMD G
Highlight same code occurrence with CTRL G or CTRL SHIFT G
Highlight code based on its grammar or enclosed blocks of code ALT or ALT
Highlight a character at a time SHIFT or SHIFT
Highlight up or down line by line of code SHIFT or SHIFT
Highlight the rest of the line of code on the right or left side SHIFT CMD or SHIFT CMD
Highlight enclosed blocks of code ALT or ALT
Highlight each by word and punctuation CMD SHIFT or CMD SHIFT

3. Manipulating

Description Shortcut Key
Duplicate your current highlighted code CMD D
Move the current line of code up SHIFT CMD SHIFT CMD
Comment or uncomment a line of code CMD /
Comment or uncomment a multi-line of code CMD ALT /
Expand or collapse a code block CMD + or CMD -
Surround with highlighted code with something ALT CMD T
Reformat or line code up CMD ALT L
Delete whole line CMD DELETE
Smart Line Joining, Pressing multiple times will keep joining the lines. CTRL SHIFT J
Create new lines without moving the cursor CMD ENTER
Toggle Letter Case and you can even toggle multilines. CMD SHIFT U
Deleting the word starting from the current caret location up to the word end ALT DELETE

4. Using the mouse

Description Shortcut Key
You can use your mouse to spread multiple cursors around your code Hold ALT and Move mouse
See more information about the piece of code by holding Hold CMD and Hover mouse over code
Going directly to code's definition Hold CMD and click code

5. Code completion

  • If you want to see Basic Code Completion suggestions you can press CTRL SPACE
  • It will show suggestions for variables, types, methods, expressions, and more.
  • We also have Statement Completion it will add missing parentheses, brackets, braces, and other necessary formatting with SHIFT CMD ENTER
  • You can also press enter if your code completion suggestion is first in the list to automatically insert.
  • Hippie Completion (Cycles through keywords, class names, methods, or variables within the file) with ALT / don't know if anyone uses this, I just always type it in.

Project Navigation

  • Quickly go to your project window by typing in CMD 1 and go back to you code editor by pressing ESC.
  • You can search for any files by just typing while you are in the project window.
  • You can choose to show only your changed files.
  • You can choose to show by Structure instead of by files. This is useful if you are in a huge file and just want to see seperated class names, methods, functions, and so on.
  • Click the target for it to immediately point you to your current file opened in your code editor.
  • Click the collapse to collapse all files and folders to root.
  • One useful thing is the Autoscroll from source which automatically moves to the current file that you are editing in your code editor.

Version Control

  • You can quickly open up version control by pressing CMD 9
  • Quickly see version control operations with CTRL V
  • Choose a way to update your project with CMD T
  • Shows Git Log visually and you can select each commit to compare differences.
  • You can use annotate to see who has changed something previously
  • See all your local changes.
  • You can create a changelist to make sure those files will not be commited.
  • See Differences between local and previously committed files.
  • When you get a merge conflict, we can fix easily by right clicking the file -> Git -> Fix Merge Conflict (The best feature in my opinion)

Searching Efficiently

1. Shortcut hotkeys for searching

Description Shortcut Key
Find something in your current file CMD F
Find and replace in current file CMD R
Find in Path CMD SHIFT G
Find and Replace in Path CMD SHIFT R
Find a Class to go to CMD O
Find a File to go to CMD SHIFT O
Find a Symbol to go to CMD ALT O
Find a Line number in current file and jump to it CMD L
Find an Action or Option name CMD SHIFT A
Search Everywhere! Double Tap SHIFT
  • Filter your search by clicking the gear icon to only look in specific areas.
  • Search by Regex, by whole words, or turn on case sensitivity.
  • Search with wildcards(*) for example *Block.php or Block.*
  • Search by each capital letter in file name.
  • Search by typing in the path for example /path/to/file.js
  • Search file with and jump to line number when opened. For Example server.js:40
  • Search for structural blocks/templates with by finding an action and look for Search Structurally you can also replace a block of code with Replace Structurally.

Shortcut hot keys you can not live without

Description Shortcut Key
Create a new file and more CMD N
Quickly go to usage or find multiple usages CMD B
Retrieve Parameter Information CMD P
Find more documentation on highlighted (double tap detailed documentation) CTRL J
Show intention actions and quick fixes ALT ENTER
Navigate between opened tabs SHIFT CMD ] or SHIFT CMD [
Navigate through tabs with history CMD [ or CMD ]
Close active editor tab CMD W
Scale your current window SHIFT CMD and move with arrow keys
Open Embedded Terminal ALT F12

Productivity guide

  • Since its built in, you can see your productivity guide by going to Help -> Productivity Guide
  • Shows how much time you have saved using code completion has saved you.
  • Shows you how many possible bugs that the IDE has saved you from.
  • Shows all IDE features that are related to productivity and how many times you have used it.
  • Shows information on how to use it.

Emmet (http://emmet.io/)

  • Our IDE includes Emmet by default. It is a plugin that increases your code editing workflow.
  • Includes HTML, CSS, and XSL fast on tab snippets!
  • Go to the website and read the documentation, it is pretty worth it.
  • Their cheatsheet is at (http://docs.emmet.io/cheat-sheet/)

Terminal Tips

  • Move word by word when moving the cursor of the command with ALT for forward and ESC for backwards. Note: The Imbedded Termainal in IntelliJ doesn't work with this, instead they use the olds school way.
  • The old school way to moving the cursor is ESC B for backwards and ESC F for forwards
  • Move at the end of the line or beginning with CTRL E or CTRL A
  • Run multiple commands in one line git add . && git commit 'commit test' && git push origin master
  • To clear window clear
  • To cancel what you entered CMD C
  • View contents of a file with cat filename
  • Previous command !ssh to show previous command that we used that began with ssh
  • Navigation through folders with cd pressing tab finish off what you were searching for
  • See a list of commands you've previously entered history
  • Undo something with CTRL -
  • Show previous single commands by also using the up and down arrows on your keyboard also.
  • Do a search between all your commands with CMD R
  • Want to always see hidden files? Use: defaults write com.apple.finder AppleShowAllFiles -bool TRUE and false if you want to turn that off.

Fun Commands

  • We can make our Mac talk to us with say 'Hello Codetony'

ZSH Configuration

  • open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, and themes
  1. zsh
    • http://ohmyz.sh/
    • https://github.com/robbyrussell/oh-my-zsh
    • https://github.com/robbyrussell/oh-my-zsh/wiki
    • https://github.com/robbyrussell/oh-my-zsh/wiki/Cheatsheet

Performance Optimizations:

  1. IDE too slow? We can increase its memory limit in the VM Options.
  • http://stackoverflow.com/questions/13578062/how-to-increase-ide-memory-limit-in-intellij-idea-on-mac

  • https://blog.jetbrains.com/idea/2006/04/configuring-intellij-idea-vm-options/

  • Go to HELP -> Edit Custom VM Options

  • Copy:

        -Xms128m
        -Xmx2048m
        -XX:MaxPermSize=350m
        -XX:ReservedCodeCacheSize=64m
        -XX:+UseCodeCacheFlushing
        -XX:+UseCompressedOops
    

Nice to knows:

  • We can also transfer over settings by creating a settings.jar going to EDIT -> Export Settings or EDIT -> Import Settings to transfering settings.