Installing and using VIM and its plugins (Pathogen and Nerdtree)

Source: Internet
Author: User
Tags parent directory

VIM Installation

Command: sudo apt-get install vim

Configuration:

Configure the VIM,/ETC/VIM/VIMRC file just fine, (I found a more powerful vim configuration file on the Internet, copied to the/ETC/VIM/VIMRC inside, the effect is good)

Configuration file: Http://files.cnblogs.com/files/xumenger/%E5%BC%BA%E5%A4%A7%E7%9A%84vim%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6.zip

Configure VIM to be used for all users in/ETC/VIM/VIMRC

Possible problems: When a normal user uses the VIM command, the config file inside the/ETC/VIM/VIMRC does not work, but it can be valid when the root user is using it.

The reason for this is as follows: configuring Vim in/ETC/VIM/VIMRC will work for all users. However, if the ~/.VIMRC for ordinary users to do the configuration, then will overwrite the/ETC/VIM/VIMRC inside for the normal user configuration, the result is/ETC/VIM/VIMRC to not specifically for their own configuration of the user effective, not as in the ~/.VIMRC in the configuration of the user effective , and ~/.VIMRC will be effective for ordinary users.

Final selection: Delete/ETC/VIM/VIMRC This configuration file, only configure ~/.VIMRC this for ordinary users of the file, later with vim to edit the text, the identity of ordinary users to edit it.

In fact, about the configuration of the plug-in and the general configuration are in the ~/.VIMRC inside, the difference is that the plug-in configuration needs to install the plug-in before the ~/.VIMRC to write configuration information, and the normal configuration can be directly in the ~/.VIMRC to write configuration information.

Plug-in Installation:

Preparatory work

First, back up your original. Vim configuration and create a new. Vim directory (. Vim in the ~ directory), and the bundle directory where the plug-in is placed: (The following command operation is performed by the normal user in the ~ directory)

1

2

3

$ mv. Vim{,.bak}

$ mv. Vimrc{,.bak}

$ MKDIR-PV. Vim/bundle

Then turn the. Vim directory into a Git repository. To do this is very simple, switch to the. Vim directory, execute the GIT init command, git will create a. Git directory:

1

2

3

4

5

6

7

8

$ cd. Vim && git init

> Initialized empty Git repository in/users/pw/.vim/.git/

$ ls-al

> Total 0

> drwxr-xr-x   4 pw  staff  136 feb  4 14:01.

> drwxr-xr-x   4 pw  staff  136 feb  4 14:01:

> drwxr-xr-x  pw  staff  340 feb  4 14:01. Git

> drwxr-xr-x   2 pw  staff   4 feb  bundle

At this point, the preparation is complete. The following commands, if not specifically stated, are typed in the. Vim directory.

1. installing pathogen

The commands to install the plugin are:

1

$ git submodule add plugin for git repository address bundle/plugin name

Pathogen will be the first plugin we've installed with Git:

1

2

3

4

5

6

7

$ git submodule add git:// Github.com/tpope/vim-pathogen.git Bundle/vim-pathogen

> Cloning into bundle/ Pathogen ...

> remote:counting objects:218, done.

> remote:compressing objects:100% (117/117), done.

> remote:total 218 (Delta), reused 202 (Delta)

> receiving objects:100% (218/218), 26.40 KiB | kib/s, done.

> resolving deltas:100% (59/59), done.

Generally speaking, a plugin is ready to use after downloading, but for pathogen this "plugin plug-in", more than one, create a very simple. vimrc file, load pathogen

1

2

$ echo-e "Runtime Bundle/vim-pathogen/autoload/pathogen.vim\ncall pathogen#infect () \nhelptags" >>. VIMRC

$ Ln-sf ' pwd '/.VIMRC $HOME/

And to install the Nerdtree plug-in in such a way, you must first install pathogen this plugin, the specific principle of: using Pathogen management vim plugin and hosted on GitHub

2. Install the nerdtree , the same method as the installation of pathogen, in the. Vim Directory execution:

1

$ git submodule add plugin for git repository address bundle/plugin name

Nerdtree, Warehouse address is git://github.com/scrooloose/nerdtree.git:

1

$ git submodule add git://github.com/scrooloose/nerdtree.git bundle/nerdtree

You can also download the package directly, unzip, move to ~/.vim/bundle inside, you can also directly use

nerdtree Common settings
Nerdtree to enter: Nerdtree, press Q when closed. You can also join the shortcut key to open
1. Vim ~/.VIMRC
2. Join this line
Nnoremap <silent> <F5>:nerdtree<cr>
3. Pressing F5 will automatically expand the directory tree


Common shortcut keys
CTRL + W + W cursor automatically toggles in left-right window
o Expand a directory on the left, and then click Merge Directory
T open the selected file/bookmark in the New tab and skip to the new tab
T Opens the selected file/bookmark in the New tab, but does not jump to the new tab
P jumps to the root node.
P jumps to the parent node.
Q Close Nerdtree window

Standard mode:
GT Front tab
GT after a tab

If you want to turn off a tab, use Vim's own command: Q or: Wq


Supplement
Switching tables and directories
CTRL + W + H cursor focus left tree directory
CTRL + W + L cursor focus right file display window
CTRL + W + W cursor automatically toggles in left-right window
CTRL + W + R moves the layout position of the current window
o Open a file, directory, or bookmark in an existing window and jump to that window
Go opens a file, directory, or bookmark in an existing window, but does not jump to that window
T open the selected file/bookmark in the New tab and skip to the new tab
T Opens the selected file/bookmark in the New tab, but does not jump to the new tab
I split a new window open the selected file and jump to that window
GI Split a new window opens the selected file, but does not jump to that window
s vsplit a new window opens the selected file and jumps to that window
GS vsplit A new window opens the selected file, but does not jump to that window
! Executing the current file
O recursively open all directories under the selected node
X closes the parent directory of the selected node.
X recursively closes all directories under the selected node.
e Edit the current dif
Double-click equivalent Nerdtree-o
The middle key pair file is equivalent to Nerdtree-i, the directory is equivalent to NERDTREE-E
D Delete the current bookmark
P jumps to the root node.
P jumps to the parent node.
K jumps to the first node of a sibling in the current directory.
J jumps to the last node of the sibling in the current directory.
K jumps to the previous node of the same sibling in the current directory.
J jumps to the next node of the sibling in the current directory.
C set the parent directory of the selected directory or selected file to the root node.
U sets the parent directory of the current root node to the root and becomes the closing root node.
U sets the parent directory of the current root node to the root directory, but maintains the original root node.
R recursively refreshes the selected directory
R recursively refreshes the root node.
m Display file System menu
CD sets CWD to the selected directory
I Toggle whether hidden files are displayed
F Toggle whether file filter is used
F Toggle whether the file is displayed
B Toggle whether bookmarks are displayed
Q Close Nerdtree window
? Toggle whether Quick Help is displayed


Toggle tab Page
: tabnew [++opt options] [+cmd] file creates a new tab for the specified file
: TABC Close the current tab
: Tabo Close all other tabs
: Tabs View all open tabs
: TABP before a tab
: Tabn After a tab


Standard mode:
GT Front tab
GT after a tab

Macvim can also use the shortcut keys to complete the tab close, switch
Cmd+w Close the current tab
cmd+{before a tab
cmd+} after a tab
Nerdtree common configuration in. vimrc
"Nerdtree is turned on by default when Vim is started (Autocmd can be abbreviated as AU)
Autocmd Vimenter * Nerdtree

"Press F2 to bring up/hide Nerdtree
map:silent! Nerdtreetoggle

"Set the Nerdtree window to the right of the Vim window (default to the left)
Let's nerdtreewinpos= "right"

"When you open the Nerdtree window, the Bookmarks is displayed automatically
Let Nerdtreeshowbookmarks=1

Installing and using VIM and its plugins (Pathogen and Nerdtree)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.