您的位置:首页 > 运维架构

openrefactory/c笔记 (一)

2015-07-10 20:37 381 查看
openrefactory/c(以下简称or/c)是一个针对C语言的代码重构工具,支持在vim和eclipse中进行代码重构。

相关文档介绍可在此处获取

由于其官网http://www.http://openrefactory.org 一直进不去,使用https://github.com/rdallman/openrefactory-vim的插件来进行实验,该插件是针对vim开发的,我使用的

操作系统为:ubuntu14.04.2 (64位)

vim版本为:7.4.52

首先是安装,在上面的github页面,安装步骤已经写的很详细了,我大致说一下,

1.安装java,可以参照我之前的博文 Ubuntu14.04安装java

2.安装vundle并使用vundle安装or/c,从https://github.com/VundleVim/Vundle.vim获取资源和安装步骤

2.1 设置Vundle

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

2.2配置.vimrc文件(在当前用户目录下)

将以下代码放在.vimrc文件中,注意(“)开头的是注释,把不需要的插件注释掉,只保留我们需要的插件,

set nocompatible              " be 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 'gmarik/Vundle.vim'
plugin 'rdallman/openrefactory-vim' "添加我们需要的插件or/c
" The following are examples of different formats supported. 下面介绍了几种不同的插件获取方式
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo 从github获取插件方式
“Plugin 'tpope/vim-fugitive' 注释掉不需要的插件
" plugin from http://vim-scripts.org/vim/scripts.html 从vim-script获取插件方式
"Plugin 'L9'注释掉不需要的插件
" Git plugin not hosted on GitHub
“Plugin 'git://git.wincent.com/command-t.git'注释掉不需要的插件
" git repos on your local machine (i.e. when working on your own plugin) 从本地计算机获取插件方式
”Plugin 'file:///home/gmarik/path/to/plugin'注释掉不需要的插件
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
“Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}注释掉不需要的插件
" Avoid a name conflict with L9
”Plugin 'user/L9', {'name': 'newL9'}注释掉不需要的插件
" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help 这里介绍了
" :PluginList       - lists configured plugin 显示要安装的插件
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate 安装插件
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal卸载插件,卸载时只需要到此文件.vimrc将要卸载的插件注释掉再执行此命令即可
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

打开vim然后执行:BundleInstall就行了。

3.现在就可以在vim中对C文件使用or/c进行代码重构了。

支持的重构方法有:

Rename

Add Local Variable

Add Reflexive Assignment

Move Expression Assignment

Remove Useless Expression

Change Integer Type

Add Integer Cast
Change Integer Type

Replace Arithmetic Operator

期间遇到问题,可以在vim中使用:help openrefactory获取帮助。注意,以上vim中的命令都支持tab键补全。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: