标签:
This is the second article(collection) on how to build a *nix development environment by integrating remote servers and local Linux/Mac clients. For the previous article on this topic, please refer to Building Remote+Local *nix Develop Environment.
Add following line into your $HOME/.vimrc
autocmd CursorMoved * exe printf(‘match IncSearch /\V\<%s\>/‘, escape(expand(‘<cword>‘), ‘/\‘))
Or use a more complicated one in the .vimrc:
" Highlight all instances of word under cursor, when idle." Useful when studying strange source code." Type z/ to toggle highlighting on/off.nnoremap z/ :if AutoHighlightToggle()<Bar>set hls<Bar>endif<CR>function! AutoHighlightToggle()let @/ = ‘‘if exists(‘#auto_highlight‘)au! auto_highlightaugroup! auto_highlightsetl updatetime=4000echo ‘Highlight current word: off‘return 0elseaugroup auto_highlightau!au CursorHold * let @/ = ‘\V\<‘.escape(expand(‘<cword>‘), ‘\‘).‘\>‘augroup endsetl updatetime=500echo ‘Highlight current word: ON‘return 1endifendfunction
If you have generated ctags file, then you can automatically load it by:
export CTAGS_TAG in $HOME/.bashrc by export
CTAGS_TAG=/path/to/your/tags.
add following lines into your $HOME/.vimrc
```Shell
if filereadable($CTAGS_TAG)set tags=$CTAGS_TAGendif
```
If you want to access the most recently used files in Vim, you need plugin MRU. The :MRU command
will show you all the recently used files, and you can choose a file and press <Enter> to open it
in current window. In addition
t key.<Enter> or v or o or t.q key or the <Esc> key
or using one of the Vim window commands.:MRU command, such as :MRU
<pattern>.
Vim runtimepath manager, widely used by many plugins. Adding call
pathogen#infect() to your .vimrc, then any plugins you wish to install can be extracted
to a subdirectory under ~/.vim/bundle. And they will be added to the runtimepath.
The NERD tree allows you to explore your filesystem and to open files and directories, and NERDTree Tabs can make NERDTree available for all Vim tabs(sometimes it is useful). After installing the these plugins, you can add the following lines to .vimrc.
" Nerd Tree" let g:NERDTreeDirArrows=0 " Do not use new arrows for directoriesmap <C-n> :NERDTreeToggle<CR>let g:nerdtree_tabs_open_on_gui_startup=0 " no nerdtree_tabs by default
For some Linux distributions, the NERDTree could not show arrows for directories, then you need to uncomment the line let
g:NERDTreeDirArrows=0 in your .vimrc.
Supertab is a vim plugin which allows you to use <Tab> for all your insert completion needs
(:help ins-completion).
These two plugins are used for searching/opening files(even not in ctags) in Vim. CtrlP is written in pure Vimscript, so it is very slow. Although Command-T is faster, it relies on Ruby, which makes it difficult to install. Actually, I rarely use them in daily work.
My vimrc can be found at https://github.com/bo-yang/misc/blob/master/vimrc.
Cscope is a tool for browsing source code. You can either run cscope standalone or use it with Vim. No matter in which way, you need to generate cscope database first. And the cscope DB depends on the source files you specified. General steps of using cscope are:
find /my/project/dir -name ‘*.c‘ -o -name ‘*.h‘ > /foo/cscope.filescd /foocscope -bCSCOPE_DB=/foo/cscope.out; export CSCOPE_DB
In Vim, you can load cscope DB by command :cs add <path_to_cscope_db>. For more cscope operations
in Vim, please run command :cs help. To automatically load cscope into Vim, you can export CSCOPE_DB in $HOME/.bashrc,
such as
export CSCOPE_DB=/path/to/cscope.out
Then the CSCOPE_DB will be automatically loaded every time you run Vim.
To save the effort of building cscope DB, I wrote a cross-platform(Linux & Mac OS X) wrapper script, which can be found in my GitHub channel.
Since sshfs command requires too much parameters, and things will be worse when the network
is not stable. Following script will ease your pain.
#!/bin/shUSER=<your_name>SERVER=<your_server>remote_dir=/nobackup/$USERlocal_dir=$HOME/Documents/VMsif [ ! -d ${local_dir} -o ! -s ${local_dir} ]thensudo umount -f $local_dirficd ${local_dir}sshfs $USER@${SERVER}:${remote_dir} ${local_dir}
- See more at: http://www.bo-yang.net/2014/12/19/remote-local-linux-develop-env-2/#sthash.7IdS3E6c.dpuf
Building Remote+Local *nix Develop Environment(II)
标签:
原文地址:http://blog.csdn.net/bonny95/article/details/42041701