Share

blog-header

Quick Coding Using Shortcut

 

Are you aware of how using shortcuts makes your work easier and faster while writing code? If not, you are in the right place. Let’s raise awareness together ?

 

Have you ever had to use your computer entirely from the keyboard without a mouse? If you have experienced this, you may have realized that you can do almost anything you want on the computer with just the use of the keyboard. We will address exactly this point. The important thing here is to put as much distance as possible in your relationship with the mouse ? This means that almost everything you do with the mouse must be done with the keyboard. You will gain time and speed as your hands will never leave the keyboard. This will actually be a waste of time while doing a normal operation such as surfing the Internet, but it will speed up your code while writing.

Since I am using a computer with MacOS operating system, the information I give will be on Mac. At the same time, I will give the shotcuts specific to Mac, but if you are using a different operating system, you can find the shortcut by trying your equivalents of the same keys.

For example, the equivalent keys on the Windows keyboard:

  • Mac: Command ~ Windows: Ctrl
  • Mac: Option ~ Windows: Alt
  • Apart from these, you may also need home and end keys on Windows unlike Mac.

 

Before I start shortcuts, let me briefly talk about the different things that I would like to recommend that can speed you up.

 

  1. English Keyboard (US Layout):klavyeklavyeAs you know, the language of the software is English. For this reason, the characters used in the syntax of the software languages ​​will be at hand on the English keyboard. For example, when you want to open a curly brace on the Turkish keyboard, you have to press the option + 7 keys and these are the keys that can be considered far from each other. On the English keyboard, you need to do the shift + [ key combination. Since these are closer keys to each other, they require less effort and reach your goal faster, albeit in milliseconds. You may have even noticed that square brackets are a key in themselves on the English keyboard. In this way, you do not need to make combinations as in the Turkish keyboard. Or as another example, while the slash is a key on the English keyboard, you need to do a combination like shift + 7 on the Turkish keyboard. Yes, these may not sound like a factor that affects speed, but once you get used to it, you can be sure that you will code faster than your Turkish keyboard speed. Of course, this is still a matter of preference. You may be accustomed to the Turkish keyboard and typing code very quickly. Up to you 🙂
  2. CopyClip (App):Shortcut Kullanımı ile Hızlı Kod YazmakThe shortcut we all use the most will indisputably be cmd + c & cmd + v 🙂 Copy & paste shotcut is very necessary in our daily life. We also use it a lot when writing code. But for example, sometimes we need to copy more than one thing in order, and copying them one by one and then pasting them one by one becomes time-consuming and annoying. This is where the CopyClip app comes to our rescue. With this app, you can access your last 80 copies and copy them again with shortcuts. This app is available for free download for Mac. You can find such apps for different operating systems. The only bad thing of this app is that you have to click on the app from the menu bar to copy it again from the clipboard. This requires the use of a mouse 🙁 But there are equivalent apps. In a paid app, you could reach and select the last few copies with keyboard shortcuts without using a mouse. If there is a free version of such an app and if you know/find it, don’t forget to let me know 🙂

 

Using Shortcut in the Code Editor

 

An acceptable part of software developers around the world use VS Code as a code editor. I also use this editor in the same way. But as far as I know, you can run the same shortcuts in other code editors in the same way. However, as I mentioned, I am using VS Code.

 

Let’s come to the actual shortcuts that will speed you up while writing code.

 

  1. Copy Entire Line (Command + C): With this shortcut, you can copy the entire line you are on without selecting anything.Shortcut Kullanımı ile Hızlı Kod Yazmak
  2. Cut Entire Line (Command + X): With this shortcut, you can cut the entire line without selecting anything.Shortcut Kullanımı ile Hızlı Kod Yazmak
  3. Navigating Between Words (Option+ Right/Left Arrow Keys): For example, let’s say you realize that you misspelled a word on the same line while writing code, and let’s reach that word together without using the mouse. For this, you can go left and right word by word with option + arrow key.Shortcut Kullanımı ile Hızlı Kod Yazmak
  4. Getting to the Beginning/End of a Line (Command + Right/Left Arrow Keys): You don’t need to waste your seconds with the arrow keys to get to the beginning or the end of a line. You can reach the beginning or the end of the line in one move with the combination of cmd + arrow key.Shortcut Kullanımı ile Hızlı Kod Yazmak
  5. Getting to Top/Bottom of File (Command + Up/Down Arrow Keys): You don’t need to scroll with the mouse to get to the beginning or the end of a file. You can reach the beginning or end of the file with the cmd + arrow key combination.
  6. Word Selection (Option + Shift + Right/Left Arrow Keys): If you want to select the word in a line to copy or delete later, you can select it with option + shift + arrow key.Shortcut Kullanımı ile Hızlı Kod Yazmak
  7. Line Selection (Command+ Shift + Right/Left Arrow Keys): Normally, you can use cmd + a shortcut to select the whole file, but if you want to select a certain line, not the whole file, you can select it with cmd + shift + arrow key.Shortcut Kullanımı ile Hızlı Kod Yazmak
  8. Line Duplication (Option + Shift + Up/Down Arrow Keys): If you want to duplicate one or more lines; No need to select and copy paste. You can duplicate it to the top or bottom of the line with option + shift + arrow key.Shortcut Kullanımı ile Hızlı Kod Yazmak
  9. Line Move (Option + Up/Down Arrow Keys): If you want to move a line up or down, you don’t need to copy paste the line or cut and paste the line. You can move the line up or down with option + arrow key.Shortcut Kullanımı ile Hızlı Kod Yazmak
  10. Scroll with Keyboard (Fn + Control + Up/Down Arrow Keys): If you want to scroll a file without using a mouse, you can use the fn + control + arrow key combination.
  11. Reach Top or Bottom Along Screen Height (Fn + Up/Down Arrow Keys): You can use the fn + arrow key combination to reach the top or bottom of the visible part of a file.Shortcut Kullanımı ile Hızlı Kod Yazmak
  12. Finding and Selecting the Same Word or Line in the File (Command + D): For example, let’s select a word in the file with the option + shift + direction key combination. Suppose we want to add something to the end of the word we have chosen. For this, after selecting the word, we can select the same word(s) on the page one by one with cmd + d. If there are 20 of those words in the file, for example, you need to do 20 cmd + d combinations. For this reason, if there are too many of the same words, if we press the cmd + d combination once and do not lift our hands from the keys, we will be able to select all the same words in the file. After selecting these words, you can reach the area you want to edit in the word with the arrow keys. Your change will be reflected in all selected words. In this way, you will have made more than one change with a single change.
  13. Making Changes Along the Same Line of Multiple Lines (Option + Command + Up/Down Arrow Keys): Let’s say there are 4 of the same lines in a file and we want to put a dot at the end of these lines. After reaching the end of the top line, you can select the bottom lines with the option + cmd + down arrow combination and make the change you want to make in one go.Shortcut Kullanımı ile Hızlı Kod Yazmak
  14. Word Deletion (Option + Delete): If you want to delete a whole word, you can delete it with option + delete.Shortcut Kullanımı ile Hızlı Kod Yazmak
  15. Line Deletion (Command + Delete): If you want to delete an entire line, you can delete it with cmd + delete.Shortcut Kullanımı ile Hızlı Kod Yazmak
  16. Line Shift (Option + Z): When one or more lines do not fit the screen width, you can scroll down the screen width with option + z to see the rest of the line.Shortcut Kullanımı ile Hızlı Kod Yazmak
  17. Tab Switching (Option + Command + Right/Left Arrow Keys): You can actually use control + tab to switch tabs in the editor, as most people know, or control + shift + tab to switch backwards. But there is another shortcut that is easier and more useful than this. It’s option + cmd + arrow key. With this combination, you can easily switch between open files in the editor.Shortcut Kullanımı ile Hızlı Kod Yazmak

 

You can try all these shortcuts yourself and see in which scenarios they can work for you. Maybe you will discover a different combination of these keys and find an item that I skipped 🙂 In that case, don’t forget to let me know!

I hope you liked my blog post and the information I have provided will be of use to you. I wish bug-free coding 🙂

 

References:

https://www.apple.com/shop/product/MK2A3LL/A/magic-keyboard-us-english

 

Perfist Blog

Similar Articles

Other Articles