在Linux 环境下用 Vim 编写 Javascript 代码,有哪些有效的方法...

如题所述

利用字典,需要整个js的函数字典,一行一个函数,unix换行。
/path/js/funclist.txt就是整理好的字典。在vim的插入模式下,按tab键,就会给出光标所在的单词的提示

在 .vimrc 添加如下内容:
setlocal dictionary-=/path/js/funclist.txt
dictionary+=/path/js/funclist.txt
" Use the dictionary completion
setlocal complete-=k complete+=k

func! InsertTabWrapper()
let col = col('.') - 1
if !col

getline('.')[col - 1] !~ '\k'
return "\ < tab > "
else
return "\ < c-p > "
endif
endfunction

" Remap the tab key to select action with InsertTabWrapper
inoremap < buffer > < tab > < c-r > =InsertTabWrapper() < cr >
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答