- 浏览: 230707 次
- 性别:
- 来自: 昆明
文章分类
最新评论
-
beiyangshuishi:
确实挺幽默的,太能恶搞了。不过这也让我想起日本的一则广告宣纸的 ...
一对活宝—— MySQL & PostgreSQL -
ShiningRay:
稍微看了vcf的api,比wxwidgets要干净得多
VCF 库的搞笑提示 -
Colorful:
Wow, this is amazing.
D语言 struct constrcutor 的 bug -
oldrev:
楼下,当时的 TRAC 确实说是要 py 2.4 的
出色的开源项目管理软件——Redmine -
jusdao:
...Trac可以用python2.5啊,没有说必须用2.4的 ...
出色的开源项目管理软件——Redmine
在正文之前,先佩服一下伟大的GFW——又把 blogspot.com 的二级域名给封了。
如果你和我一样经常为了测试D语言的某个特性而写一些小程序来验证想法,而且恰好也使用 VIM 的话,那么本文就是为你准备的。
首先,VIM7 中自带的D语言语法文件版本很老,请替换为 http://www.vim.org/scripts/script.php?script_id=379 这个支持0.178的。
下面的代码是 VIM 的DMD编译器支持,将其放入 ~/.vim/complier/dmd.vim (for unix-like, Windows 为 $VIMRUNTIME\vim70\compiler\dmd.vim),GDC 用户请将18行的 dmd 替换为 gdmd。
最后,在 ~/.vimrc(Windows 是 $VIMRUNTIME\_vimrc)文件中加入如下两行:
大功告成,现在只需要任意打开一个D文件,在普通模式下按下 F5就可以运行程序,假如文件中存在编译错误的话,VIM会将其加入错误列表,并自动跳到第一个错误所在的行,同时也支持像 clist 列出错误清单这类的 Quickfix 命令。
下面是我的VIM效果:
Happy Vimming!
:autocmd BufRead,BufNewFile *.d map <F5> :w<CR>:!dmd -debug -run %<CR>
:autocmd BufRead,BufNewFile *.d map <F6> :w<CR>:!dmd -debug -unittest -run %<CR>
其实是这样的,查看本页源代码,就能从中找到_vimrc的配置。
替换掉双引号,大于,小于符号就可以了
PS:
代码标签显示得不对,网站bug,试试用quote标签?
而且,显示_vimrc文本的时候很慢,firefox都提示是否停止进行js
看不到代码,可以发可我吗?谢谢。qyqxt@hotmail.com
我贴出我的 _vimrc 参考一下:
只要按上面的步骤做应该没问题
如果你和我一样经常为了测试D语言的某个特性而写一些小程序来验证想法,而且恰好也使用 VIM 的话,那么本文就是为你准备的。
首先,VIM7 中自带的D语言语法文件版本很老,请替换为 http://www.vim.org/scripts/script.php?script_id=379 这个支持0.178的。
下面的代码是 VIM 的DMD编译器支持,将其放入 ~/.vim/complier/dmd.vim (for unix-like, Windows 为 $VIMRUNTIME\vim70\compiler\dmd.vim),GDC 用户请将18行的 dmd 替换为 gdmd。
dmd.vim 代码
- " Vim compiler file
- " Compiler: DMD Runner
- " Maintainer: oldrev
- " Last Change: 2007/03/28
- if exists("current_compiler")
- finish
- endif
- let current_compiler = "dmd"
- if exists(":CompilerSet") != 2 " older Vim always used :setlocal
- command -nargs=* CompilerSet setlocal <args></args>
- endif
- let s:cpo_save = &cpo
- set cpo-=C
- CompilerSet makeprg=dmd\ -run\ %
- CompilerSet errorformat=%f:%l:%m
- let &cpo = s:cpo_save
- unlet s:cpo_save
- " vim: nowrap sw=2 sts=2 ts=8 ff=unix:
最后,在 ~/.vimrc(Windows 是 $VIMRUNTIME\_vimrc)文件中加入如下两行:
.vimrc 代码
- :autocmd BufRead,BufNewFile *.d compiler dmd
- :autocmd BufRead,BufNewFile *.d map <f5> :w<cr>:make<cr> </cr></cr></f5>
大功告成,现在只需要任意打开一个D文件,在普通模式下按下 F5就可以运行程序,假如文件中存在编译错误的话,VIM会将其加入错误列表,并自动跳到第一个错误所在的行,同时也支持像 clist 列出错误清单这类的 Quickfix 命令。
下面是我的VIM效果:
Happy Vimming!
评论
11 楼
sofire
2007-08-06
我把配置文件改成了。
CompilerSet makeprg=dmd\ -run\ %\ 1>&2
CompilerSet errorformat=%f(%l)%m
我用的是linux下的dmd 1.015,错误提示用的是冒号,例如:
array.d(96): Error: cannot assign to static array [11]
makeprg改动的原因是:
运行程序后,在终端上显示输出结果。
如果不加 1>&2 ,结果就不会显示出来
上面的回复有点问题,贴的是_vimrc配置里面的,
和文章的有点出入。文章里面的意思是:
:autocmd BufRead,BufNewFile *.d compiler dmd
:autocmd BufRead,BufNewFile *.d map <f5> :w<cr>:make<cr>
多谢oldrev,原来用make编译程序,能更方便的定位错误。
引用
CompilerSet makeprg=dmd\ -run\ %\ 1>&2
CompilerSet errorformat=%f(%l)%m
我用的是linux下的dmd 1.015,错误提示用的是冒号,例如:
array.d(96): Error: cannot assign to static array [11]
makeprg改动的原因是:
运行程序后,在终端上显示输出结果。
如果不加 1>&2 ,结果就不会显示出来
上面的回复有点问题,贴的是_vimrc配置里面的,
和文章的有点出入。文章里面的意思是:
引用
:autocmd BufRead,BufNewFile *.d compiler dmd
:autocmd BufRead,BufNewFile *.d map <f5> :w<cr>:make<cr>
多谢oldrev,原来用make编译程序,能更方便的定位错误。
10 楼
sofire
2007-08-04
引用
:autocmd BufRead,BufNewFile *.d map <F5> :w<CR>:!dmd -debug -run %<CR>
:autocmd BufRead,BufNewFile *.d map <F6> :w<CR>:!dmd -debug -unittest -run %<CR>
其实是这样的,查看本页源代码,就能从中找到_vimrc的配置。
替换掉双引号,大于,小于符号就可以了
PS:
代码标签显示得不对,网站bug,试试用quote标签?
而且,显示_vimrc文本的时候很慢,firefox都提示是否停止进行js
9 楼
qyqx
2007-04-03
引用
我贴出我的 _vimrc 参考一下:
看不到代码,可以发可我吗?谢谢。qyqxt@hotmail.com
8 楼
oldrev
2007-04-02
引用
我都是照着做的,可是还没搞好,我用的是GVIM7.0 for windows, 一用VIM打开D文件就提示:
"D:\ASM.d" 20L, 382C
找不到映射
请按ENTER或其它命令继续
"D:\ASM.d" 20L, 382C
找不到映射
请按ENTER或其它命令继续
我贴出我的 _vimrc 参考一下:
scriptencoding utf-8 "----------------------------------------------------------------------- "BaSS vimrc based con ciaran "----------------------------------------------------------------------- "----------------------------------------------------------------------- " terminal setup "----------------------------------------------------------------------- " Extra terminal things " set termencoding=utf-8 "if exists('&t_SI') " let &t_SI = "\<Esc>]12;lightgoldenrod\x7" " let &t_EI = "\<Esc>]12;grey80\x7" "endif "----------------------------------------------------------------------- " settings "----------------------------------------------------------------------- " Don't be compatible with vi set nocompatible " Enable a nice big viminfo file set viminfo='1000,f1,:1000,/1000 set history=500 " Make backspace delete lots of things set backspace=indent,eol,start " Create backups "set backup " Show us the command we're typing set showcmd " Highlight matching parens set showmatch " Search options: incremental search, highlight search " set hlsearch " Selective case insensitivity set ignorecase set infercase " Show full tags when doing search completion set showfulltag " Speed up macros set lazyredraw " No annoying error noises set noerrorbells set visualbell t_vb= if has("autocmd") autocmd GUIEnter * set visualbell t_vb= endif " Try to show at least three lines and two columns of context when " scrolling set scrolloff=3 set sidescrolloff=2 " Wrap on these set whichwrap+=<,>,[,] " Use the cool tab complete menu set wildmenu set wildignore+=*.o,*~,*.obj set suffixes+=.in,.a " Allow edit buffers to be hidden set hidden " 1 height windows set winminheight=1 " Enable syntax highlighting if has("syntax") syntax on endif " Set our fonts if has("gui_running") "set guifont=Raize:h10 set guifont=Consolas:h10.5:cANSI endif "中文效果测试" " Try to load a nice colourscheme " No icky toolbar, menu or scrollbars in the GUI if has('gui') set guioptions+=b " set guioptions-=m set guioptions-=T " set guioptions-=l " set guioptions-=L " set guioptions-=r " set guioptions-=R end " By default, go for an indent of 4 tab stuff " set expandtab //讨厌换成空格 set expandtab set shiftwidth=4 set tabstop=4 " Do clever indent things. Don't make a # force column zero. set autoindent set smartindent inoremap # X<BS># " Enable folds "if has("folding") " set foldenable " set foldmethod=indent "endif " Syntax when printing set popt+=syntax:y " Enable filetype settings if has("eval") filetype on filetype plugin on filetype indent on endif " Enable modelines only on secure vim versions if (v:version >= 604) set modeline else set nomodeline endif " Nice statusbar set laststatus=2 set statusline= set statusline+=#%n\ " buffer number set statusline+=%f\ " file name set statusline+=%h%1*%m%r%w%0* " flags set statusline+=\[%{strlen(&ft)?&ft:'none'}, " filetype set statusline+=%{&encoding}, " encoding set statusline+=%{&fileformat}] " file format if filereadable(expand("$VIM/vimfiles/plugin/vimbuddy.vim")) set statusline+=\ %{VimBuddy()} " vim buddy endif set statusline+=%= " right align set statusline+=0x%-8B\ " current char set statusline+=%-14.(%l,%c%V%)\ %<%P " offset "set statusline=%<%f%=\ [%1*%M%*%n%R%H]\ %-19(%3l,%02c%03V%)%O'%02b' "set encoding=unicode set encoding=utf-8 set fileencodings=utf-8,chinese,ucs-bom set ambiwidth=double set langmenu=zh_CN.utf-8 source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim language messages zh_CN.utf-8 filetype plugin on filetype on filetype indent on set autoindent set cindent shiftwidth=4 set autoindent shiftwidth=4 "set mouse=a " use the mouse set sm set cin " DISPLAY OPTIONS set number set ruler "set notitle if (has("gui_running")) set wrap set showtabline=2 colorscheme torte set cursorline "hi LineNr guibg=darkgrey ctermbg=darkgrey guifg=white ctermfg=grey if has('multi_byte_ime') highlight Cursor guibg=white guifg=black highlight CursorIM guibg=yellow guifg=black endif else set wrap colorscheme torte endif let Tlist_Auto_Open=1 if version >= 603 set helplang=cn endif map <F2> :set hlsearch!<CR> map <F7> :wa<CR>:make<CR> imap <F7> <ESC>:wa<CR>:make<CR> imap <F3> <ESC>:wa<CR>a map <F3> :wa<CR> nnoremap <silent> <F8> :TlistToggle<CR> nnoremap <C-Enter> :WinFullScreen<CR> set diffexpr=MyDiff() function MyDiff() let opt = '-a --binary ' if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif let arg1 = v:fname_in if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif let arg2 = v:fname_new if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif let arg3 = v:fname_out if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif let eq = '' if $VIMRUNTIME =~ ' ' if &sh =~ '\<cmd' let cmd = '""' . $VIMRUNTIME . '\diff"' let eq = '"' else let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"' endif else let cmd = $VIMRUNTIME . '\diff' endif silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq endfunction :autocmd BufRead,BufNewFile *.cmake,CMakeLists.txt,*.cmake.in runtime! indent/cmake.vim :autocmd BufRead,BufNewFile *.cmake,CMakeLists.txt,*.cmake.in setf cmake :autocmd BufRead,BufNewFile *.py,*.python map <F5> :w<CR>:!python %<CR> :autocmd BufRead,BufNewFile *.rb,*.ruby map <F5> :w<CR>:!ruby %<CR> :autocmd BufRead,BufNewFile *.d map <F5> :w<CR>:!dmd -debug -run %<CR> :autocmd BufRead,BufNewFile *.d map <F6> :w<CR>:!dmd -debug -unittest -run %<CR> :autocmd BufRead,BufNewFile *.c,*.cpp,*.cxx,*.cc map <F5> :wa<CR>:!gcc %<CR> :!%<<CR> :autocmd BufRead,BufNewFile SConstruct,SConscript runtime! indent/python.vim :autocmd BufRead,BufNewFile SConstruct,SConscript setfiletype python :autocmd BufRead,BufNewFile SConstruct map <F5> :wa<CR>:!scons -Q<CR>
7 楼
qyqx
2007-04-02
我都是照着做的,可是还没搞好,我用的是GVIM7.0 for windows, 一用VIM打开D文件就提示:
"D:\ASM.d" 20L, 382C
找不到映射
请按ENTER或其它命令继续
"D:\ASM.d" 20L, 382C
找不到映射
请按ENTER或其它命令继续
6 楼
oldrev
2007-03-30
F5键要在普通(Normal)模式下
要想在插入模式下也能按F5运行,请将下面的脚本加入 .vimrc(或_vimrc):
:autocmd BufRead,BufNewFile *.d imap <ESC>:w:make
要想在插入模式下也能按F5运行,请将下面的脚本加入 .vimrc(或_vimrc):
:autocmd BufRead,BufNewFile *.d imap <ESC>:w:make
5 楼
smithfox
2007-03-30
I try vim, thank you.
But can't press F5 to debug.
But can't press F5 to debug.
4 楼
oldrev
2007-03-30
引用
为什么用VIM打开d文件,提示说没有映射,按F5没效果.
只要按上面的步骤做应该没问题
3 楼
qyqx
2007-03-30
为什么用VIM打开d文件,提示说没有映射,按F5没效果.
2 楼
ideage
2007-03-30
试验了.很好.的确方便.F5搞定了.写测试项目合适.
1 楼
oldrev
2007-03-30
难道没人用vim?
发表评论
-
Tango 0.99.7 Dominik 今天放出
2008-07-25 12:16 1388详细的发布公告: http://www.dsource.org ... -
D新闻组里的天才代码
2008-03-30 21:26 3272超猛的代码,刚才逛新闻组刚看到的,随便记录一下。 出自: ... -
Ubuntu & D
2008-03-23 12:33 2394前几天 Ubuntu Linux 8.04 (Hardy) 刚 ... -
Dotmars.test 单元测试框架简介
2007-11-19 22:43 94D语言内置的 unittest关键字+assert 组成的单元 ... -
mixin 模拟多继承
2007-11-10 17:40 3661D1.0 代码 /** TupleMixin ... -
简单的 C to D 转换 Ruby 脚本
2007-10-24 22:06 4602今天晚上费了点脑筋写了一个简单的 C2D 转换脚本,大致实现了 ... -
D1.0代码模拟 __traits(hasMember, ...)
2007-10-08 23:12 5120通过1.0的代码完全模拟了 D 2.0 __traits(ha ... -
更好的C++——给C++使用者的D语言简介
2007-09-14 01:30 12228作为 C++ 狂热的粉丝, ... -
让D代码自己编译自己
2007-09-12 22:55 4759刚在 D语言的新闻组里看到了D模板&元编程顶尖高人 ... -
Dotmars 实例之:容器、迭代器与算法框架
2007-08-03 23:49 5682Dotmars 实例之:容器、迭代器与算法框架 这几天 Mr. ... -
基于 D 2.0 编译时反射的单元测试框架
2007-07-27 21:25 2798一个模仿 Ruby Test::Unit 的 Quick &a ... -
D 2.0 Const/Final/Invariant 概念简介
2007-07-24 22:55 5430D 2.0 Const/Final/Invariant 概 ... -
DotMars 版 Hello World
2007-06-05 02:17 8193DotMars 已经具有初步的样子了,特别发帖庆祝。 Dot ... -
关联数组字面值+函数字面值=支持任意类型的 switch
2007-05-19 23:29 4523刚才写字符串格式化的由于要处理所有内置类型,而且只有 Type ... -
.Net/Java 风格格式化字符串
2007-05-18 22:51 3594基础类库的东西看起来容易做起来难,今天花时间实现了一点点 . ... -
修改版 juno.com.base
2007-04-20 00:28 4287dsource 上的 juno 是一个很不错的 Windows ... -
C#-like 的 DLL 封装
2007-04-16 23:19 4376一个类似 C# 的 DllImport 实现,用于“半”动态加 ... -
简单的D语言 VIM 缩写插件
2007-04-13 15:45 3457昨晚我写了一个非常简单的 VIM 的D语言缩写插件,希望能让用 ... -
双向链表模板类
2007-04-07 02:03 3024参考 STL 实现的 Quick & Dirty 双向 ... -
用Rant自动化D语言程序构建
2007-03-31 13:54 3202上回说到 Rank 这个 Ruby 世界最广泛使用的构建工具在 ...
相关推荐
或命令行下 vim –d file1 file2 可进行文件比较 [c 前一差别 ]c 后一差别 2.19缩进 >% 缩进块中内容 反缩进块中内容 >i{ {内部缩进(不包括{}) >a{ {内容缩进(包括{}) 反缩进 反缩进 2.20使用文件模板 :autocmd ...
Vim是一个功能强大的文本编辑器,该文档并不详尽。 Vim语言 Vim命令由动词和目标组合而成。 目标可以是对象(单词,句子,段落,行,括号的内容)或动作(跳至单词的末尾,跳至段落的末尾,向前跳至字母“ e”等)...
与其它的类Vi编辑器相比, Vim拥有众多的特性: 对180多种语言的语法高亮功能, 对C语言的自动缩进, 以及一个功能强大的内置脚本语言. 对每个人来说, Vim总有让他们喜欢的东西. Vim的开发仍然在继续进行, 写作本文时...
vim-textobj-function vim-textobj-function是一个用于功能... 因此,在编辑之前必须将函数的语法告知vim-textobj-function。 默认情况下,支持以下语言: C语言JavaVim脚本(包括特定于语法) 要支持新语言,请参阅:
本文将指导用户在 Fedora 15 环境中进行环境搭建,包括 VIM 配置、网络配置、Samba 配置和防火墙配置。 一、VIM 配置 在 Fedora 15 中,VIM 是默认的文本编辑器。为了提高编程效率,我们需要对 VIM 进行配置。我们...
能够高亮显示的语言列表有:ada, asm, asn1, au3, ave, baan, blitzbasic, bullant, caml, cmake, conf, cpp, csound, css, d, ed, eiffel, Embedded, erlang, escript, flagship, forth, fortran, freebasic, gap, ...
Sublime Text 是一个轻量、简洁、高效、跨平台的编辑器,方便的配色以及兼容vim快捷键等各种优点博得了很多前端开发人员的喜爱!Sublime Text 2这款程序员必备代码编辑器,几乎每位程序员提到Sublime Text 2都是...
产品特点现代 从任何语言进行,包括C / C ++,C#,Clojure,D,Elixir,Go,Haskell,Java,JavaScript / Node.js,Julia,Lisp,Lua,Perl,Python,Racket,Ruby,Rust 嵌入式可编写脚本的异步多个编辑器实例之间...
Sublime Text 是一个轻量、简洁、高效、跨平台的编辑器,方便的配色以及兼容vim快捷键等各种优点博得了很多前端开发人员的喜爱!Sublime Text 2这款程序员必备代码编辑器,几乎每位程序员提到Sublime Text 2都是...
代码编辑界面 历史记录 a199ea2 - (HEAD, origin/master, master) 图片宽度修改 (evilbinary) 046d56e - 高亮基本版本完成 (evilbinary) ...
Sublime Text 3是一个轻量、简洁、高效、跨平台的编辑器,方便的配色以及兼容vim快捷键等各种优点; 它体积小巧,无需安装,绿色便携;它可跨平台支持Windows/Mac/Linux;支持32与64位操作系统,它在支持语法高亮、...
C, C++, C#, CSS, D, Erlang, HTML, Groovy, Haskell, HTML, Java, JavaScript, LaTeX, Lisp, Lua, Markdown, Matlab, OCaml, Perl, PHP, Python, R, Ruby, SQL, TCL, Textile and XML 等主流编程语言的语法高亮。...
Doom Emacs配置每个人都喜欢感染了Vim的滚动发布文本编辑器/操作系统! 这是我的日常驱动程序配置,具有对各种语言(lsp-mode和company-capf),终端仿真器(vterm),git(magit),电子邮件(mu4e + mbsync),...
C, C++, C#, CSS, D, Erlang, HTML, Groovy, Haskell, HTML, Java, JavaScript, LaTeX, Lisp, Lua, Markdown, Matlab, OCaml, Perl, PHP, Python, R, Ruby, SQL, TCL, Textile and XML 等主流编程语言的语法高亮。...
C, C++, C#, CSS, D, Erlang, HTML, Groovy, Haskell, HTML, Java, JavaScript, LaTeX, Lisp, Lua, Markdown, Matlab, OCaml, Perl, PHP, Python, R, Ruby, SQL, TCL, Textile and XML 等主流编程语言的语法高亮。...
C, C++, C#, CSS, D, Erlang, HTML, Groovy, Haskell, HTML, Java, JavaScript, LaTeX, Lisp, Lua, Markdown, Matlab, OCaml, Perl, PHP, Python, R, Ruby, SQL, TCL, Textile and XML 等主流编程语言的语法高亮。...
C, C++, C#, CSS, D, Erlang, HTML, Groovy, Haskell, HTML, Java, JavaScript, LaTeX, Lisp, Lua, Markdown, Matlab, OCaml, Perl, PHP, Python, R, Ruby, SQL, TCL, Textile and XML 等主流编程语言的语法高亮。...
Sublime Text 是一个轻量、简洁、高效、跨平台的编辑器,方便的配色以及兼容vim快捷键等各种优点博得了很多前端开发人员的喜爱!Sublime Text 这款程序员必备代码编辑器,几乎每位程序员提到Sublime Text 都是...
Sublime Text 是一个轻量、简洁、高效、跨平台的编辑器,方便的配色以及兼容vim快捷键等各种优点博得了很多前端开发人员的喜爱!Sublime Text 这款程序员必备代码编辑器,几乎每位程序员提到Sublime Text 都是...
Sublime Text 是一个轻量、简洁、高效、跨平台的编辑器,方便的配色以及兼容vim快捷键等各种优点博得了很多前端开发人员的喜爱!Sublime Text 2这款程序员必备代码编辑器,几乎每位程序员提到Sublime Text 2都是...