Vim+vundle+vim-autoformat+astyle Format Code __vim

Source: Internet
Author: User
Tags git clone

Vundle is the VIM plug-in management tool used to manage Vim plug-ins, Vim-autoformat is a code-formatted plug-in


1. Installation Vundle (reference click to open link)

$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/vundle.vim

2. Add the following content to the. vimrc file

Set Nocompatible              "is improved, required
filetype off                  " required

"set the runtime path to include Vundle and initialize
set Rtp+=~/.vim/bundle/vundle.vim call
vundle#begin ()
"Alternatively, pass a path where Vundle should install plugins
"Call Vundle#begin (' ~/some/path/here ')"-let Vundle manage Vundle

,
required Plugin ' Vundlevim/vundle.vim '
Plugin ' Chiel92/vim-autoformat '
"All of your Plugins must is added before the following Linecall Vundle#end ()" Requiredfiletype plugin indent on "Requi Red "to ignore plugin indent changes instead with:" FileType plugin on "" Brief Help ":P luginlist-lists configured Plugins ":P Lugininstall-installs plugins; Append '! ' to update or just:P luginupdate ':P luginsearch foo-searches for foo; Append '! ' to refresh the local cache ':P luginclean-confirms removal of unused plugins; Append '! ' to Auto-approve removal ' "see:h vundle for more details or wikis for FAQs" Put your non-plugin stuff Line

3. Restart Vim, execute in VIM: Plugininstall, install Vim-autoformat

4. Install Astyle

sudo apt-get install Astyle

You can also install the formatting plug-ins for other languages, and when the installation is complete, the default formatting settings are performed

5. Custom Astyle format, add the following code in. VIMRC

Let G:formatdef_my_cpp = ' "Astyle--style=google" ' let
g:formatters_cpp = [' my_cpp ']
au bufwrite *: Autoformat

When the code is saved, it is automatically formatted


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.