Vim Advanced - Day 8

  1. q: Show command history; q/ Show history for searches

How to remap complex shortcuts using Karabiner Elements

We can use Karabiner Complex Modification online editor to finish such work.

Links

  1. Karabiner-Elements complex_modifications rules

How to disable Mac's radius corner of the window

Tested on Catalina 10.15.3 | Last Updated: Wed Apr 8 22:32:32 CST 2020

  1. Disable SIP (There are lots tutorial online to teach you how to do it, will not expand the details here)

  2. Install ThemeEngine (Note: only this build supports catalina 10.15)

  3. Make system volume writable: sudo mount / -uw

  4. Backup original theme resources: rsync -rI /System/Library/CoreServices/SystemAppearance.bundle/Contents/Resources/ .

  5. Create a new folder for editing the theme file: mkdir edited && cd edited

  6. Copy a theme file here and edit it (SystemApperance.car for the light theme and DarkAquaAppearance.car for the dark theme). Take SystemAppearance.car as an example:

    1
    2
    cp ../SystemAppearance.car .
    open . # Open this folder with finder

  7. Double click the file SystemAppearance.car to edit it with ThemeEngine that we installed before

  8. Edit WindowFrame_WindowShapeEdges

    • Replace masks to squares
    • Replace base images to pure transparent images
  9. Save all changes, replace the modified SystemAppearance.car back to the system path.

    1
    sudo cp SystemAppearance.car /System/Library/CoreServices/SystemAppearance.bundle/Contents/Resources/

  10. Reboot

Links

  1. ThemeEngine - GitHub
  2. macOS Mojave disable all 4 rounded window corners either with defaults, or software, or programatically
  3. square-macos-windows - GitHub

How we manage icons in Rocket.Chat?

  • 2020-3-6
  1. Add a new SVG icon file into app/ui-master/public/icons folder
  2. Run the automation script node ../generateSprite.js to generate icons.svg from those SVG files in the above folder. (the SVG's filename is exactly the icons' identifier)
  3. In the meteor.startup callback function, using Asset.getText to download icons.svg file as plain text to the client first, and then with the help of injectIntoBody function to insert the entire content as raw text into the body.

Note: the generated icons.svg the file contains multiple icons, where we use the tag symbol as a delimiter.

Remove default ABC input method on Mac

  • 2020-3-5

TL;DR

1
code ~/Library/Preferences/com.apple.HIToolbox.plist

Delete the dict that represents the ABC method and it will take effect after rebooting the system.

Vim & VSCode Advanced - Day 7

  • 2020-3-4

Vim

  1. :tabo[nly] Close all tabs except the active one; :tabnew Create a new tab; :tabNext Move to the next tab; :tabprevious Move to the previous tab;
  2. :pwd Print the current working directory
  3. Use / search to move the sursor faster
  4. Use relative line numbers.
  5. :his[tory] to list command history
  6. Text Obejcts: i/a/ys/cs + w/s/p/]/)/"/'/t
  7. Parameterized Text Objects:
    • f, F => "find" the next character
    • t, T => up to the next character
    • / => Search (up to the next character)

Code

  1. command+t Search symbol in the file
  2. command+shift+t Search symbol in the workspace
  3. command+b Show/Hide activity bar
  4. ctrl+p Go to file
  5. command+p Git: push changes to the remote

Ref:

  1. Learning Vim in a Week
  2. Mastering the Vim Language
  3. 20 VS Code Shortcuts for Faster Coding

Vim Advanced - Day 6

  • 2020-3-3
  1. C-n In the native Vim, we can use this shortcut to achieve keyword completion. But in the VSCodeVim the behavior is something different because completion is the killer feature equipped with VSCode that you don't need to type any extra keys to open completion window. So C-n here means toggling cursor among all available candidates.
  2. The Vim supports scp protocol and you can use vim scp://aliyun/Downloads/app.js to edit app.js file under ~/Downloads directory in your remote aliyun machine.
  3. Local Bookmarks Management
    • :marks [a-zA-Z] List all bookmarks (or specified bookmarks only)
    • m+a-z Create a local bookmark
    • m+A-Z Create a global bookmark
    • `+a-zA-Z Jump to the bookmark
    • '+a-zA-Z Jump to the bookmark (stop at the beginning of your bookmarked line)
    Combined with the powerful C-o (Jump backward the cursor's location) and C-i (Jump forward the cursor's location), we can move the cursor from place to place easily.

Ref: Why I love Vim: It’s the lesser-known features that make it so amazing

Vim Advanced - Day 5

  • 2020-3-2
  1. g+i insert at the end of last change
  2. Insert Mode: C-o command execute command and return to Insert Mode
  3. g+J: like "J", but without inserting spaces
  4. :reg {arg} show the contents of registers mentioned in {arg}, using spaces to separate multiple args
  5. Y, g+g: yank N lines into a register
  6. ]+p: like p, but adjust indent to current line
  7. [+p: like P, but adjust indent to current line
  8. g+p: like p, but leave cursor after the new text
  9. g+P: like P, but leave cursor after the new text
  10. u undo last change
  11. C-r redo last change
  12. U restore last changed line

Vim Advanced - Day 4

  • 2020-3-1
  1. Number+| Jump to the column Number
  2. Visual mode: o toggle cursor position between the beginning and the end of the highlighting
  3. Visual mode: c-q or c-v enter visual-block mode
  4. Visual mode: g+v start highlighting on previous visual area
  5. Notice the key l. We always use this key to move right but forget another function that it has - It represents the character under cursor. That is to say, if you want to perform an operation on the char under cursor, we can use l to represent it. For instance, we can use y+s+l+surroundings enclose the char with the surroundings we provided.
  6. g+m to the middle of the line

Ref:

  1. Learn Vim For the Last Tiem: A Tutorial and Primer
  2. VSCodeVim Roadmap

Vim Advanced - Day 3

  • 2020-2-29
  1. g+a Show ASCII value of character under cursor
  2. <+< Shift lines to left
  3. >+> Shift lines to right
  4. C-a Increase number under cursor
  5. y+s+text-object+surrondings Enclose the text object with surroundings
  6. c+s+text-object+old-surrondings+new-surrondings Change the surrondings of the text object
  7. d+s+text-object+surrondings ReMove the surroundings of the text object
  8. V enter visual line mode first; S+surrondings add surrondings linewise. (for instance, V C <p class='important'>)
  9. Nouns: w: word; s: sentence; p: paragraph; t tag;
  10. D Remove the text after the cursor of the current line, which is similar to C (C will also enter into insert mode)
  11. * Search for other instances of the word under your cursor
  12. ^ Move to the first non-blank character in the line, which is a little different from 0 (Move to the beginning of the line)
  13. $ Move to the end of the line
  14. Move by word: w/W: Move forward one word; b/B Move back one word; e/E Move to the end of the word;
  15. Move by sentence: ( Move back one sentence; ) Move forward one sentence
  16. Move by paragraph: { Move back one paragraph; } Move forward one paragraph
  17. Move by screen: H Move to the top of the screen; M Move to the middle of the scrren; L Move to the bottom of the screen; C-u Move up half a screen; C-d Move down half a screen
  18. Move by file: gg Move to the beginning of the file; G Move to the end of the file
  19. C-i Jump forward the cursor's location; C-o Jump backward the cursor's location (I guess Vim maintains a cursor location stack to achieve it)
  20. s delete the character under cursor and enter into insert mode (think about x)
  21. S dlete the current line and enter into insert mode, which equals to c+c
  22. Substitution: :%s/foo/bar/gc Replace "foo" to "bar" on every line with confirm (! Note that :%s/foo/bar/cg is not working, the sequence of c and g is sensitive); :s/foo/bar/gc Replace "foo" to "bar" on current line
  23. / Search forward; ? Search backward

Ref: Learn Vim For the Last Tiem: A Tutorial and Primer