vim

Changing variable names in Vim

白昼怎懂夜的黑 提交于 2019-12-29 10:03:54
问题 I am trying to read a lot of C/Perl code through Vim which contain many single letter variable names. It would be nice to have some command which could help me change the name of a variable to something more meaningful while I'm in the process of reading the code so that I could read the rest of it faster. Is there some command in Vim which could let me quickly do this? I don't think regexes would work because: the same single letter name might have different purposes in different scoping

Shortcut to open file in Vim

三世轮回 提交于 2019-12-29 10:03:43
问题 I want to open a file in Vim like in Eclipse using Ctrl + Shift + R , or via the Ctrl + N option of autofill. Invoke a keyboard shortcut, type the file name/pattern, and choose from all the matching files names. I know opening it normally like: :tabe <filepath> :new <filepath> :edit <filepath> The problem here is that I have to specify the whole file path in these cases. 回答1: I recently fell in love with fuzzyfinder.vim ... :-) :FuzzyFinderFile will let you open files by typing partial names

Using git commit -a with vim

非 Y 不嫁゛ 提交于 2019-12-29 10:03:33
问题 I'm new with git, so I decided to learn git using the tutorials of github. The third chapter said: "For this first example we’ll modify the README file to add ourselves as an author on the project. So we simply edit the file. Now we want to commit that change, so we run the git commit -a command." When I use the git commit -a command, the console opens a vim and I wrote my message, but I don't know how to close this vim editor from the console. How do I save the message and close vim? 回答1: In

Why is vim starting in delete mode?

折月煮酒 提交于 2019-12-29 09:23:23
问题 As stated in the question, my vim starts out in delete mode. If I open a file and hit j to start navigating, that'll delete the first line. I've isolated the problem down to this line in my .vimrc : nnoremap <silent> <esc> :noh<return><esc> I don't understand why this would even trigger delete mode. On top of that, I believe I added <silent> to instruct vim to make this binding without executing it, which doesn't seem to be the case. What's the explanation for why this is happening? (side

VIM: insert empty ERB tags

廉价感情. 提交于 2019-12-29 09:04:05
问题 How can I insert empty ERB tags and put cursor inside it? It is similar to surrounding with surround plugin, but there is nothing to surround. For example, from this: bla|bla I want get this: bla<%= | %>bla 回答1: I would use Tim Pope's surround plugin to accomplish this. Add the following to you ~/.vim/after/ftplugin/erb.vim let b:surround_{char2nr('=')} = "<%= \r %>" let b:surround_{char2nr('-')} = "<% \r %>" Now when you press <c-s>= it will insert <%= | %> just as you wanted. You may also

VIM: insert empty ERB tags

旧城冷巷雨未停 提交于 2019-12-29 09:03:16
问题 How can I insert empty ERB tags and put cursor inside it? It is similar to surrounding with surround plugin, but there is nothing to surround. For example, from this: bla|bla I want get this: bla<%= | %>bla 回答1: I would use Tim Pope's surround plugin to accomplish this. Add the following to you ~/.vim/after/ftplugin/erb.vim let b:surround_{char2nr('=')} = "<%= \r %>" let b:surround_{char2nr('-')} = "<% \r %>" Now when you press <c-s>= it will insert <%= | %> just as you wanted. You may also

Vim syntax and Latex math inside markdown

Deadly 提交于 2019-12-29 07:35:10
问题 I write documentation in markdown using ViM and I also put math using the latex $$ symbol (I compile using pandoc). The thing is that ViM syntax wouldn't ignore the underscores _ inside the dollar symbols and it is pretty annoying. For instance if I write this: $$ a_1 = 0 $$ Then Vim will highlight all the following text as italics due to to the underscore used. How can I change that? Also it would be nice if I could highlight what's inside $ with a different format. 回答1: I have put these

filetype setting lost after reloading all files in buffer

☆樱花仙子☆ 提交于 2019-12-29 06:20:35
问题 After running :bufdo e! All my files lose their filetype setting and I have to manually run :set ft=XXX in each file. Anyone know how to solve this issue? Running :bufdo set ft=XXX doesn't work and I don't want to set all files to the same filetype at any rate. Cheers. 回答1: You can fix this automatically via the following autocmd: " Enable syntax highlighting when buffers were loaded through :bufdo, which " disables the Syntax autocmd event to speed up processing. augroup

How to use correct ruby in vim ? How to modify $PATH in VIM?

流过昼夜 提交于 2019-12-29 03:39:07
问题 I use plain Vim with ruby support on Lion (installed by gist). I am using ruby with rbenv so my path looks like /users/me/.rbenv/shims:..... From within vim the path is :!echo $PATH > usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/fb/.rbenv/shims:.... Even I can create and modify an environment variable: :let $PATH = "/bar:/foo" :!echo $PATH > /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/foo:/bar paths remains starting with /usr/bin. So how can I access my ruby

Switching to a particular tab in VIM

半城伤御伤魂 提交于 2019-12-29 02:46:44
问题 I was trying to switch from a tab to another tab (which may not be adjacent to the previous tab) in VIM. Is there any shortcut for that, like we have Ctrl - p / Ctrl - n for switching to adjacent tabs? Also, I was trying to write a key mapping which will give a variable as input to a function and do the operation. For instance, let's say I press Ctrl - 5 and a function (written by the user) will be called and given as input 5, and the cursor will go to tab 5 (if there is any 5th tab opened).