vim

Is there a way for vim to open all .C and .H files in a directory and all its subdirectories?

北城余情 提交于 2021-01-27 06:53:03
问题 I want to execute a substitution in vim on around 20 *.C and *.H files, and I want to open them all at once. All files are distributed in multiple nested directories, and the command is executed in the top parent directory. Can I do this using only vim, or do I need the "find" command and the "-p" option as shown on this answer? 回答1: Start Vim at the root of your project: $ vim /path/to/project Add the relevant files to the arglist, recursively: :argadd **/*.C **/*.H See :h starstar and :h

Vim: Indent with tabs, align with spaces

点点圈 提交于 2021-01-27 03:00:52
问题 I've already read several questions and answers: Vim: Use tabs for indentation, spaces for alignment with C source files Vim: Align continous lines with spaces But none of them offers a solution for me. I really want to apply the "Indent with tabs, align with spaces" principle, but when it comes to auto-indentation, I failed to teach Vim how to do that right. Consider the code, assuming tabstops == 3 , shiftwidth == 3 ( >-- means tab, and . (a dot) means space): { >--long a = 1, >-->--..b = 2

Vim: Indent with tabs, align with spaces

匆匆过客 提交于 2021-01-27 02:57:58
问题 I've already read several questions and answers: Vim: Use tabs for indentation, spaces for alignment with C source files Vim: Align continous lines with spaces But none of them offers a solution for me. I really want to apply the "Indent with tabs, align with spaces" principle, but when it comes to auto-indentation, I failed to teach Vim how to do that right. Consider the code, assuming tabstops == 3 , shiftwidth == 3 ( >-- means tab, and . (a dot) means space): { >--long a = 1, >-->--..b = 2

Vim: Indent with tabs, align with spaces

久未见 提交于 2021-01-27 02:57:13
问题 I've already read several questions and answers: Vim: Use tabs for indentation, spaces for alignment with C source files Vim: Align continous lines with spaces But none of them offers a solution for me. I really want to apply the "Indent with tabs, align with spaces" principle, but when it comes to auto-indentation, I failed to teach Vim how to do that right. Consider the code, assuming tabstops == 3 , shiftwidth == 3 ( >-- means tab, and . (a dot) means space): { >--long a = 1, >-->--..b = 2

vim--vim中右键激活了可视模式

做~自己de王妃 提交于 2021-01-23 22:49:09
在vim的命令行中输入:help mouse 就可以找到答案,查看鼠标的配置方案。 vi的三种模式:命令模式,插入模式,可视模式.鼠标可以用于启动各种模式: The mouse can be enabled for different modes: n Normal mode v Visual mode i Insert mode c Command-line mode h all previous modes when editing a help file a all previous modes r for |hit-enter| and |more-prompt| prompt Normally you would enable the mouse in all four modes with: :set mouse=a When the mouse is not enabled, the GUI will still use the mouse for modeless selection. This doesn't move the text cursor. 所以配置文件中的set mouse=a启动了所有模式,这样就屏蔽了鼠标右健功能. 来源: oschina 链接: https://my.oschina.net/u/1395664/blog/1925241

Delete everything between two brackets in Vim, including newlines

寵の児 提交于 2021-01-21 07:03:11
问题 Say I have the following python array literal: def f(): arr = [ 1, 2, 3 ] I want to delete everything in the brackets so that it becomes this: def f(): arr = [] How can I do that with minimal commands in vim? These are some of my attempts: Using di] will delete the text, but not the empty newlines, leaving a lot of whitespace I'd have to delete: def f(): arr = [ ] Using da] will delete the newlines, but also the brackets: def f(): arr = 回答1: You can simply do: ca[[]<Esc> or: ca][]<Esc> See

Perform a non-regex search/replace in vim

女生的网名这么多〃 提交于 2021-01-20 15:19:40
问题 When doing search/replace in vim, I almost never need to use regex, so it's a pain to constantly be escaping everything, Is there a way to make it default to not using regex or is there an alternative command to accomplish this? As an example, if I want to replace < with < , I'd like to just be able to type s/</</g instead of s/\</\&lt\;/g 回答1: For the :s command there is a shortcut to disable or force magic. To turn off magic use :sno like: :sno/search_string/replace_string/g Found here:

技巧:Vimdiff 使用

僤鯓⒐⒋嵵緔 提交于 2021-01-14 06:14:27
技巧:Vimdiff 使用 转载地址: http://www.ibm.com/developerworks/cn/linux/l-vimdiff/ 各种 IDE 大行其道的同时,传统的命令行工具以其短小精悍,随手可得的特点仍有很大的生存空间,这篇短文介绍了一个文本比较和合并的小工具:vimdiff。希望能对在 Unix/Linux 系统上进行开发的朋友有所帮助。 源程序文件(通常是纯文本文件)比较和合并工具一直是软件开发过程中比较重要的组成部分。现在市场上很多功能很强大的专用比较和合并工具,比如 BeyondCompare;很多IDE 或者软件配置管理系统,比如Eclipse, Rational ClearCase都提供了内建``的功能来支持文件的比较和合并。 当远程工作在Unix/Linux平台上的时候,恐怕最简单而且到处存在的就是命令行工具,比如diff。可惜diff的功能有限,使用起来也不是很方便。作为命令行的比较工具,我们仍然希望能拥有简单明了的界面,可以使我们能够对比较结果一目了然;我们还希望能够在比较出来的多处差异之间快速定位,希望能够很容易的进行文件合并……。而Vim提供的diff模式,通常称作vimdiff,就是这样一个能满足所有这些需求,甚至能够提供更多的强力工具。在最近的工作中,因为需要做很多的文件比较和合并的工作,因此对Vimdiff的使用做了一个简单的总结

How do I enable python in my new GVIM 8.2 installation on windows 10?

人走茶凉 提交于 2021-01-05 07:11:31
问题 I installed the latest gvim from vim.org today. It is a 'loaded' package with many options, cfr infra (output of :version command) I have python 2.7 installed, the python27.dll resides in c:\windows\system32. The python37.dll and pyhon39.dll are available in the 'c:\Program Files\python37' and 'c:\Program Files\python39' directories. These three directories with python dlls are on the system path. Both Gvim and Vim output 0 on the echo has('python') and echo has('python3') commands. Do I have

How do I enable python in my new GVIM 8.2 installation on windows 10?

别说谁变了你拦得住时间么 提交于 2021-01-05 07:09:08
问题 I installed the latest gvim from vim.org today. It is a 'loaded' package with many options, cfr infra (output of :version command) I have python 2.7 installed, the python27.dll resides in c:\windows\system32. The python37.dll and pyhon39.dll are available in the 'c:\Program Files\python37' and 'c:\Program Files\python39' directories. These three directories with python dlls are on the system path. Both Gvim and Vim output 0 on the echo has('python') and echo has('python3') commands. Do I have