Configure and use Vim

Source: Internet
Author: User

Display Settings

SSH background settings: Edit-> setting-> color

Linux background settings:

Text Size: Ctrl +/-zoom in and out

Edit-> Configure the current file-> color

A simple. vimrc

CD/etc VI vimrc

It mainly implements automatic indentation, line feed, and other functions.

Set nocompatible
Set columns = 80
Set tabstop = 4
Set ruler
Set noexpandtab
Set number
Set ignorecase
Set wrapmargin = 15
Set cindent
Set shiftwidth = 4
Syntax on

Vim window configuration

Let G: winmanagerwindowlayout = 'fileexplorer | taglist'
Nmap wm: wmtoggle <CR>
Map <c-W> <c-F>: firstexplorerwindow <CR>
Map <c-W> <c-B>: bottomexplorerwindow <CR>
Map <c-W> <c-t>: wmtoggle <CR>


Simple VIM:

Function Area, function area, file tag, but no file Workspace

Install cscope-15.6.tar.gz./configure-> make & make install

After the installation is complete, enter the following code in the folder:

Cscope-rbkq

Then integrate the command and enter

Cscope

In this way, you can use Ctrl +] to view system functions,

Search function: CS find G Function Name

To view the system function content, you can directly use the cssag command, and then enter the name of the function to be viewed in the find function called by this function. After reading the function, CTRL + O will return to the original place.

Ctags-5.6.tar.gz (the implementation of the taglist function requires it)    ./Configure-> make & make install

Taglist_42.zip

Run vim and use the taglisttoggle command to activate the taglist. Use Ctrl + 2 W to switch between the tags area on the left and the normal editing area.

Install taglist For Vim

Taglist
Can list the tags (functions, class, variable, etc) in the source file and jump.
Note: The taglist depends on the ctags, so you must first install the ctags; otherwise, the taglist cannot be used!
(1)
Http://vim.sourceforge.net/scripts/script.php? Script_id = 1, 273
Download taglist_42.zip, that is
Http://vim.sourceforge.net/scripts/download_script.php? Src_id = 1, 6416
(2) extract two files.
| -- Doc
| '-- Taglist.txt
'-- Plugin
'-- Taglist. Vim
(3) Installation
Cp doc/taglist.txt/usr/share/Vim/vim70/doc/
CP plugin/taglist. Vim/usr/share/Vim/vim70/plugin/
(4) configuration and use
CD/usr/share/Vim/vim70/doc/


Minibufexplorer

Download this plug-in to/usr/share/Vim/vim70/plugm. Without this plug-in, the file tag cannot be displayed. In vim, close the opened file, key D: Delete the buffer where the cursor is located.


 

 

Using the quickfix mode of VIM can greatly speed up error locating. You can start compilation in Vim, and then Vim will automatically jump to the first error location based on the error message output by the compiler, after modification, you can use a shortcut key to jump to the next error and modify it.

Two methods are provided to compile the source program in VIM:
1. Enter

: Set makeprg = GCC \-wall \-ohello \ hello. c

Then, make

Enter the CW command to display the error message window.

2. Write a MAKEFILE file directly.

Write a simple makefile:
XX: XX (the two files must be the same. For convenience, if you want to formally generate a file name: program file name. c)
 

(The first character in the second line must be the tab key) name of the program file generated by GCC-o. c
Example:
Hello: Hello. c
 (Tab) GCC-O hello. c

The above command will compile the hello. c executable file named hello and open all the warnning. If there are spaces in the compilation command, use '\' to escape it. This is the case in the above example. Use: CW to open the quickfix window and use CN and CP to switch between the error lines in quickfix

Complex window Vim :( wmtoggle), with an additional file manager window

Decompress winmanager.zip and put the corresponding file

/Usr/share/Vim/vim70/doc/
/Usr/share/Vim/vim70/plugin/

Enter wmtoggle once, open the control window, and enter wmtoggle again. The control window is closed again.

Close the subwindow:
First, let the window to be closed get the mouse input point, then enter Q in command mode, and press ENTER

Vim Chinese problems

Create a. vimrc file in the user directory
Join
Set fileencodings = UTF-8, gb2312, GBK, gb18030
Set termencoding = UTF-8
Set fileformats = Unix
Set encoding = PRC
UTF-8 in fileencodings must be in front.

Solve the Problem of file garbled by VIM
CD/etc
VI vimrc
Add:
Let & termencoding = & Encoding
Set fileencodings = UTF-8, GBK, ucs-bom, cp936

 

In command mode, enter U to undo the operation.

Do not save the modification. Force Exit: Q!

 

Differences between VI and VIM

1. Multilevel Revocation
We know that in VI, you can only undo the last command by pressing U, but you can undo it without limit in vim.
The difference is that Vim is an upgraded version of VI, which is not only compatible with all instructions of VI,
There are also some new features in it.

 

 Gvim

Many readers may be unfamiliar with vim command operations or keyboard operations, so you can use gvim with the above two tools. You only need to use gvim to open the c file, enable the function list, and double-click the function name to jump to the function. Press Ctrl + the left and right mouse keys to track or roll back, which is more convenient and better than many tools in win

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.