Solving Sluggish Paste in Zsh

Pasting a long string in the terminal may be very slow if you have syntax highlighting on for zsh. Set ZSH_HIGHLIGHT_MAXLENGTH before sourcing zsh-syntax-highlighting.zsh to prevent long strings from being parsed by the highlighter.

ZSH_HIGHLIGHT_MAXLENGTH=60
source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Tags: zsh

N%

Use 50% to go to the halfway point of the file.

See :h N% for the entry in Vim’s help.

Tags: vim

Tabs in Vim

In Vim, a buffer is a file in memory. A window is a viewport of buffer. A tab is a layout of windows. Oftentimes, you would find yourself splitting the screen into multiple windows for several buffers.

However, this screen is just one tab page. To preserve the window layout, we can do :tabnew or :tabe <file>. This will create a new tab page for us, leaving the first tab page and its windows intact. You can also use C-w T on any existing window to move it to a new tab. Use gt or :tabn to navigate to the next tab page, and gT or :tabp to go back to the previous tab page.

Tabs are useful when you need to do something out of context. For instance, while you code in the first tab, you open a new tab for help with :tab help ,. You could also dedicate a tab just for diff viewing.

Comma in Vim

,           Repeat latest f, t, F or T in opposite direction
            [count] times. See also |cpo-;|

Tags: vim

Vim Motions for HTML Tags

When working with HTML tags in Vim, it and at can be quite useful. it means “inner tag block”, while at means “a tag block”.

To change “Hello World” to “Goodbye”, we just need to position our anywhere in the <p> tag, and do cit then Goodbye:

<div>
  <p>Hello World</p>
   ^ (citGoodbye)
</div>
---
<div>
  <p>Goodbye</p>
</div>

To delete the entire <div> block, we can position our cursor on the <div> tag, and do dat:

<div>
^ (dat)
  <p>Goodbye</p>
</div>
---