vim

Advanced searching in Vim

笑着哭i 提交于 2020-01-12 07:37:06
问题 Is there a way to search for multiple strings simultaneously in Vim? I recall reading somewhere that it was possible but somehow forgot the technique. So for example, I have a text file and I want to search for "foo" and "bar" simultaneously (not necessarily as a single string, can be in different lines altogether). How do I achieve that? 回答1: /^joe.*fred.*bill/ : find joe AND fred AND Bill (Joe at start of line) /fred\|joe : Search for FRED OR JOE 回答2: Actually I found the answer soon after

Vim and ctags: tag filenames

瘦欲@ 提交于 2020-01-12 06:46:15
问题 Is it possible to have ctags generate tags for filenames as well? I would like to be able to jump to a file given a filename. :find seems to be awfully slow compare to tags... 回答1: Try running ctags -R --extra=f . The --extra=f option tells ctags to: "Include an entry for the base file name of every source file (e.g. "example.c"), which addresses the first line of the file." When you open vim, you can the use :tag <filename> to jump to the first line of the file. 回答2: You can open the

Vim replace all without cursor moving

*爱你&永不变心* 提交于 2020-01-12 06:37:29
问题 In Vim, when I do: :%s/foo/bar/g It will replace all occurrence of 'foo' with 'bar' in the entire document. When it completes, the cursor has moved to the last position where 'foo' was replaced with 'bar'. How do you run :%s/foo/bar/g without the cursor leaving the original position before issuing this command? Is there some option I can set in .vimrc file? 回答1: I just type Ctrl + O after the replace to get back the the previous location. 回答2: When the :substitute command is run, before

Vim plugin to generate Javascript Documentation comments

蓝咒 提交于 2020-01-12 05:50:12
问题 Is there a plugin for vim, somewhat like Jsbeautify, which automatically generates JavaDoc like comments in the script files. For example it will take this function(a , b , c){ } and return /** * Description. * * @param a Description. * @param b Description. * @param c Description. */ function(a , b , c){ } 回答1: Here's a little something to get you started - tweak as required!-) " generate doc comment template map <LocalLeader>/ :call GenerateDOCComment()<cr> function! GenerateDOCComment()

Vim code completion

折月煮酒 提交于 2020-01-12 03:29:09
问题 Is it possible to make Vim complete the code for you, like in any other IDE (not just word searching, but members of classes, methods etc.)? What are the best options / plugins available? 回答1: It's possible, but most people don't. vim is a fairly generic editor, that said, it does contain some "code completion" features such as word completion, etcetera, but nothing like the likes of, say, Delphi's IDE. Such a system could be added by scripting vim - vim can directly run several scripting

How to paste before the cursor after selecting a vertical block?

孤者浪人 提交于 2020-01-11 20:58:46
问题 I'm so sure that this must exist, but if it doesn't maybe there is a macro for it... One of my most favourite features of vim is the insert before when in visual mode ( <C-v> , select the lines, <C-I> , type a little, then Esc ). My issue is that I want to paste the clipboard contents before, not 'insert'. I tried <C-P> but no love. I have read cheat sheets, searched everywhere, looked through the questions on here and haven't found it, but I could definitely be searching for the wrong thing.

How to paste before the cursor after selecting a vertical block?

和自甴很熟 提交于 2020-01-11 20:58:40
问题 I'm so sure that this must exist, but if it doesn't maybe there is a macro for it... One of my most favourite features of vim is the insert before when in visual mode ( <C-v> , select the lines, <C-I> , type a little, then Esc ). My issue is that I want to paste the clipboard contents before, not 'insert'. I tried <C-P> but no love. I have read cheat sheets, searched everywhere, looked through the questions on here and haven't found it, but I could definitely be searching for the wrong thing.

How to paste before the cursor after selecting a vertical block?

爱⌒轻易说出口 提交于 2020-01-11 20:57:06
问题 I'm so sure that this must exist, but if it doesn't maybe there is a macro for it... One of my most favourite features of vim is the insert before when in visual mode ( <C-v> , select the lines, <C-I> , type a little, then Esc ). My issue is that I want to paste the clipboard contents before, not 'insert'. I tried <C-P> but no love. I have read cheat sheets, searched everywhere, looked through the questions on here and haven't found it, but I could definitely be searching for the wrong thing.

How do you disable a specific plugin in Vim?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-11 19:59:10
问题 I have Vim set up to use the excellent NERDTree plugin. However, there are some environments where I do not want this plugin to be loaded. In my .vimrc I have a sections that are only run when specific environment variables are true. In one of these sections I would like to disable the loading of NERDTree but all of the information I've come across states how to disable all plugins, not just one. Could someone demonstrate how to disable the loading of one specific plugin in Vim? 回答1: Most

How do you disable a specific plugin in Vim?

扶醉桌前 提交于 2020-01-11 19:58:08
问题 I have Vim set up to use the excellent NERDTree plugin. However, there are some environments where I do not want this plugin to be loaded. In my .vimrc I have a sections that are only run when specific environment variables are true. In one of these sections I would like to disable the loading of NERDTree but all of the information I've come across states how to disable all plugins, not just one. Could someone demonstrate how to disable the loading of one specific plugin in Vim? 回答1: Most