Skip to content

RockHong/vim-env

Repository files navigation

Thanks to pathogen and git, the configuration and plugins of vim can be well managed and under version control.

Installation

First you need vim installed. For Linux/cygwin, usually vim is already there. For Windows, download it from official site.

To make all vim plugins work, you need to install other programs:

  • ctags
    Use it for some plugins for code completion and symbol finding
  • the silver searcher
    To use ack.vim plugin on Windows, install it first. One way to install is that downloading the source, and using make/gcc on cygwin to build.
  • Ack
    Need it to use ack.vim plugin on Linux. (Though it's also possible to install it on Windows, and make it as the back-end of ack.vim.)

Linux/cygwin

Download this repository by using git clone or other means.

Go into the directory of this repository, and run (not . install.sh)

./install.sh

Test: open vim and enter ,d. If a window shows up in left side of vim, then it proves that vim plugin works.

Windows 7/10

Clone this repository.

Windows also supports hard link and symbolic link (at least on Windows 10). Run "cmd" as administrator, and run following commands,

c:\Users\hong>mklink /d vimfiles c:\repos\vim-env
symbolic link created for vimfiles <<===>> c:\repos\vim-env

c:\Users\hong>mklink _vimrc c:\repos\vim-env\vimrc
symbolic link created for _vimrc <<===>> c:\repos\vim-env\vimrc

c:\Users\hong>mklink _gvimrc c:\repos\vim-env\gvimrc
symbolic link created for _gvimrc <<===>> c:\repos\vim-env\gvimrc

Or you can make a hard copy. Copy repo to HOME directory (for example, C:\Users\SomeUser), and rename it to "vimfiles".

Copy "vimfiles/vimrc" to "HOME/_vimrc".

Copy "vimfiles/gvimrc" to "HOME/_gvimrc".

Copy "vimfiles/gvimrc.custom" to "HOME/gvimrc.custom".

Vim Configuration

Vim configuration like settings and key-mappings can be found in vimrc.

Plugins

NERD tree

NERD tree allows you to explore file-system and to open files and directories.

In vim's normal mode, input ,d to bring out NERDtree plugin. In NERDtree tree windows, press ? to show help. See more help via :help NERDtree.

Snapshot NERDtree

ctrlp

ctrlp can be used to quickly open files. In vim normal mode, enter Ctrl+P to bring out this plugin.

Snapshot ctrlp

ctrlp is not powerful for a big project. It says command-t is faster alternate, but it needs Ruby supporting in vim. Liang Jian's symfind is very fast for big project, which, however, I am not sure compatible with pathogen or not.

See more help via :help ctrlp.

Supertab

Supertab is a vim plugin which allows you to use for all your insert completion needs.

The following snapshot shows that you input xyz, then press Tab, supertab will help you complete. supertab

See more help via :help supertab and :help ins-completion.

omnicppcomplete

Supertab is lightweight completion plugin, while omnicppcomplete is more heavy, powerful, and suitable for large C++ projects. A completion begins when you enter . or ->. You can also trigger completion in insert mode explicitly using CTRL-X CTRL-O.

Snapshot omnicppcomplete

To let omnicppcomplete/vim knows symbols, ctags needs to be run first. Run ctags in vim by :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ., or Ctrl-F12.

See more by :help omnicppcomplete.

ack.vim

ack.vim is like grep, but it will show its searching result in vim's Quickfix window, so that you can easily jump to.

Snapshot (searching string "xyz" in current working directory) ack.vim

ack.vim needs a back-end program to as its searching engine. In this repository, ack.vim uses Ack as the back-end on Linux, and use the silver searcher on Windows.

It's slow to search in a very large project. To search symbols in a large project, you can use ctags or Liang Jian's symfind.

See more help via :help ack.

If your system has not ack installed, please refer to this doc.

tagbar

tagbar "is a vim plugin for browsing the tags of source code files. It provides a sidebar that displays the ctags-generated tags of the current file, ordered by their scope."

tagbar also needs running ctags firstly.

See more help via :help tagbar.

NERDCommenter

Comment code. See more by :help NERDCommenter.

Using ctags

Use ctags to build tags, then you can browser symbols in C++ project. Run ctags in vim by :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ., or Ctrl-F12.

Ctrl-]            Jump to the tag underneath the cursor
:ts <tag> <RET>   Search for a particular tag
:tn               Go to the next definition for the last tag
:tp               Go to the previous definition for the last tag
:ts               List all of the definitions of the last tag
Ctrl-t            Jump back up in the tag stack

See more help via :help tags-and-searches.

Liang Jian's symfind is another option for symbol looking up.

Others

###color scheme It says solarized is good color scheme. There is a plugin for it. Maybe you don't need it, if your terminal also has that color scheme.

###On Windows 7 If encounter problem with ^M, run the following command in cygwin (create a new git branch first for more safety),

$ find . -type f -exec dos2unix '{}' \;

Feel free to tinker on this repository