.vimrc

为了C语言而设置,我的.vimrc文件内容(vim版本7.2.330,在ubuntu10.04下安装的)

我也是个初学者,不想照搬网络上已有的配置文件,因此先从最简单的开始吧,离好用还有很大差距。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"显示行号
set nu
 
" C的编译和运行,按F5
map <F5> :call CompileRunGcc()
func! CompileRunGcc()
exec "w"
exec "!gcc -Wall -g % -o %&lt;"
exec "! ./%&lt;"
endfunc
 
" C++的编译和运行,按F6
map <F6> :call CompileRunGpp()
func! CompileRunGpp()
exec "w"
exec "!g++ -Wall -g % -o %&lt;"
exec "! ./%&lt;"
endfunc
 
"自动缩进相关
set autoindent
set cindent
 
"配色
colorscheme desert
 
"自动括号补全不一定特别方便,但至少不会把括号忘记了
:inoremap ( ()i
:inoremap ) =ClosePair(')')
:inoremap { {}i
:inoremap } =ClosePair('}')
:inoremap [ []i
:inoremap ] =ClosePair(']')
:inoremap &lt; &lt;&gt;i
:inoremap &gt; =ClosePair('&gt;')
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\"
else
return a:char
endif
endf
 
"Taglist插件和winmanager的设置(需要下载安装这两个插件),按F4显示winmanager
"据说Taglist需要安装ctags(总之我装了,没验证过),在ubuntu10.04中为exuberant-ctags软件包
let g:Tlist_Use_Left_Window=1
let g:Tlist_Show_One_File=1
let g:Tlist_Compact_Format=1
let Tlist_Exit_OnlyWindow=1
let g:winManagerWindowLayout='FileExplorer|TagList'
nmap <F4> :WMToggle

++++++++++++++++++++++++++++++++++++++++++++++++++++

插件

++++++++++++++++++++++++++++++++++++++++++++++++++++

TabBar 打开多个文档时可以像UE一样有标签的效果..通过alt+1,2,3切换,见效果图3

WinManager 文件管理和窗口管理器,见效果图3

TagList 显示代码中的函数、类、变量等等,见效果图3

效果图1(设置了行号,C语言自动缩进,配色是desert;默认有括号配对和语法高亮),程序是随便写的,为了演示下而已,功能是取20个数的最大最小值。

效果图2(按F5,调用gcc编译并运行,直接在GVIM的窗口内运行,还是蛮方便的)

效果图3,按F4,调出winmanager,上半部分是文件浏览器,下半部分是Taglist,同时编辑多个文件,上方还有TabBar,用Alt+number来切换各个编辑文件。

先暂时这样,功能好多,乱……慢慢来吧

Previous Next

31 Comments (+add yours?)

  1. godsoul
    七 07, 2010 @ 15:39:06

    Firefox 3.6.6 Firefox 3.6.6 Ubuntu 10.04 Ubuntu 10.04

    不错哦,问一下,那个权限问题怎么解决阿,我F5说我权限不行,怎么加sudo阿,还有几个窗口怎么切换?

    给评论打分: Thumb up 0 Thumb down 0

    回复

    • 婉秋
      七 07, 2010 @ 15:42:54

      Firefox 3.6.6 Firefox 3.6.6 Windows XP Windows XP

      没有什么权限问题啊,运行gcc不需要root权限的。
      如果有TabBar插件就用Alt+number来切换。

      给评论打分: Thumb up 0 Thumb down 0

      回复

    • godsoul
      七 07, 2010 @ 15:52:55

      Firefox 3.6.6 Firefox 3.6.6 Ubuntu 10.04 Ubuntu 10.04

      第一个问题:/bin/bash: lt:找不到命令
      Shell 已返回127
      你看就是这个
      第二个问题:我用alt+2切换,出现如下
      处理 function 11_Bf_SwitchTo 时发生错误:
      第 3 行:
      E86: 缓冲区 5 不存在

      给评论打分: Thumb up 0 Thumb down 0

      回复

      • 婉秋
        七 07, 2010 @ 16:11:08

        Firefox 3.6.6 Firefox 3.6.6 Windows XP Windows XP

        第一个问题:那个WordPress的插件有问题,经常把我输的文字改掉……………… :!: 应该是下面这样的
        ” C的编译和运行
        map :call CompileRunGcc()
        func! CompileRunGcc()
        exec “w”
        exec “!gcc -Wall -g % -o %< "
        exec "! ./%<"
        endfunc

        " C++的编译和运行
        map :call CompileRunGpp()
        func! CompileRunGpp()
        exec “w”
        exec “!g++ -Wall -g % -o %<”
        exec “! ./%<”
        endfunc

        第二个还不清楚

        给评论打分: Thumb up 0 Thumb down 0

        回复

  2. Leyond
    六 29, 2010 @ 20:17:38

    Firefox 3.6.4 Firefox 3.6.4 Windows XP Windows XP

    很专业 呵呵 门外汉 飘过 :)

    给评论打分: Thumb up 0 Thumb down 0

    回复

    • ブブ
      七 06, 2010 @ 00:12:29

      Firefox 3.6.6 Firefox 3.6.6 Windows XP Windows XP

      同意

      给评论打分: Thumb up 0 Thumb down 0

      回复

      • 婉秋
        七 06, 2010 @ 14:47:25

        Firefox 3.6.6 Firefox 3.6.6 Windows 7 Windows 7

        给评论打分: Thumb up 0 Thumb down 0

        回复

  3. A.shun
    六 15, 2010 @ 16:00:42

    Opera 10.60 Opera 10.60 Windows XP Windows XP

    这界面和配色方案很赞呢 :oops:
    感觉会用vim的都是高手

    话说,贴出来的代码证明有一大段空白呢

    给评论打分: Thumb up 0 Thumb down 0

    回复

    • 婉秋
      六 15, 2010 @ 16:12:34

      Firefox 3.6.3 Firefox 3.6.3 Ubuntu 10.04 Ubuntu 10.04

      空白?

      给评论打分: Thumb up 0 Thumb down 0

      回复

      • A.shun
        六 15, 2010 @ 16:36:49

        Firefox 3.5.6 Firefox 3.5.6 Windows XP Windows XP

        额。。刚刚看了下是Opera 10.5+特有的问题
        10.1则正常。。。囧

        请无视吧 :(

        给评论打分: Thumb up 0 Thumb down 0

        回复

        • 婉秋
          六 15, 2010 @ 16:49:18

          Firefox 3.6.3 Firefox 3.6.3 Ubuntu 10.04 Ubuntu 10.04

          那代码高亮的插件有些小问题的,常常把<>里的内容自动改掉。
          改换一个了,但不知什么好

          给评论打分: Thumb up 0 Thumb down 0

          回复

  4. 朵未
    六 15, 2010 @ 11:30:47

    Google Chrome 6.0.425.0 Google Chrome 6.0.425.0 Windows XP Windows XP

    来围观一下,我不懂C语言,以前简单的SQL语言也差不多不会了。

    给评论打分: Thumb up 0 Thumb down 0

    回复

  5. 刘晓林
    六 14, 2010 @ 22:58:13

    Google Chrome 6.0.427.0 Google Chrome 6.0.427.0 Windows 7 Windows 7

    专业东西,我飘过!

    给评论打分: Thumb up 0 Thumb down 0

    回复

  6. Auston Jary
    六 14, 2010 @ 18:02:27

    ChromePlus ChromePlus GNU/Linux GNU/Linux

    我的.vimrc是从ubuntu的wiki里复制的.
    每次终端打开或Gvim 都会弹个框出来…..
    —–
    处理 /usr/share/vim/vimrc 时发生错误:
    第 52 行:
    E185: 找不到配色方案 corey
    :-?

    给评论打分: Thumb up 0 Thumb down 0

    回复

    • 婉秋
      六 14, 2010 @ 18:32:38

      Firefox 3.6.3 Firefox 3.6.3 Windows 7 Windows 7

      说明你没有叫做“corey”的配色方案。
      到ubuntu的wiki看了,到 http://wiki.ubuntu.org.cn/Corey/vimrc 复制那个配色方案,保存为corey.vim到colors目录下就可以了。
      那个wiki很古董了……建议vimrc保存到/home/username/.vimrc

      给评论打分: Thumb up 0 Thumb down 0

      回复

      • Auston Jary
        六 14, 2010 @ 19:01:33

        ChromePlus ChromePlus GNU/Linux GNU/Linux

        确实够古董,不过看着也还行
        弄好了
        vim确实够折腾哈

        给评论打分: Thumb up 0 Thumb down 0

        回复

  7. Mucid
    六 14, 2010 @ 15:55:59

    Firefox 3.6.3 Firefox 3.6.3 Ubuntu 10.04 Ubuntu 10.04

    看你写的可以直接拿到vc里编译,语法都一样的啊,除了编译器细微的差别外,比如vc可以写void main,但是其实vc很不标准,一般是int main加一个返回

    给评论打分: Thumb up 0 Thumb down 0

    回复

    • 婉秋
      六 14, 2010 @ 16:40:17

      Firefox 3.6.3 Firefox 3.6.3 Ubuntu 10.04 Ubuntu 10.04

      VC是不标准,不过用起来感觉还好。我的老师常常把C和C++弄混了,比如malloc和new……不过居然还能编译通过,正常运行。
      那个main函数,我还有看到写int main(void)的,搞不清楚那个标准。

      给评论打分: Thumb up 0 Thumb down 0

      回复

      • Mucid
        六 14, 2010 @ 16:58:06

        Firefox 3.6.3 Firefox 3.6.3 Ubuntu 10.04 Ubuntu 10.04

        当然了,只要小改下c就可以完全通过c++,现在的话我还是尽力保持自己用C++标准,int main是标准的.

        给评论打分: Thumb up 0 Thumb down 0

        回复

        • 婉秋
          六 14, 2010 @ 17:00:27

          Firefox 3.6.3 Firefox 3.6.3 Ubuntu 10.04 Ubuntu 10.04

          我只会C :-? C++完全没有接触过

          给评论打分: Thumb up 0 Thumb down 0

          回复

          • Mucid
            六 14, 2010 @ 17:17:17

            Firefox 3.6.3 Firefox 3.6.3 Ubuntu 10.04 Ubuntu 10.04

            c++完全兼容c,c++面向过程,其实就是加了啥类啊,重载啊,继承派生啊,多态性啊,构造函数啊,更加符合人的思维习惯(ps:个人觉的没啥人的思维。。),更加安全和提高了代码重复利用率,其实有时我觉得用c写作业要爽的多 :idea: linus曾经炮轰c++,看来不可小视c啊

            给评论打分: Thumb up 0 Thumb down 0

            回复

            • 婉秋
              六 14, 2010 @ 17:23:25

              Firefox 3.6.3 Firefox 3.6.3 Ubuntu 10.04 Ubuntu 10.04

              但是好像差距很大啊,我看过C++的代码,几乎看不懂呃。
              因为QT用C++的,而且在移动设备上多见,似乎蛮不错的。我这个专业不少比我高年级人的都在用QT了……

              给评论打分: Thumb up 0 Thumb down 0

              回复

              • Mucid
                六 14, 2010 @ 17:33:20

                Firefox 3.6.3 Firefox 3.6.3 Ubuntu 10.04 Ubuntu 10.04

                肯定还是要先稍微看点c++的资料才能理解的,我经常写c++作业,很多地方简直跟c一样,你所说的差别肯定是c++对c的扩充部分了。不过我还没有在linux下编过程,qt不就是个库和环境么,就像vc2005运行库一样的,急啥啊,还没到开发阶段昵。。

                给评论打分: Thumb up 0 Thumb down 0

                回复

                • 婉秋
                  六 14, 2010 @ 18:33:22

                  Firefox 3.6.3 Firefox 3.6.3 Windows 7 Windows 7

                  嗯,我还是先试试GTK+的 :mrgreen:

                  给评论打分: Thumb up 0 Thumb down 0

                  回复

  8. Mucid
    六 14, 2010 @ 15:53:15

    Firefox 3.6.3 Firefox 3.6.3 Ubuntu 10.04 Ubuntu 10.04

    像我这种一编译就一团bug和waring的,还是只适合使用视窗型的编译器 :mrgreen: 这个就像python的那个东东一样就一个框框。

    给评论打分: Thumb up 0 Thumb down 0

    回复

  9. 九站
    六 14, 2010 @ 08:45:21

    Internet Explorer 8.0 Internet Explorer 8.0 Windows XP Windows XP

    配置文件,这个好像比C还难,捏。

    给评论打分: Thumb up 0 Thumb down 0

    回复

    • 婉秋
      六 14, 2010 @ 09:11:03

      Firefox 3.6.3 Firefox 3.6.3 Windows 7 Windows 7

      只是不懂它的语法罢了。应该都差不多

      给评论打分: Thumb up 0 Thumb down 0

      回复

  10. jeehon
    六 14, 2010 @ 02:08:48

    Firefox 3.6.3 Firefox 3.6.3 Windows 7 Windows 7

    小女程序员啊,程序我可以看懂耶……

    给评论打分: Thumb up 0 Thumb down 0

    回复

    • 婉秋
      六 14, 2010 @ 09:07:58

      Firefox 3.6.3 Firefox 3.6.3 Windows 7 Windows 7

      呵呵,很简单的一个

      给评论打分: Thumb up 0 Thumb down 0

      回复

  11. zhiwei
    六 14, 2010 @ 00:26:32

    Google Chrome 5.0.375.70 Google Chrome 5.0.375.70 Windows 7 Windows 7

    额额额,大赞!又发现一个用vim的啦 :-)

    给评论打分: Thumb up 0 Thumb down 0

    回复

    • 婉秋
      六 14, 2010 @ 00:30:50

      Firefox 3.6.3 Firefox 3.6.3 Ubuntu 10.04 Ubuntu 10.04

      哈哈!握爪 :mrgreen:

      给评论打分: Thumb up 0 Thumb down 0

      回复

Leave a Reply

:wink: :-| :-x :twisted: :) 8-O :( :roll: :-P :oops: :-o :mrgreen: :lol: :idea: :-D :evil: :cry: 8) :arrow: :-? :?: :!:

Switch to our mobile site