未加星标

Useful Vim editor plugins for software developers - part 1

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二05 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

An improved version of Vi, Vim is unarguably one of the most popular command line-based text editors in linux. Besides being a feature-rich text editor, Vim is also used as an IDE (Integrated Development Environment ) by software developers around the world.

What makes Vim really powerful is the fact that it's functionality can be extended through plugins. And needless to say, there exist several Vim plugins that are aimed at enhancing users' programming experience.

Especially for software developers who are new to Vim, and are using the editor for development purposes, we'll be discussing some useful Vim plugins - along with examples - in this tutorial.

Please note that all the examples, commands, and instructions mentioned in this tutorial have been tested on Ubuntu 16.04, and the Vim version we've used is 7.4.

Plugin installation setup

Given that the tutorial is aimed at new users, it would be reasonable to assume that they don't know how Vim plugins are installed. So, first up, here are the steps required to complete the installation setup:

Create a directory dubbed .vim in your home directory, and then create two sub-directories named autoload and bundle . Then, inside the autoload directory, you need to place a file named pathogen.vim , which you can download from here . Finally, create a file named .vimrc in your home directory and add the following two lines to it: call pathogen#infect() call pathogen#helptags()
Useful Vim editor plugins for software developers - part 1

That's it. You are now ready to install Vim plugins.

Note: Here we've discussed Vim plugin management using Pathogen. There are other plugin managers available as well - to get started, visit this thread .

Now that we are all set, let's discuss a couple of useful Vim plugins.

Vim Tagbar plugin

First up is the Tagbar plugin. This plugin gives you an overview of the structure of a source file by letting you browse the tags it contains. "It does this by creating a sidebar that displays the ctags-generated tags of the current file, ordered by their scope," the plug-in's official website says. "This means that for example methods in C++ are displayed under the class they are defined in."

Sounds cool, right? Now, lets see how you can install it.

Tagbar's installation is pretty easy - all you have to do is to run the following two commands:

cd ~/.vim/bundle/

git clone git://github.com/majutsushi/tagbar

After the plugin is installed, it's ready for use. You can test it out by opening a .cpp file in Vim, entering the command mode , and running the :TagbarOpen command. Following is an example screenshot showing the sidebar (towards right) that comes up when the :TagbarOpen Vim command was executed:


Useful Vim editor plugins for software developers - part 1

To close the sidebar, usethe :TagbarClose command. What's worth mentioning here is that you can use the :TagbarOpen fj command to open the sidebar as well as shift control to it. This way, you can easily browse the tags it contains - pressing the Enter key on a tag brings up (and shifts control to) the corresponding function in the source code window on the left.


Useful Vim editor plugins for software developers - part 1

In case you want to repeatedly open and close the sidebar, you can use the :TagbarToggle command instead of using :TagbarOpen and :TagbarClose , respectively.

If typing these commands seems time consuming to you, then you can create a shortcut for the :TagbarToggle command. For example, if you put the following line in your .vimrc file:

nmap <F8> :TagbarToggle<CR>

then you can use the F8 key to toggle the Tagbar plugin window.

Moving on, sometimes you'll observe that certain tags are pre-fixed with a +, -, or # symbol. For example, the following screenshot (taken from the plugin's official website) shows sometags prefixed with a + symbol.


Useful Vim editor plugins for software developers - part 1

These symbols basically depict the visibility information for a particular tag. Specifically, + indicates that the member is public, while - indicates a private member. The # symbol, on the other hand, indicates that the member is protected .

Following are some of the important points related to Tagbar:

The plugin website makes it clear that "Tagbar is not a general-purpose tool for managing tags files. It only creates the tags it needs on-the-fly in-memory without creating any files. tags file management is provided by other plugins. " Vim versions < 7.0.167 have acompatibility issue with Tagbar. " If you are affected by this use this alternate Tagbar download instead: zip ," the website says. " It is on par with version 2.2 but probably won't be updated after that due to the amount of changes required." If you encounter the error Tagbar: Exuberant ctags not found! while launching the plugin, then you can fix it by downloading and installing ctags from here . For more information on Tagbar, head here . Vim delimitMate Plugin

The next plugin we'll be discussing here is delimitMate. The plugin basically provides insert mode auto-completion for quotes, parens, brackets, and more.

It also offers " some other related features that should make your time in insert mode a little bit easier, like syntax awareness (will not insert the closing delimiter in comments and other configurable regions), and expansions (off by default), and some more," the plugin's official github page says.

Installation of this plugin is similar to the way we installed the previous one:

cd ~/.vim/bundle/

git clone git://github.com/Raimondi/delimitMate.git

Once the plugin is installed successfully (meaning the above commands are successful), you don't have to do anything else - it loads automatically when the Vim editor is launched.

Now, whenever - while in Vim - you type a double quote, single quote, brace, p arentheses, or bracket, they'll be automatically completed.

The delimitMate plugin is configurable. For example, you can extend the list of supported symbols, prevent the plugin from loading automatically,turns

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: C++LinuxUbuntu
分页:12
转载请注明
本文标题:Useful Vim editor plugins for software developers - part 1
本站链接:http://www.codesec.net/view/483242.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(29)