First of all, the title is a bit broad. This article is just to share some shortcuts and habits that I usually use. I hope it can help your daily development efficiency. [[219579]] As for why to write? There are several reasons: - At work, I found that some iOS partners, when developing, usually search layer by layer in the project directory, such as when quickly opening a class file, etc. I hope this article can improve their development happiness.
- I think I know a lot of shortcut keys, but I still learned a few practical ones from my colleagues. This article is just a record to share some tips I usually develop. If you have any better tips after reading it, you can leave a message to share with me. It is equivalent to throwing out bricks for jade. I will continue to update ~ I hope everyone can be a lazy programmer (my definition of lazy programmer is at the end of the article).
Mouse and Touchpad If you use an iMac, you mostly use an Apple mouse. The Apple mouse can be set with smart gestures. There are tutorials and settings in the System Preferences. You can take a look. Every time I see my colleagues still using the iMac mouse as a Windows mouse, I really want to say that the high price of this mouse is justified. mouse: - Swipe right with one finger to return, and you don’t have to click every time in Xcode to return to the previous class.
- Use two fingers to swipe left or right to switch desktops. MacOS has multiple desktops, which can be used to store UI, code, interface documents, etc.
- Tapping with two fingers is equivalent to the shortcut key Miss Control above F3, which is very convenient.
Touchpad: Basically the same as a mouse, to switch desktops, swipe left or right with three fingers, and to Miss Control, swipe upward with three fingers. Okay, without further ado, let’s get straight to the point. I’ll sort by the frequency of use of the shortcut keys by default, and I hope everyone can give it a try. In Xcode - Shift + Command + O pops up the quick file search window (this is the letter O, and the number 0 after Markdown O looks like 0). Shift + Command + 0 is the shortcut key to quickly open the official document.
- Shift + Command + j locates the directory where the file is located, often used in conjunction with the shortcut key above.
- Control + Command + Up\Down to switch between .m and .h.
- Command + t creates a new Tab, which is very practical. I usually create 3 or 4 Tabs. To close a Tab, you can use Command + w.
- If you are not used to opening multiple Tabs and are used to opening multiple Xcode windows, you can use Command + ` to switch between them.
- Control + Command + e can batch modify the variables at the cursor position, like this
- Shift + Command + f opens the global search. Of course, you can hold down the Command key and press 4 twice in a row to focus on the global search. I have to say here that searching Xcode not only supports text matching, the most commonly used method is to add an Any regular expression, which can search for results like the one shown in the picture, and so on.
- Command + f searches within a class, enter matches the next one and Shift + enter matches the previous one.
- Command + Up\Down\Left\Right cursor switches to the beginning of the class, the end of the class, the beginning of the line, and the end of the line.
- alt + left\right cursor moves one word left or right.
- Command + delete deletes the content from the cursor to the beginning of the line. Similarly, alt + delete deletes the word before the cursor. In addition, you can switch to the end of the line and use Command + delete to delete an entire line.
- Similarly, Command + Shift and Command + alt plus the arrow keys can select an entire row or multiple rows.
- Select a section of code and press Control + i to automatically indent it.
- Command + \ adds a breakpoint to the current line, alt + Command + \ creates a new symbolic breakpoint.
- Command + n to create a new file, Shift + Command + n to create a new project
- alt + Command + Fold left\right\display the current block, Shift + alt + Command + Fold left\right\display the blocks in the current file.
- Control + Command + [ moves up. If not selected, the current line is moved up by default. Control + Command + ] moves down.
- Command + ] indents to the right, supports multiple lines, Command + [ indents to the left.
- Shift + Command + k product to clean, Command + r to Run, Command + b to compile.
- There is also an important shortcut key, ☝️, Control + Command + p quick import, like this,
Pretty cool, right? You need to import a tool to achieve this, you can click here. Xcode 9 has used similar plug-ins before to achieve this function. I also used Peak's FastStub-Xcode before, which was also pretty cool. Xcode window related - Shift + Command + Y hides\shows the console area, but I recommend using Shift + Command + C to show the console area, which will directly focus the effect.
- Command + k console clears the screen.
- Control + 1 This is probably not used by many engineers. Of course, you can also click the small icon.
- As shown in the figure, you can see all the callers, imported files, and other related dependencies. You can also find the recently opened files, Recent Files
- Control + 6 to view the method list of the current class. It is recommended to use pragma mark to divide the methods into blocks. For related extended reading, please see the code standard suggestions here.
- Command + 1,2,3,4,5,6,7,8,9 switch the left window, Command + 0 show\hide the left window.
- Alt + Command + 0 shows\hides the right window. Similarly, Alt + Command + 1, 2, etc. can also switch.
- Command + , pop up Perferences, you can hide it with Command + w
other - There is also a multi-line editor, which is sometimes used. You need to use Sublime Text. The shortcut key is Shift + Command + L. To exit multi-line editing, you also need to press Shift + Command + L.
- Shift + Command + 3 takes a full-screen screenshot, Shift + Command + 4 takes a screenshot of a selected area, and Shift + Command + 4 + Space takes a screenshot of a specific window.
- Command + F3 to quickly view the desktop.
- Control + Command + Space to pop up the emoji input box.
tool I recommend you to install CheatSheet, then long press Command to view all shortcut keys. Off topic: I would like to recommend an application to everyone, Noizio, an environmental noise simulation tool that can simulate being in a cafe, at the beach, etc. About Lazy Programmers Laziness is actually a compliment to programmers. The laziness here is not laziness in the conventional sense. Maybe you have heard that laziness is the greatest virtue of programmers. Laziness will make programmers think of better solutions to solve the problems at hand, which often results in saving a lot of physical labor and achieving the same needs in the most elegant and convenient way. To give a practical example, our recent project introduced internationalization. As we all know, translation is really a physical job. My colleagues wrote a script in Python that can automatically detect the text that needs to be translated and automatically write it to the corresponding Localization file and the location of the text code, which greatly saves physical labor. This is the excellent virtue of laziness. *** If you have any good shortcuts or ideas to improve efficiency, please leave a message to share with me, so that I can add some good habits. At the same time, I will update this article. Thank you! I hope everyone can become a lazy programmer. Isn’t it good to use the time saved to have a cup of coffee? |