vim

What are the most-used vim commands/keypresses?

不打扰是莪最后的温柔 提交于 2019-12-20 07:58:09
问题 I'm a Ruby programming trying to switch from Textmate to MacVim, and I'm having trouble wading through the gargantuan lists of things you can do in VIM and all of the keypresses for them. I'm tired of hearing "You can use 'I' for inserting text, or 'a' for appending text after the character, or 'A' for appending text at the end of the line, or…" I can't imagine everyone uses all 20 different keypresses to navigate text, 10 or so keys to start adding text, and 18 ways to visually select an

How to edit blocks in vim without visual block mode

痴心易碎 提交于 2019-12-20 07:13:11
问题 Is there a way to edit a vertical block in a code without using the visual block mode selection? 回答1: What's so bad about blockwise visual mode ?! There's no practical alternative to it. You could use :substitute with atoms like \%>v , \%<v , \%>l and \%<l to limit the pattern match to a rectangular block, but that's very tedious. There are some multi-edit plugins (inspired by other editors) that allow you to select some areas, and then simultaneously edit them all. For special purposes, you

Is it possible to change tab header color each filetype in vim?

女生的网名这么多〃 提交于 2019-12-20 06:36:32
问题 If I'm opening .js, .html, .rb and other filetype, is it possible to change tab color each filetype? Tab means vim's tab not like space. 回答1: Use the format %#String# will color with the string hightlight : - set tabline=%#String#\ toto A script to put in your vimrc : function! TabTest() let res = '' for i in range(tabpagenr('$')) let i += 1 " Get open buffer let i_window = tabpagewinnr(i) let l_buffer = tabpagebuflist(i) let i_buffer = l_buffer[i_window - 1] " Get type let s_type = getbufvar

Undofile independent of the Vim version

谁说胖子不能爱 提交于 2019-12-20 06:31:18
问题 I'm using the Vim 7.3 feature undofile the following way: if version >= 703 set undofile set undodir=$HOME/.vim/undo set undolevels=1000 set undoreload=10000 endif I am using the same .vimrc and the same files (within a cloud storage) on different machines which do not support Vim 7.3 but use the old 7.2 version which does not support undofile out of box. Is there a solution for the 7.2 version compatible with the 7.3 undofile? 回答1: version check Because persistent undo was introduced with

Undofile independent of the Vim version

血红的双手。 提交于 2019-12-20 06:31:08
问题 I'm using the Vim 7.3 feature undofile the following way: if version >= 703 set undofile set undodir=$HOME/.vim/undo set undolevels=1000 set undoreload=10000 endif I am using the same .vimrc and the same files (within a cloud storage) on different machines which do not support Vim 7.3 but use the old 7.2 version which does not support undofile out of box. Is there a solution for the 7.2 version compatible with the 7.3 undofile? 回答1: version check Because persistent undo was introduced with

Vim的终极自动补全插件:NeoComplCache

三世轮回 提交于 2019-12-20 06:11:02
版權所有:晴耕雨讀@ 【牧碼志】 ,如需轉載,請注明出處。 原文地址: http://0x3f.org/?p=1399 关于自动补全,最初用的是 SuperTab ,那个时候Vim的自动补全插件寥寥无几,也就SuperTab比较有名。不过实际使用过程中这个插件给我的体验不是很好,原因是补全的准确度不高。 后来出了一个新插件, AutoComplPop ,功能和使用都很简单。但是很快我就又用回SuperTab,原因是AutoComplPop在输入的同时实时地查询匹配的关键词,导致输入极不流畅,效率很低。 一直就这么凑合着用着SuperTab,随着这个插件版本的更新,旧功能不断地完善,新功能也接二连三地引入,SuperTab在匹配关键词的准确度上有了一些改善,但是新的问题又出现了。SuperTab后来加入一个新功能,对于程序源文件,可以在其引入的文件以及API文件中匹配关键词。比如假设我当前正在编辑a.php,在a.php中有 include ‘b.php’; 这样的语句,当我输入 array 并按下Tab键时,SuperTab不但会在当前文件中查询所有匹配项,还会到b.php中查询,如果配置过vim、指定一个包含了php的API的文件,则SuperTab还会自动从这个文件中查询匹配项。按理说这个功能的理念很好,但问题就在于SuperTab做的是实时查询,如果源文件中包含的文件较多

Capture the number of 'yes' clicks in a substitute command with confirmation?

≯℡__Kan透↙ 提交于 2019-12-20 05:58:23
问题 Is it possible to capture the number of 'yes' clicks in a substitute command with confirmation? p.e. :%s/foo/bar/gc replace with bar (y/n/a/q/l/^E/^Y)? number of y clicks = ? 回答1: If you want to know how many substitutions were done (the number of y ), after all occurrences confirmation were asked, you will see X substitutusions on Y lines , the X is what you want. If you are writing a script and you want to get the number in your script. You can either implement this counter in your function

Advanced Usage of Ranges with Vim Keymappings

南笙酒味 提交于 2019-12-20 05:52:08
问题 I have a mapping in my vimrc that downwardly comments out regions of c code: nmap comc :normal! I//<ESC> Since the 'normal' ex command implicitly converts input such as "Ncomc" to ".,.+N-1 comc", I can range comments downwardly without many keystrokes and without leaving normal mode. This is, however, a very limited subset of what vim ranges can do. If I'm willing to be verbose, I can achieve upward ranging comments like so: .,.-5 normal comc While editing text, I would much prefer to type

Vim: underscore(_) automatically converted to (<-)

白昼怎懂夜的黑 提交于 2019-12-20 05:37:18
问题 I have been writing R scripts in Vim for some time now. Starting an hour ago, I began facing an issue that every time I type an underscore ( _ ), it gets automatically converted to <- . What setting did I change for this to happen? Thanks! 回答1: :verbose imap _ should tell you which (probably filetype plugin) has set this. It's less likely to be an abbreviation, but :verbose ia _ would tell you. 回答2: The VIM: r-plugin does indeed change the mapping but the documentation section 4.1 states "it

Editable vimgrep string in command line

自古美人都是妖i 提交于 2019-12-20 05:18:31
问题 I use vimgrep a lot to navigate in files and usually use the last search from the history to modify the search pattern and run it again. Is there a way to display in the command line an editable string like the one below, with the cursor already positioned between the two search pattern slashes (and the pattern being empty)? :vimgrep // **/*[ch]|copen I don't want to use a constant mapping (like the one at this vim tip) since I want to be able to add/change options (\c etc.). 回答1: I'd