2021年11月6日 星期六

VIM Script 8.0.xx not execute channel command right away

 

I encountered this issue while developing my vim plugins. Although, 

Env/Platform: 

    VIM 8.0.1365

    MAC OS X Mojave

 

Problem: 

    When server send a channel command to VIM client, there is a notable gap between the command receiving time and execution starting time. In my case, the delay is about 4 seconds. With this delay, plugins for realtime application such as autocomplete, linting and highlighting will results  poor user experience. 

    To identify this problem, we can use channel log, for example, in command line type the following command:

    :call ch_logfile(''my_ch.log")

After channel command is done, we can check time-stamps in my_ch.log: 

    x.xxxxx On 0, RECV ["call", "MyFunc"]

    y.yyyyy Call MyFunc 

y.yyyy, x.xxxxx are time-stamps

 

Solution: 

    This issue seems a buffering issue because when VIM send message to server right after receiving  channel command, the channel command will be executed immediately. I guess the VIM is simply waiting  for some events before start to to command. To solve this, update VIM to 8.2.





2021年7月31日 星期六

node.js npm指令基本用法 -1

前言:

npm (Node Package Management) 是node.js 用來管理套件(Module)安裝與環境的工具,在node.js安裝完成後·後續項目的開發皆須使用此工具來安裝需要的套件


基本用法:

1. 安裝 指定的Module (本地)

> cd <NodeProjectDir>

> npm install <ModuleName> 

Ex: 

> npm install lodash


2. 安裝 指定的Module (全域)

> npm install -g <ModuleName>

Ex: 

> npm install -g loadsh

PS: 使用-g 選項,npm會將模組安裝至系統目錄,所有的使用者皆可以使用此模組。相反的沒有-g選項則npm會將模組安裝Project目錄下的node_module目錄中。一般建議儘可能將Module安裝至Project目錄,確保Project使用的模組的相依性有被儲存到package.jason,未來在新的環境需要重新安裝所有的模組時可以避免遺漏。

3. 移除 指定的Module 

> npm uninstall <ModuleName>

> npm uninstall -g <ModuleName> 

Ex: 

> npm uninstall lodash



解決Mackbook macOS home, end, pageup, pagedown 按鍵無法使用的問題

前言:

使用一般的PC鍵盤或是藍芽鍵盤連接Macbook時經常會遇到的問題是某些功能按鍵沒有如預期般的起作用,例如常用的home, end鍵與pageup, pagedown鍵等等。

問題發生的原因:

Macbook本身並沒有這些功能性按鍵,取而代之的類似的功能都是透過快速鍵來實現,例如:
1. HOME:⌘+ ← 
2. END     : ⌘+→
換句話說的一般PC鍵盤上的功能按鍵沒有功能是很正常的。

解決方法:

解決方式有兩種·
1. 學習使用mac的快速鍵 
完整的macOs快速鍵可以到蘋果電腦的支援網站查詢:

2. 使用修改KeyMapping 的方式將功能按鍵對應到期望的功能
有興趣的人可以參考下面的文章裡面有詳細的說明:

我把文章內介紹的方法整理在下方以便未來參考:
Step1. 新增~/Library/KeyBindings 目錄
Step2: 在~/Library/KeyBindings 內建立一個文字檔案‘DefaultKeyBinding.dict’,輸入下面的內容並且存檔:

{

    "\UF729"  = moveToBeginningOfLine:; // home

    "\UF72B"  = moveToEndOfLine:; // end

    "$\UF729" = moveToBeginningOfLineAndModifySelection:; // shift-home

    "$\UF72B" = moveToEndOfLineAndModifySelection:; // shift-end

 

Step3. 重新啟動應用程式,順利的話home/end/pageup/pagedown就可以使用囉!










2019年6月7日 星期五

解決macOS上Visual Studio Code (VsCode) VIM plugins 按鍵重複失效的問題

前言:

對於習慣使用VIM的人來說,剛進入VsCode (Visual Studio Code)環境最不習慣的應該是無法使用VIM常用的操作方式,例如使用hjkl進行游標上下左右的移動或是在command mode 下使用:w 做存檔的動作。幸好VsCode的Marketpalce 上有一個VIM plugin 在VsCode 下模擬(emulate) VIM 的操作環境,讓習慣使用VIM的人可以有一個選擇來使用自己習慣的編輯器環境。

如何安裝:

安裝方式很簡單,只需要在Extensions視窗中收尋vim,找到說明是vim emulation ... 的plugin 安裝即可。安裝完後馬上大家應該可以發覺在編輯器畫面已經可以開始使用VIM的相關命令了,不管是移動或是檔案操作甚至是搜尋取代都與VIM完全一致,基本上這個套件模仿VIM的完成度相當不錯。

使用上的問題:

MacOS的使用者在使用方式上與Window並無不同,不過習慣使用hjkl進行連續移動的人會感受到一個明顯的差異就是持續按著這些按鍵只會移動一次而無法進行連續的移動。主要原因是MacOS預設為每個Application關閉重複鍵功能,

解決方法:

解決方式就是為VsCode開啟重複按鍵功能,其實流程VIM plugin已經寫在它的說明中,如果不幸沒看到它的說明同時剛好在網路上搜尋到這篇文章人可以使用下面的流程來處理:
1. 開啟終端機視窗 (Spotlight搜尋 ->  輸入Terminal -> 執行)
2. 在終端機中輸入下面的命令

a> defaults write com.microsoft.VSCodeInsiders ApplePressAndHoldEnabled -bool false

b> defaults write com.microsoft.VSCodeInsiders ApplePressAndHoldEnabled -bool false

3. 重新啟動VsCode (PS: 必須完全關閉該程式後再重新啟動)

大至上完成以下的流程就可以恢復重複按鍵的功能,也可以使用hjkl順利地移動游標了,祝大家使用愉快。

2016年10月20日 星期四

Python Learning Material

最近開始學習Python,這邊蒐集一些網路上不錯的學習資源。


Here is learning material collection for Python:



Pyton 台灣使用者群組: 第一次使用就上手

A Byte of Python

"A Byte of Python" is very suitable for a C/C++ or Perl programmer who just starts to learn Python.
The author has introduced Python's syntax clearly and very easy to understand. Moreover, while explaining important concepts, the author usually gives some difference highlights  to C/C++ or Perl to help readers to capture the sprit of Python. This book is very useful.


Python.org Documents

Python.org 提供的文件,包含語法以及模組的完整使用說明以及範例。如果對模組的使用有疑問,建議來這邊找資料。


Install Python 3.x on Mac OS X

The pre-installed python in Mac OS X Yosemite is Python 2.x.
(not sure the pre-installed version of later version: EI Caption and Seirra)

To use Python 3.x, we have to install it by ourself. Thanks for Internet and may contributors on it, there are many instructions about how to install Python 3.x on Mac.

I choose one of them below and made some note for the problems that encountered during installation.

2016年8月5日 星期五

Tcl 學習資源


Tcl 學習資源
TCL Leaning Material and References

Tcl Tutorial