vim 键映射<F7><F8><F9>
2013-04-28 09:05
330 查看
写单个程序,如果每次都自己输入:set makeprg=gcc\ .......什么的就太麻烦了.所性自己定义快捷键.当然,大程序就用makefile了.这里只是为了方便下:
---------------------------------------------------------------------------------------------------------------------
,<F7>编译 ,<F8>运行 ,<F9>带参运行
举例:写文件foo_001.c 则make成可执行文件001 .如果有参,文件应是:foo_001.in 则输出foo_001.out
分隔符是下划线,稍微看下就可以随自己个性修改使用
----------------------------------------------------------------------------------------------------------------------
nmap <leader><F7> :call Gcc_make()<cr><cr>
nmap <leader><F8> :call Gcc_run()<cr><cr>
nmap <leader><F9> :call Gcc_run_infile()<cr><cr><cr>
function Gcc_run()
exec "! mv %:r `echo %:r | cut -d'_' -f2`"
exec "!./`echo %:r | cut -d'_' -f2`"
endfunction
function Gcc_run_infile()
exec "! mv %:r `echo %:r | cut -d'_' -f2`"
exec "!./`echo %:r | cut -d'_' -f2` < %:r.in > %:r.out"
exec "!cat ./%:r.out"
endfunction
function Gcc_make()
exec "w"
let s:input_file = expand("%") . "\\"
let s:output_file = expand("%:r")
exec "set makeprg=gcc\\\ -g\\\ -Wall\\\ " . s:input_file "-o\\\ " . s:output_file
exec "make"
endfunction
---------------------------------------------------------------------------------------------------------------------
,<F7>编译 ,<F8>运行 ,<F9>带参运行
举例:写文件foo_001.c 则make成可执行文件001 .如果有参,文件应是:foo_001.in 则输出foo_001.out
分隔符是下划线,稍微看下就可以随自己个性修改使用
----------------------------------------------------------------------------------------------------------------------
nmap <leader><F7> :call Gcc_make()<cr><cr>
nmap <leader><F8> :call Gcc_run()<cr><cr>
nmap <leader><F9> :call Gcc_run_infile()<cr><cr><cr>
function Gcc_run()
exec "! mv %:r `echo %:r | cut -d'_' -f2`"
exec "!./`echo %:r | cut -d'_' -f2`"
endfunction
function Gcc_run_infile()
exec "! mv %:r `echo %:r | cut -d'_' -f2`"
exec "!./`echo %:r | cut -d'_' -f2` < %:r.in > %:r.out"
exec "!cat ./%:r.out"
endfunction
function Gcc_make()
exec "w"
let s:input_file = expand("%") . "\\"
let s:output_file = expand("%:r")
exec "set makeprg=gcc\\\ -g\\\ -Wall\\\ " . s:input_file "-o\\\ " . s:output_file
exec "make"
endfunction
相关文章推荐
- vim颜色选择+按<F9>自动编译运行+其他基本配置(ubuntu)
- vim:将<esc>映射为CapsLock键
- vim做映射时使用<C-u>做前缀的原因
- mybatis 映射 List<String>
- <转>如何在Mac OS X中开启VIM语法高亮
- Hibernate逍遥游记-第5章映射一对多-02双向(<set>、<key>、<one-to-many>、inverse、cascade="all-delete-orphan")
- MVC<2:路由映射原理3>
- 图片映射(HTML <map>标签)这么拽,小伙伴们都知道吗?
- SpringBoot系列<四>视图解析、路径-资源映射、静态资源访问
- hibernate 映射<四>多对一双向映射
- vi或vim搜索之</><?>---linux命令
- 深入Hibernate映射文件(二)——<hibernate-mapping>的属性
- Hibernate <三> 映射对象标识符
- 简明 Vim 练级攻略 &lt;转&gt;
- ACE_TAO sequence<string> strList C++ 映射
- HTML <area> 标签实现带有可点击区域的图像映射
- MVC<2:路由映射原理4>
- hibernate 映射文件的 <generator>元素
- Hibernate<二> 映射基础 单个持久类与单个数据库表映射
- vim map <ESC> in command-line mode