网上找到两篇文章,为我成功编译vim打下基础,不过两篇文章都有些缺陷导致编译不成功。
第一篇文章为:https://www.cnblogs.com/liangwode/p/5825128.html?utm_source=itdadao&utm_medium=referral
另一篇文章为:https://blog.csdn.net/feixiang3839/article/details/73772275
首先下载ncurses-5.9.tar.gz,从https://mirrors.sjtug.sjtu.edu.cn/gnu/ncurses/;
再下载vim7.4源码:ftp://ftp.vim.org/pub/vim/unix/,我表示这种国外的网站打开太难了。
下载后,解压缩并编译:
tar zxf ncurses-5.9.tar.gz
./configure --prefix=/home/dhn/install_ncurses --host=arm-linux-gnueabihf --without-cxx --without-cxx-binding --without-ada --without-manpages --without-progs --without-tests --with-shared
make && make install
vim的编译:
tar jxf vim-7.4.tar.bz2
cd vim74
./configure --host=arm-linux-gnueabihf --prefix=/opt/vim74 --with-features=huge --disable-gui --without-x --disable-selinux --disable-acl --disable-gpm --with-tlib=ncurses vim_cv_getcwd_broken=no vim_cv_memmove_handles_overlap=yes vim_cv_stat_ignores_slash=yes vim_cv_tgetent=zero vim_cv_terminfo=yes vim_cv_toupper_broken=no vim_cv_tty_group=root vim_cv_tty_mode=0620 CPPFLAGS=-I/home/dhn/install_ncurses/include/ncurses LDFLAGS=-L/home/dhn/install_ncurses/lib
make
vim的编译选项真的是太多了,不过上述configure命令你需要修改/home/dhn为/home/你的用户名。
编译vim后,make install会出错,此时在/opt中只有/opt/vim74/bin/vim,没有其他文件,我们再创建目录:
mkdir -p /opt/vim74/share/vim,然后拷贝文件:
cp -rf runtime/* /opt/vim74/share/vim/
将/opt/vim74打包:
cd /opt
tar zcf vim74.tar.gz vim74
将压缩包拷贝到开发板的linux系统中的/opt解压缩tar zxf vim74.tar.gz.
创建一个软连接 ln -s /opt/vim74/bin/vim /usr/bin/vim
在用户目录下放一个如下内容的.vimrc会更好用:
"set mouse=a
set nu
set backspace=indent,eol,start
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=1
let Tlist_File_Fold_Auto_Close=1
map <F4> :TlistToggle<CR>
noremap <F2> :w<CR>
noremap <F6> :make<CR>
noremap <S-F6> :make clean;make<CR>
noremap <F7> :Tlist<CR>
noremap <S-F7> :TlistSync<CR>
noremap <F3> :!./vitags.sh<CR>:cs reset<CR>
noremap <S-F3> :!cvs up<CR>
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set wrap
set hlsearch
"colorscheme default
"colorscheme elflord
colorscheme desert
"colorscheme blue
"colorscheme delek
"colorscheme evening
"colorscheme murphy
"colorscheme torte
"colorscheme daukblue
"colorscheme koehler.vim
"colorscheme pablo
"colorscheme ron
"colorscheme zellner
"colorscheme morning
"colorscheme peachpuff
"colorscheme shine
syntax on
set nocp
filetype plugin on
filetype indent on
if has("cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
set cscopetag
endif
set tabstop=4
set shiftwidth=4
"autocmd FileType python set expandtab
set ru
set hls
set is
set sm
set cin
set cino=:0g0t0(sus
"let Tlist_Ctags_Cmd = '/usr/bin/ctags'
set autoread " read open files again when changed outside Vim
"set autowrite " write a modified buffer on each :next , ...
"set browsedir =current " which directory to use for the file browser
set incsearch " use incremental search
set nowrap " do not wrap lines
"set visualbell " visual bell instead of beeping
set nobackup
set nowritebackup
map <C-F12> :!ctags -R --c-kinds=+p --fields=+iaS --extra=+q .<CR>
map <C-F11> :!ctags -R .<CR>
"-------------------------------------------------------------------------------
" Change the working directory to the directory containing the current file
"-------------------------------------------------------------------------------
"if has("autocmd")
" autocmd BufEnter * :lchdir %:p:h
"endif " has("autocmd")
" When editing a file, always jump to the last cursor position.
" This must be after the uncompress commands.
autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif