~/.vimrc のみが含まれています
so ~/config/vim/vimrc
~/config/vim/vimrc には、通常のオプション、いくつかのマッピング、およびさまざまなファイルタイプのソースファイルが含まれています。
autocmd FileType cpp so ~/config/vim/filetype/cpp.vimrc
そして、そのファイルで、次の関数を定義しました。これは、二重の包含を避けるために、新しい cpp ヘッダーを開くたびに呼び出す必要があります。
python import vim
function! s:insert_gates()
python << endPython
hpp = vim.current.buffer.name
hpp = hpp[hpp.rfind('/') + 1:]
hpp = hpp.upper()
hpp = hpp.replace('.', '_')
vim.current.buffer.append("#ifndef " + hpp)
vim.current.buffer.append("# define " + hpp)
vim.current.buffer.append("")
vim.current.buffer.append("#endif")
endPython
endfunction
autocmd BufNewFile *.hpp call <SID>insert_gates()
そして、シェルに次のことを要求すると:
vim -O3 t1.hpp t2.hpp t3.hpp
私が得た:
| |#ifndef T2_HPP |#ifndef T3_HPP |
| |# define T2_HPP |# define T3_HPP |
| | | |
| |#endif |#endif |
| | |#ifndef T3_HPP |
| | |# define T3_HPP |
| | | |
| | |#endif |
| | | |
|_____________________|_____________________|_____________________|
|t1.h |t2.h |t3.h |
それはまさに私が望んでいるものではありません.私の間違いがわかりますか?ありがとう。