Put a vi script without leaving the vi compiler.

Source: Internet
Author: User
Put a vi script without leaving the vi compiler-general Linux technology-Linux programming and kernel information. The following is a detailed description. A script is written in combination with the make and quickfix windows to compile a single file without leaving vi.

Usage:

1. Add the following code to your. vimrc file (~ \. Vimrc)
"This script use to excute make in vim and open quickfix window
Nmap B: call Do_make ()
Nmap C: cclose
Function Do_make ()
Let filename = bufname ("% ")
Let suffix_pos = stridx (filename, ". c ")
If suffix_pos =-1
Return
Else
Let target = strpart (filename, 0, suffix_pos)
Endif
Let target = "make". target

Execute target
Execute "copen"
Endfunction

2. In the nomal mode of vi (that is, the command mode, instead of the colon-based command mode)

Compile the program by shift + B. If an error occurs in the quickfix window, the error line and error message are displayed. Press enter to jump to the error line.

Press shift + c to close the quickfix window.

Note: In vi, shift + c deletes all characters after the cursor of the row and enters the input mode. If you often use this hot key, please map it yourself. Only c files are supported.

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.