How to edit Java files in Vim

xiaoxiao2021-03-06  112

By Camry.Wu

This time you introduce how to edit the Java file in Vim

When the Javabrowser Editorial class file, the class resource tree is a useful thing, and it can be displayed intuitively with members, methods, etc. in the VIM, which can also be achieved like VC, JBuilder, of course, more than those Something, it is also easy to use. Just use Javabrowser.vim this script implementation. First go to Vim Online to find this script file. (You can find a lot of useful other scripts) and then find the installation of CTAGS on Google Method, (General Linux system with this program)

Copy javabrowser.vim to ~ / .vim / plugin / under the Linux system. Then you are configured in ~. / Vimrc: (ie, the path to the CTAGS program) Let javabrowser_ctags_cmd = '/ usr / bin / ctags' Vim is not a GUI version, then you can do the following settings, it will not change the window let javabrowser_inc_winwidth = 0 Run Vim When you open a Java file, enter: javabrowser can see the beautiful resource tree. But this file must It is a actual file. Javabrowser.vim can be copied to the plugin under the Vim directory in the Windows system. It also needs to set the javabrowser_ctags_cmd, the path to the CTAGS program. I usually set NMAP in the Java macro file. Javabrowser IMAP I can see this thing in one by pressing the F11 key. It is very convenient. In Vim Online, you will find a Taglist script is also used to display the resource tree. And it is widely used, which is suitable for multiple languages, but the color doesn't seem to have Javabrowser. JCommenter programming is definitely need to write comments, and write Java files to write a javadoc type. JCommenter.vim This script can Help you easily write a comment. You can find this script to Vim Online. Download it in your directory, I will put it in ~ / .vim / files / directory, this directory is really put a lot. Read the script first, of course, we don't want to read it when editing any file, how to make further explanations in Section III. After reading the script: Call JcommentWriter () can automatically write a comment It is very comfortable after use. I usually define to write a comment. AutoCmd AutoCmd is very powerful, I have mentioned it in the article experience in VIM. Now explains how to support the Java file. I am setting up my autocmd in. Vimrc: AutoCMD! autocmd FileType java source ~ / .vim / files / java.vim autocmd FileType java source ~ / .vim / files / jcommenter.vim autocmd BufNewFile * .java 0r ~ / .vim / files / skeletons / java.skel autocmd BufNewFile *. The Java Normal GNP illustrates:

Cancel before autocmd, if the Java file is edited, then read Java.vim macro definition (defined in the following description) If you edit a java file, read JCommenter.vim definition When new Java files are new, Java.skel content copy After reading Java.skel content, run GNP this macro command My java.skel content is this: / * * ---------------- ------------------------------------------ * File name: _filename_ * authors : Camry (camry.wu@gmail.com) * Created: _datetime_ * Copyright: (c) 2004 Vitular Inc. All Rights Reserved. * * Modifications: * * --------------- ------------------------------------------- * / package com.Vitular . * * @Author camry (Camry.Wu@gmail.com) * @version 1.0 * / public class _ClassName_ {/ ** * default constructor. * / Public _classname_ () {super } // end: _ClassName_ / ** * for test. * @Param args commond line parameters public static void main (femant string [] args {} // end: main * /} // end: _classname_ // /: ~ Run the gnp macro command, mainly to replace _classn AME_, _DATIME_, _FILENAME_ These three variables. GNP command specifies in the Java.vim macro file. Java macro defines how my Java.vim macro file is defined. First, another macro contains another macro Definition, here is some of my own definitions: "Enter the reflection abbr sprt system.out.println abbr psf public static final" will _filename_, _datetime_, _classname_ convert into a correct name "Note that the following two lines should be connected One line of text MAP GNP :% s / _filename _ // = bufname ("%") / :% s / _datetime _ // = strftime ("% C") / go "% p $ f.bd0f.dviwx:% s / _classname _ // = strands (@") / g gdd: 1 / { "Enter You can see class resource tree NMAP : Javabrowser IMAP Enter can write to note directly. NMAP : Call JcommentWriter () <

Cr> IMAP command mode, type GSG on the shape such as private string s; / ** Comment * / like this can be automatically turned into GET SET. "Note that the following three lines It should be a line of text MAP GSG 0F; DW "AD0WWVIW" BXWVIW "CX0DA " APA Public Void Set "CPB3 ~ $ A (Final " BPA "CPA) {this. " CPA = "CPA;} public " BPA GET "CPB3 ~ $ A () {RETURN "CPA;} 0 last updated: November 13, 2004, Saturday, 15:13, 4 seconds HTML conversion program: Tex2Page 2004-09-11

转载请注明原文地址:https://www.9cbs.com/read-102869.html

New Post(0)