vim

Git commit messages lost by vi

。_饼干妹妹 提交于 2019-12-20 11:35:11
问题 I'm a clumsy typist, and I don't use vi/vim very often, but I do use it for commit messages. However, if you type a wrong command while editing a commit message ( :Wq , say, instead of :wq ), when you correctly close out the commit message in vim with :wq or :x , you get this: error: There was a problem with the editor 'vi'. Please supply the message using either -m or -F option. Normally, a wrong command like :W is no problem—vim just ignores it and you can keep on working with the file and

Use a register value as search pattern

百般思念 提交于 2019-12-20 11:18:09
问题 I wish to use the content of a register as search pattern in Vim. I would like to do this from the command line so I cannot use the <c-r> syntax since that assumes an interactive session. It is possible to use a register as a replace pattern, like this :%s/foo/\=@a/g However using this syntax as a search pattern does not work :%s/\=@a/foo/g it outputs E64: \= follows nothing E476: Invalid command 回答1: I don't think it's possible directly, but you can use :exe to achieve this: :exe '%s/' . @a

Install GVIM on windows with Python3 support?

五迷三道 提交于 2019-12-20 10:59:11
问题 How do I install GVIM for Windows with Python3 support? I have installed VIM 7.4 which says in it's version file (run :version command) "+python3/dyn" and "-DDYNAMIC_PYTHON3_DLL=\"python32.dll\". So it looks like it's ready to support Python 3. When I run :echo has("python3") it returns zero. And if I test with :py3 print("hello") it says it cannot load python32.dll. 回答1: Here is an approach that I used to get VIM 7.x to work with Python 3.x. Install a VIM of your preference. Suggestion: get

Utilizing emacs' or vim's syntax highlighter for command-line program?

我是研究僧i 提交于 2019-12-20 10:56:00
问题 I have a command-line program that spews JSON and YAML. By default it detects if pygments (pygmentize) is available and if it does, pass the output throught it to get a nice colorized output. However, pygments is not installed by default on most computers that this program will run on. But most computers will have either emacs or vim, however, does. Is there a way to get one of these editors to syntax-highlight some text using ANSI escape sequences and then output it again? 回答1: as the editor

Set Vim's shiftwidth and tabstop based on directory

霸气de小男生 提交于 2019-12-20 10:38:23
问题 I have a project I'm working on currently where the coding standard is to use 2 space indentation. On other projects, however, I use 4 space indentation. Is there an easy way to tell vim that all files within a certain directory should have a tabstop of 2 spaces? 回答1: The venerable Tim Pope just released a plugin call Sleuth, which automagically determines shiftwidth and tabstop (among other buffer options) based on what's used in the current file (or, incredibly, if it's a new buffer, based

Vim html.erb snippets?? snipMate Need a vim tip

孤者浪人 提交于 2019-12-20 10:35:03
问题 When I'm in an html.erb file, I get no snipMate snippets. I would like both HTML and Ruby, or just HTML would be fine, How would I do this? Would I need to write a set of snippets? If so, is there a way of pulling in existing snippets without copying them? Is there a way of telling vim to go into html mode when it sees .html erb? 回答1: Snippets are stored in directory called snippets somewhere in your ~/.vim folder. If you look there, there is usually one file per filetype, there is a c

Finding definitions/references to C++ class members in Vim

守給你的承諾、 提交于 2019-12-20 10:28:52
问题 I'm using Vim for a C++ project that I've started working on and I've been spending a lot of time lately browsing through the existing code to get a hang of it. To make the browsing easier, I've setup ctags and cscope in Vim to jump to definitions and find references. However, I find that neither of them are intelligent enough to know which class a member variable/function belongs to. For example: class Square; ... Square a; ... a.rotate(); Attempting to find the definition of rotate() will

VIM textwidth has no effect

China☆狼群 提交于 2019-12-20 10:25:14
问题 This feels like a dumb question, but I can't find an answer on the Internet (or in VIM help). I'm using VIM 7.2 on Mac OS X. All I want to do is wrap my lines at 72 characters, but doing :set textwidth=72 has no effect. The textwidth is being set correctly (I can see that when I just query ":set textwidth"), but neither existing lines nor new lines that I type after setting textwidth get wrapped. If I start a new line, still doesn't wrap. Open and close the file, no change. I've also tried

Vim extension (via Python)?

…衆ロ難τιáo~ 提交于 2019-12-20 10:24:04
问题 is it possible to extend vim functionality via custom extension (preferably, written in Python)? What I need ideally is custom command when in command mode. E.g. ESC :do_this :do_that 回答1: vim supports scripting in python (and in perl as well, I think). You just have to make sure that the vim distribution you are using has been compiled with python support. If you are using a Linux system, you can download the source and then compile it with ./configure --enable-pythoninterp make sudo make

Why some commands in vim require a colon while some don't?

最后都变了- 提交于 2019-12-20 10:23:22
问题 Some of the commands in vim are given by first typing a colon (:) eg . :wq for saving a file and quitting . While some of the commands don't require a colon for example the Replace command (R). I want to know what is the difference between the two approaches ? Is there any specific rule as to which ones require a colon and which ones don't ? 回答1: You have to look into the history of vi, the predecessor of Vim, for an explanation. A long time ago, when text editing had to be done with a