vim

conditional map in normal mode?

左心房为你撑大大i 提交于 2019-12-24 00:46:19
问题 Is it possible in vim to do a conditional map, in normal mode? I've seen it for insert mode. I want to remap gq, depending on the outcome of a function. Something like: nnoremap gq if(g:set_formatprg()) | gq | else | = | endif Notice that g:set_formatprg() will not always have the same value, so it cannot be replaced by if(!g:set_formatprg()) | nnoremap gq = | endif 回答1: An expression map makes it easy nnoremap <expr> gq g:set_formatprg() ? 'gq' : '=' For more help see :h map-expression 来源:

Vim 'earlier' and 'later' commands are not working as expected

会有一股神秘感。 提交于 2019-12-24 00:29:19
问题 By first looking at the command for time travelling in Vim i.e. ea {N}s and lat {N}s , I thought it'll be really simple. But, it's not working for me as expected and now I'm totally confused. This is what happened. I fired up my Vim, and started writing the following lines say, first line written at time 5 second line written after a pause of 5 seconds may be around time 18 third line again after a pause of 5 seconds around 30 So, suppose if I started writing at 00:00:00 , I completed line 1

Make AutoComplPop allow hyphen as a word charcter

浪尽此生 提交于 2019-12-24 00:29:12
问题 This screenshot explains the problem I'm having: I would like address-font rather than address to appear in the AutoComplPop dropdown, as hyphenated class names are common in idiomatic css. But by default they are considered the end of a word. How can I configure ACP so that a hyphen is treated just like any other letter and the full class names appear as options for autocompletion? 回答1: The setting iskeyword controls what characters vim uses to determine word characters. - is not normally

C++ development on linux Code::Blocks, EMACS or GVIM [closed]

非 Y 不嫁゛ 提交于 2019-12-23 23:14:57
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I am not looking for an IDE suggestion for C++ development. I have found many discussions on that and tried EMACS, GVIM and Code:

Jump to file without modifying jump list

送分小仙女□ 提交于 2019-12-23 22:27:27
问题 I'm writing a TAGS-like plugin. It should be able to jump to the given file, line, and column. I use :edit to jump to the right file, and then G / | to jump to the right location (as explained here). My problem is that :edit adds the beginning of the target file to the jump list, and thus I end up with two locations in the jump list instead of one. Can I prevent :edit from modifying the jump list, or maybe make it open the target file at the right location? 回答1: Use :keepjumps edit to avoid

How do I actually use the value of an argument to a Vim function?

爱⌒轻易说出口 提交于 2019-12-23 20:04:44
问题 I'm trying to write a simple Vim function that takes the name of a file as an argument and reads the contents of that file into the current document (related to this question). Here's my first stab at it: fun! Tpl(tplfile) r c:\tpl\a:tplfile endfun That just gives me the following error: E484: Can't open file c:\tpl\a:tplfile How do I make the function actually use the value of the tplfile argument? 回答1: Replace the line with: exe 'r c:\tpl\' . a:tplfile The a:tplfile is a string variable, so

Slow tab switching in Vim with large terminal

亡梦爱人 提交于 2019-12-23 19:43:49
问题 My vim is very slow to switch tabs ( :tabnext ) when i've fullscreened my terminal (1920x1200). Does anyone have a fix for this? Is it a vim issue, or is it my setup? Redrawing a black terminal (gnome-terminal) with a bit of text shouldn't be that hard. 回答1: It is probably the gnome-terminal problem. Vim with my fullscreen (1920x1080) rxvt-unicode (urxvtc) terminals works just fine. 来源: https://stackoverflow.com/questions/2864084/slow-tab-switching-in-vim-with-large-terminal

Jump to CSS definition when editing HTML in VIM

∥☆過路亽.° 提交于 2019-12-23 19:26:24
问题 For example I am editing index.html or index.php in VIM and I have the following code in there: <div id="header"> // some code </div> When I move my cursor to the word header I want to jump to the position in my CSS-file where the tag (id/class) is defined. ctags doesnt work with this. Thx for advise! 回答1: You could try to patch ctags so that it supports CSS. This guy explains how but I have no idea if it works or not. I'll probably give this solution a try very soon as I think this feature

YouCompleteMe unavailable : requires Vim 7.4.143

依然范特西╮ 提交于 2019-12-23 19:23:42
问题 my apologies if im asking a retarded question. New to windows bash and saw the vim Plugin "YouCompleteme" and tried to install it with Vundle. However im getting the error as stated in the title. My vim current ver is 7.4.52 anyone have any idea how to solve this? Edit : I just realised when i just call vim it says 7.4.52 however when i call :version it says 7.4 does this mean im using the wrong vim ? 回答1: You need to upgrade to the latest vim so run the following commands: sudo add-apt

Substituting zero-width match in vim script

…衆ロ難τιáo~ 提交于 2019-12-23 19:19:56
问题 I have written this script that replaces many spaces around the cursor with one space. This however doesn't work when I use it with no spaces around the cursor. It seems to me that Vim doesn't replace on a zero-width match. function JustOneSpace() let save_cursor = getpos(".") let pos = searchpos(' \+', 'bc') s/\s*\%#\s*/ /e let save_cursor[2] = pos[1] + 1 call setpos('.', save_cursor) endfunction nmap <space> :call JustOneSpace()<cr> Here are a few examples (pipe | is cursor): This line