vim

Vim: keep location list window open after selecting a file

不问归期 提交于 2020-05-15 10:24:42
问题 I need exactly the opposite behavior of this question. My observation is that upon pressing enter on a line in location list window, the window will be closed and the main window will display the content of the selected file. As a contrary, quickfix window doesn't have this behavior, i.e., it remains opened after the selection. I have checked my autocmd and there is no special handling for location list or quickfix list. An example - :lgrep hi * to populate the location list. lopen to open

In vim, what is the difference between <c-r>+register and <c-r><c-p>+register with the . command?

折月煮酒 提交于 2020-05-14 18:04:48
问题 I struggle to understand the solution to this vimgolf challenge. The best proposed solution is cw(<C-R><C-P>")<Esc>w.w.ZZ Then I tried to do cw(<C-R>")<Esc>w.w.ZZ But then the text becomes (one) (one) (one) instead of (one) (two) (three) Can someone help me to understand why . behaves differently with those two commands? 回答1: Since the accepted answer addresses the difference between CTRL-R CTRL-R and CTRL-R CTRL-O but doesn't answer the question as to why . behaves as it does, and the

In vim, what is the difference between <c-r>+register and <c-r><c-p>+register with the . command?

五迷三道 提交于 2020-05-14 18:03:06
问题 I struggle to understand the solution to this vimgolf challenge. The best proposed solution is cw(<C-R><C-P>")<Esc>w.w.ZZ Then I tried to do cw(<C-R>")<Esc>w.w.ZZ But then the text becomes (one) (one) (one) instead of (one) (two) (three) Can someone help me to understand why . behaves differently with those two commands? 回答1: Since the accepted answer addresses the difference between CTRL-R CTRL-R and CTRL-R CTRL-O but doesn't answer the question as to why . behaves as it does, and the

E185: Cannot find color scheme*

落花浮王杯 提交于 2020-05-12 11:31:09
问题 I have been customizing my vimrc file but for some reason, no colorschemes work. Whenever I try to change the colorscheme, it just gives me: E185: Cannot find color scheme '*' I checked the color folder to make sure I actually have colors and I do. For example the first item in the color folder is blue.vim but when I put colorscheme blue in the vimrc, it just gives E185: Cannot find color scheme 'blue' when I start Vim and the colorscheme doesn't apply. I also tried changing the colorscheme

Add word under cursor to search pattern

一个人想着一个人 提交于 2020-05-10 07:14:54
问题 Using * when the cursor is on a word theWord , vim directly jumps to the next appearance of exactly that word, i.e. performes /\<theWord\> . Questions: Is there a way to add another word otherWord to the search, when the cursor is on this other word, such that one performes /\<theWord\>\|\<otherWord\> ? 回答1: Try something like: * (to search for a word) move somewhere else :let @/=@/.'\|\<'.expand("<cword>").'\>' this appends to the previous search pattern the current word under the cursor)

Add word under cursor to search pattern

岁酱吖の 提交于 2020-05-10 07:12:10
问题 Using * when the cursor is on a word theWord , vim directly jumps to the next appearance of exactly that word, i.e. performes /\<theWord\> . Questions: Is there a way to add another word otherWord to the search, when the cursor is on this other word, such that one performes /\<theWord\>\|\<otherWord\> ? 回答1: Try something like: * (to search for a word) move somewhere else :let @/=@/.'\|\<'.expand("<cword>").'\>' this appends to the previous search pattern the current word under the cursor)

vim: delete all blank space until next non-blank character

拈花ヽ惹草 提交于 2020-05-09 21:08:11
问题 Say I have the following code: <p> Hello </p> And I want to make it <p>Hello</p> I would like to put the cursor in normal mode at the end of line 1, so on the ' > ' and have a command to delete all spaces until the next character. The closest I can think of is the motion d/Hello which deletes everything until Hello but the issue is that it deletes also the character under the cursor (the ' > ') so I end up with <pHello </p> How would you do that? 回答1: One way when you won't need to repeat

vim: delete all blank space until next non-blank character

本小妞迷上赌 提交于 2020-05-09 21:07:37
问题 Say I have the following code: <p> Hello </p> And I want to make it <p>Hello</p> I would like to put the cursor in normal mode at the end of line 1, so on the ' > ' and have a command to delete all spaces until the next character. The closest I can think of is the motion d/Hello which deletes everything until Hello but the issue is that it deletes also the character under the cursor (the ' > ') so I end up with <pHello </p> How would you do that? 回答1: One way when you won't need to repeat

Vim scripting: Preserve cursor position and screen view in function call

假装没事ソ 提交于 2020-05-09 19:06:14
问题 I have some Vim functions that make changes to the document format. When I call this function, I currently use something like the following to save and restore my cursor position: func! Foo() :norm mz ... :norm `z endf This properly saves the cursor position, but it sometimes changes the window position, so that the current line moves from being near the top of the screen to being near the bottom or vice versa. Is there a way to preserve both cursor position and the on-screen position of the

Vim scripting: Preserve cursor position and screen view in function call

人走茶凉 提交于 2020-05-09 19:05:53
问题 I have some Vim functions that make changes to the document format. When I call this function, I currently use something like the following to save and restore my cursor position: func! Foo() :norm mz ... :norm `z endf This properly saves the cursor position, but it sometimes changes the window position, so that the current line moves from being near the top of the screen to being near the bottom or vice versa. Is there a way to preserve both cursor position and the on-screen position of the