小vimer的心得+求primer一个实例问题解答

  在成为一个游戏程序的这段日子里,接触了神一样的编辑器VIM,便在深深的体会到了他的优点之后,不可自拔的爱上了这款编辑器,想在电脑中每一个角落都使用上它。说起这个不得不说,VS中的VSVIM越来越好了,从刚开始用的时候只是移动编辑等与VIM一样,到现在几乎完成可以使用VIM的操作习惯了。

  这里分享下我的.vimrc配置.

"------------------------------------------------------------------------------------------------
" 我的配置
"------------------------------------------------------------------------------------------------

set shortmess=atI " 启动的时候不显示那个援助乌干达儿童的提示

set nu "显示行号

set ruler "显示标尺"

"set fileencodings=utf-8,gbk "设置编码格式"
"set termencoding=utf-8

"set encoding =utf-8 "编码格式
"set langmenu=zh_CN.UTF-8

set go = " 不要图形按钮

set guifont=Courier_New:h12:cANSI " 设置字体,这个字体觉得很不错,比较细,看着很顺眼。

set syntax=on "语法高亮

"autocmd InsertLeave * se nocul "高亮当前行
"autocmd InsertEnter * se cul "高亮当前行

set novisualbell "不要闪烁

colorscheme desert "主题

set foldenable "允许折叠

set foldmethod =manual "手动折叠

set autoread "文件被改动时自动录入

set completeopt =preview,menu "自动录入

set nobackup "不备份
set noswapfile

set cursorline "突出当前行

set smartindent "自动缩进
"set cindent

set noexpandtab "取消空格代替换行符

set history =1000 "设置保存空间

set ignorecase "搜索忽略大小写

set wildmenu "增强命令补全

set showmatch "高亮显示括号

set tabstop=4
set softtabstop=4
set shiftwidth=4

set autoread
"自动补全

:inoremap ( ()<ESC>i

:inoremap ) <c-r>=ClosePair(')')<CR>

:inoremap { {<cr>}<ESC>O

:inoremap } <c-r>=ClosePair('}')<CR>

:inoremap [ []<ESC>i

:inoremap ] <c-r>=ClosePair(']')<CR>

:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i

function! ClosePair(char)

if getline('.')[col('.') - 1] == a:char

return "\<Right>"

else

return a:char

endif

endfunction

"filetype plugin indent on
"set completeopt indent on
"set completeopt=longest,menu

set noeb " 不要错误提示音

"强迫自己用 hjkl
map <Left> <Nop>
map <Right> <Nop>
map <Up> <Nop>
map <Down> <Nop>


""CompileRun函数,用来调用进行编译和运行
func CompileRun()
exec "w"
"C程序
if &filetype == 'c'
exec "!gcc % -g -o %<.exe"
"c++程序
elseif &filetype == 'cpp'
exec "!g++ % -g -o %<.exe"
"Java程序
elseif &filetype == 'java'
exec "!javac %"
endif
endfunc
"结束定义CompileRun
"定义Run函数
func Run()
exec "w"
if &filetype == 'c' || &filetype == 'cpp'
exec "!%<.exe"
elseif &filetype == 'java'
exec "!java %<"
endif
endfunc
"定义Debug函数,用来调试程序
func Debug()
exec "w"
"C程序
if &filetype == 'c'
exec "!gcc % -g -o %<.exe"
exec "!gdb %<.exe"
elseif &filetype == 'cpp'
exec "!g++ % -g -o %<.exe"
exec "!gdb %<.exe"
"Java程序
elseif &filetype == 'java'
exec "!javac %"
exec "!jdb %<"
endif
endfunc
"结束定义Debug
"设置程序的运行和调试的快捷键F5和Ctrl-F5
map <F5> :call CompileRun()<CR>
map <F6> :call Run()<CR>
map <C-F5> :call Debug()<CR>

map <F7> :simalt ~x <CR>    "方便使用命令行开VIM后,最大化窗口

-----------------------------------------------------------------------------------------------------------------------

想要使用gvim在windows里编译运行文件需要安装mingw,安装一个GCC编译器。

环境配置的话直接使用将安装mingw的文件夹位置中的bin文件夹路径添加到系统环境的PATH里就OK了,在cmd窗口中运行gcc -v 可以显示编译器的版本信息就说明安装成功了。

------------------------以下是我今天遇到的一些问题------------------------------------------------

#include<iostream>
#include<string>
#include<stdlib.h>
#include<sstream>

using namespace std;

class Foo
{
public:
Foo(){
cout << "Foo()" << endl;
}
Foo(const Foo& f):value(f.value){
// *this = f;
ps = new string();
string temp = *(f.ps);
*ps = temp;
cout << "Foo(const Foo)" << endl;
}
Foo(int x, string s)
{
value = x;
ps = &s;
cout << "foo(int)" << endl;
}

Foo& operator=(const Foo& f)
{
ps = new string;
*ps = *f.ps;
value = f.value;

cout << "test operator = " << endl;

return *this;
}
~Foo(){ delete ps;}
int get()
{
return value;
}
void show(){
cout << value << " " << *ps << endl;
}
private:
int value;
string *ps;
};

int main()
{
string s("hello");
cout << "f1:" << endl;
Foo f1(6, s);
cout << "f2:" << endl;
Foo f2 = f1;
cout << "f3:" << endl;
Foo f3(f1);

f3.show();

cout << "f4:" << endl;
int pause;
cin >> pause;
return 0;
}

程序在gvim中使用gcc编译运行正常的,但是在VS2012中在运行到Foo f2 = f1; 这句时总报出一个内容冲突的错误。

请知道的大大帮我解答下。谢谢!

posted @ 2014-04-13 18:50  wtu_sos  阅读(892)  评论(6编辑  收藏  举报