如下是使用 Boost Format 库 的C++代码, 我自己手动缩进如下:
代码: 全选
// To compile:
// $ g++ -lboost_filesystem path.cc
//
// 该示例程序演示 Boost.Filesystem 中提供的
// path对象的常用操作.
//
// 同时, 我还使用了Boost Format 库完成格式化输出.
//
#include "boost/filesystem.hpp"
#include <boost/format.hpp>
#include <iostream>
#include <cstdio>
using namespace std;
namespace bfs = boost::filesystem;
int main(int argc, char** argv) {
//boost::progress_timer t( std::clog );
if(argc <= 1)
exit(1);
bfs::path p(argv[1]);
//p.clear();
cout << boost::format (
"path= '%||'\n"
"complete: '%||'\n"
"\n"
"path.filename(): '%||'\n"
"path.parent_path(): '%||'\n"
"path.string(): '%||'\n"
"path.file_string(): '%||'\n"
"path.directory_string(): '%||'\n"
"path.root_name() '%||'\n"
"path.root_directory() '%||'\n"
)
% p
% bfs::system_complete(p)
% p.filename()
% p.parent_path()
% p.string()
% p.file_string()
% p.directory_string()
% p.root_name()
% p.root_directory()
;
// 因为 path 具有从 const char* 进行构造的构造函数, 所以:
//cout << bfs::system_complete("a/b/c.py") << "\n";
}
代码: 全选
// To compile:
// $ g++ -lboost_filesystem path.cc
//
// 该示例程序演示 Boost.Filesystem 中提供的
// path对象的常用操作.
//
// 同时, 我还使用了Boost Format 库完成格式化输出.
//
#include "boost/filesystem.hpp"
#include <boost/format.hpp>
#include <iostream>
#include <cstdio>
using namespace std;
namespace bfs = boost::filesystem;
int main(int argc, char** argv) {
//boost::progress_timer t( std::clog );
if(argc <= 1)
exit(1);
bfs::path p(argv[1]);
//p.clear();
cout << boost::format (
"path= '%||'\n"
"complete: '%||'\n"
"\n"
"path.filename(): '%||'\n"
"path.parent_path(): '%||'\n"
"path.string(): '%||'\n"
"path.file_string(): '%||'\n"
"path.directory_string(): '%||'\n"
"path.root_name() '%||'\n"
"path.root_directory() '%||'\n"
)
% p
% bfs::system_complete(p)
% p.filename()
% p.parent_path()
% p.string()
% p.file_string()
% p.directory_string()
% p.root_name()
% p.root_directory()
;
// 因为 path 具有从 const char* 进行构造的构造函数, 所以:
//cout << bfs::system_complete("a/b/c.py") << "\n";
}
我想请教一下, 对于Vim无法应付的情况, 如果处理呢?
不要以为这不重要, 其实无法正确缩进很让人抓狂的, 比如在上面的代码中, 我输入了一行 %***, 换行之后预期应和上行对齐的, 但是却漂移了很远, 我不得连续按退格键手动对齐.
谢谢!!!