harttle.github.io icon indicating copy to clipboard operation
harttle.github.io copied to clipboard

2015/07/18/vim-cpp

Open harttle opened this issue 7 years ago • 25 comments

在VIM下写C++能有多爽? - Harttle Land

http://harttle.land/2015/07/18/vim-cpp.html

harttle avatar May 02 '18 18:05 harttle

我现在遇到的问题是不能refactor,没有找到好用的refactor工具,如果变量或者函数要重命名会非常麻烦,有什么好用的插件可以解决这个问题吗?另外,YouCompleteMe很棒,但是目前不能显示函数的参数提示,这个也比较麻烦。

By NoAnyLove 2016-01-21T18:49:14Z

harttle avatar May 02 '18 18:05 harttle

如果可以做到查找你需要的名称(函数、变量)的话,其实就不需要refactor工具了吧!可以录一个宏或者用『.』来重复上一次编辑。YouCompleteMe没有参数吗?它调用的是外部工具,换一个工具即可。比如:https://github.com/Valloric...

By Yang Jun 2016-03-05T05:36:33Z

harttle avatar May 02 '18 18:05 harttle

网上搜索查找了一番,看起来,目前Vim上的解决方案好像都是利用搜索,比如EasyGrep,不过总感觉不如通过语法分析进行的重命名靠谱,Emacs下倒是有专门的refactor插件。YCM的函数参数提示功能虽然有改进的计划,不过目前好像没有进度,pull#1300已经没有变化很久了。不太确定你指的调用外部工具和换一个工具是什么意思。

By NoAnyLove 2016-03-05T06:53:34Z

harttle avatar May 02 '18 18:05 harttle

There's also an omnifunc-based completer that uses data from Vim's omnicomplete system.
YCM automatically detects which completion engine would be the best in any situation.
YCM内置了一些C的completion engine,但我们应该可以安装其他的completion engine来提供Vim的omnifunc(http://vimdoc.sourceforge.n...
C++我不了解,比如JavaScript补全可以安装一个tern_for_vim(https://github.com/ternjs/t...
它便是提供了omnifunc的completion handler,然后YCM就可以补全JS了。

至于是基于搜索还是语义我不太了解,我估计是语义补全,一来YCM文档中处处都在提semantic,二来补全过程中确实会进行一些编译(难道是我的linting插件做的编译?)。

By Yang Jun 2016-03-05T08:46:51Z

harttle avatar May 02 '18 18:05 harttle

请问 如果main 文件包含自定义头文件,但头文件里面的实现在源文件里面,您是如何通过main编译运行的,一般会出现未定义错误,如果通过命令单独编译链接没问题,通过vim会出现问题

By 何杰 2016-05-31T02:58:52Z

harttle avatar May 02 '18 18:05 harttle

这和Vim没有关系。如果你是做了vim快捷键映射,仅仅相当于你在当前目录输入那些命令。可以在进行快捷键映射之前先跑通了(通过:! <command>命令)。

如果是编译一个c++工程,还是建议写一个makefile,在vim里映射这个命令:`:!make`。

Good Luck :)

By Yang Jun 2016-05-31T06:12:03Z

harttle avatar May 02 '18 18:05 harttle

thinks

By 何杰 2016-06-12T02:53:38Z

harttle avatar May 02 '18 18:05 harttle

Vim直接支持`:make`这个命令。

By pg999w 2016-07-21T11:47:44Z

harttle avatar May 02 '18 18:05 harttle

棒!少一个`!`

By Yang Jun 2016-07-21T12:08:24Z

harttle avatar May 02 '18 18:05 harttle

YouCompleteMe 已经改用 install.py 了。

By jingjinghack 2017-02-09T13:50:33Z

harttle avatar May 02 '18 18:05 harttle

我的delimitMate貌似默认没有“在一对括号之间回车,自动分为3行并调整缩进”的功能诶~需要特殊的设置吗?

By TJM 2017-04-15T22:21:02Z

harttle avatar May 02 '18 18:05 harttle

filetype indent on
参考:http://vimdoc.sourceforge.n...

By Yang Jun 2017-04-16T14:01:06Z

harttle avatar May 02 '18 18:05 harttle

感谢您的帮助于回复
filetype indent 默认是 on
而且我又手动 :filetype indent on 了一次
然而并不能自动三行+缩进

终端记录: https://fars.ee/t/uk-d.json

By TJM 2017-06-05T08:20:12Z

harttle avatar May 02 '18 18:05 harttle

我初步怀疑是cinoptions的问题,您能分享一下您的cinoptions吗?

By TJM 2017-06-05T08:28:33Z

harttle avatar May 02 '18 18:05 harttle

我记得我是通过插件配置这个行为的,不确定具体是哪个插件。我的配置都在这里:https://github.com/harttle/... 你应该可以试出来。

By Yang Jun 2017-06-05T09:13:34Z

harttle avatar May 02 '18 18:05 harttle

经过一个半月的试验……貌似是因为新版delimitMate没这个功能了or在某些发行版上不支持这个功能了……我换成了auto-pairs就OK了

By TJM 2017-07-21T05:38:15Z

harttle avatar May 02 '18 18:05 harttle

issue #closed

By TJM 2017-07-21T05:38:31Z

harttle avatar May 02 '18 18:05 harttle

很强大 学习了

By Zee 2017-08-21T13:32:53Z

harttle avatar May 02 '18 18:05 harttle

”暂且不提它毁了多少人的面试之路“hhhhh, 手写代码也很有争议吧,有人描述过如果允许用自己熟悉的IDE的话,不知道要在工作中准备多少种IDE和各种配置的版本。 跟编译器较真是日常了。

ghost avatar May 22 '18 02:05 ghost

”YouCompleteMe“ 忘记这个插件如何修改背景颜色了,博主记得吗。

ghost avatar May 22 '18 02:05 ghost

设置了运行、编译、调试的快捷键 关于这个,看了别人的博客也是这么写,可是按一下会编译完成还没看到结果又自己跳回到vim的代码界面了怎么破,终于找到一个能留言的博客,抓住博主问个清楚! (突然想到应该是用了多窗口的tmux,还没看,打扰了..)

ghost avatar May 22 '18 03:05 ghost

欢迎star和fork https://github.com/Leptune/vim-for-coding

Leptune avatar Oct 08 '18 09:10 Leptune

请问编译运行里除了设置F5系列的,我可以设置command + B运行吗

wsh3776 avatar Nov 23 '19 06:11 wsh3776

请问autoformat怎么设置运算符两侧空格?

wsh3776 avatar Nov 23 '19 13:11 wsh3776

大哥,讲细一点啊。我不会弄

blusewang avatar Feb 01 '21 10:02 blusewang