简体   繁体   中英

Using vim for indentation in C++

I use vim to write code (please , lets not discuss why) . We indent our code using a common vimrc

syntax on        "Turn on syntax highlighting
set laststatus=2 "Always show status line

set tabstop=4    "Number of spaces a TAB in the text stands for

...<more code>...

""Converting tabs to spaces
set expandtab
set tags=./tags;/
map <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>

This however is missing code to remove extra white space in between the 2 words and removing wrong spaces before comma etc .

Does anyone has any suggestion to remove those white spaces as well ?

Is there some standard that is followed which can help me as a guide to format c++ code ?

Vim is the wrong tool for what you want, since it doesn't know, nor care, about C++ syntax. Try a source code beautifier instead, such as uncrustify or GNU indent .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM