2021年3月20日 星期六

在vim加入clang-format的功能

 目的:

使用clang-format官網提供的方法加入排版功能

平台:

ubuntu 18.04

作法:

1. 在clang-format的官網裡面的Vim Integration有提到需要有clang-format.py這個檔案並可從這裡獲得。並且需要特過指令:

        sudo apt-get install clang-format

下載clang-format這個工具。

2. 從.vimrc加入以下內容

        imap <c-f> <c-o>:py3file ~/clang-format.py<cr>

3. 之後便可在vim的insert mode透過ctrl-f使目前的程式編排成google的coding style。


參考資料:

1. Clang 12 documentation CLANGFORMAT

沒有留言:

張貼留言