Hot answers tagged

4

For the URLs, I have the pattern \w\+:\/\/[^[:space:]]\+, but I cannot figure out what to put in containedin. The best I came up with is containedin=bibQuote,bibBrace, that works but it breaks syntax highlighting for everything that comes after the URL. This pattern actually works, except in cases where the URL is at the end of the field value and ends up ...


3

A milestone in my question answering career: this is the first time I solved something with nothing but a pure, unadulterated, grade-A SWAG. I don't know how much value this will have for anyone but the OP but an answer is an answer. Forgive the padding. ;) I didn't seen anything wrong with the sample code in the question. These are both perfectly valid ...


2

Building uppon Lie Ryan's answer and the code provided above (it is described here) . Change your function parsing the git branch as follows: let g:gitparsedbranchname = ' ' function! UpdateGitBranch() let l:string = system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'") let g:gitparsedbranchname = strlen(l:string) > 0?'['.l:...


2

In Vim, if you look at the source code for buflist_new() which adds a filename to the buffer list you'll find the part where the b: dictionary is initialized // init b: variables buf->b_vars = dict_alloc(); if (buf->b_vars == NULL) { vim_free(ffname); vim_free(buf); return NULL; } init_var_dict(buf->b_vars, &buf->b_bufvar, ...


2

You have several ways to do it: You can use <bar> which is the key code for | to be used in a mapping (Do not use | directly in your mapping): nnoremap <leader>a :echo "fizz" <bar> echo "buzz"<CR> This is the equivalent of running :echo "fizz" | echo "buzz" in the command line. You can also ...


2

Adapting the answer to another question about multibyte-aware character at current position, consider using the :help /\%v zero-width atom to perform a string match. let l:wordBeforeCursor = matchstr(getline('.'), '\k\+\%' . virtcol('.') . 'v') let l:WORDContainingCursor = matchstr(getline('.'), '\S*\%' . virtcol('.') . 'v\S*') The first uses \k to match ...


2

Seems remiss1 to not mention what some would consider the fastest way to jump back to the previous line: '', i.e. just double-tap apostrophe. The nice thing is that you can bounce back and forth between two lines with the same command. A couple things to be aware of: This takes you to the first non-blank character of the previous line (as all jump-to-mark ...


2

The jumplist (see :help jumplist) can be navigated with Ctrl-o, to go back to line 700 (and Ctrl-i would take you back to line 456 again). If you want to be able to do this with relative jumps (i.e. after typing 7j to go seven lines down, use Ctrl-o to return to where you before the relative jump), you can use following two remaps in your .vimrc: " ...


2

No, you have to write such "option parser" yourself. But quite probably there's no need to do this. Just re-write your function to accept dictionary argument. For example, function! SubmitJob(opts) abort let l:opts = extend(copy(a:opts), #{hours: 1, cpus: 1}, 'keep') echo l:opts.hours l:opts.cpus endfunction :call SubmitJob(#{cpus: 2}) &...


1

Once you have vim how you like it, it's possible to save the session (so any files you have open, the arrangement of splits you have etc.). See :help mksession Basically, you can just do: :mksession! and vim will write a file into the currentent directory. As I've written it above, I provided no file name and therefore vim will default to naming the file ...


1

You can try to set this value: set foldmethod=syntax


1

Mapping the escape key like this tends to break things because of the way certain special characters are handled (references needed/appreciated). I would also recommend avoiding <C-t> and <C-]> as they are pretty useful commands (:help CTRL-T, :help CTRL-]). You might want to know about gt and gT for navigating tabs. They also take a count. Here'...


1

A substitution like this works for all scenarios: %s/print(\(.*\))/log.info(" ".join([\1]))/ Grab everything within print brackets (.*) using regex replace the match with a join statement surrounding the match replace the print with log.info (or whatever is required) Here is the test script if anyone wants to try it for themselves: import logging,...


1

Finally, I decided not to re-invent the wheel, and this problem seems to be more difficult than I think. So, I give Vem-Tabline a try and it works nicely, and the default settings of this plugin are good, so no need to put code into my .vimrc. Nice! Now my MacVim looks like this, the prefix of buffer names are now skipped by default:


1

My problem was I was trying to source my vimrc file within gvim/vim and my changes were not being applied in the session. I would have to reopen gvim/vim to see the changes. Adding the $HOME user environment variable: C:\Users\<username> resolved this. For my setup I am using Windows 10 and vim/gvim 8.2. Instead of using the user vimrc file: $HOME\...


1

Checking for X11-clipboard support in terminal From the console, type: vim --version | grep clipboard If you see +clipboard or +xterm_clipboard, you are good to go. If it's -clipboard and -xterm_clipboard, you will need to look for a version of Vim that was compiled with clipboard support. Installing clipboard support On Debian and Ubuntu, to obtain ...


Only top voted, non community-wiki answers of a minimum length are eligible