Hot answers tagged

9

how to load vim8 optional packages in vimrc? The way to load vim8 optional packages in your vimrc is to use the :packadd! command, which will add them to your 'runtimepath', which will make the opt plugins load together with the ones in start. In your particular case: packadd! vim-javascript The examples you give hint that what you're actually trying to ...


8

Running process in a terminal buffer is treated mostly the same way as "an unsaved file". So you can do :qa! or :set confirm etc.etc. Well, anything to allow exit from Vim with buffers unsaved. But, of course, that will modify Vim's behaviour with respect to all buffers, not only terminals. So if you only want to allow silent terminal closing, you should ...


5

From discussion in comments I learned that OP has a custom vimgrep call and would like to run it asynchronously. The utility of this is pretty clear, especially if you run a lot of searches that take a while: by moving the execution into a separate/background thread you free up Vim's UI so you can continue working without waiting for the result. As I ...


5

You need to use :tnoremap to map keys in the :terminal window. So if you want that to work in both normal mode of a regular buffer and of terminal windows, you need to add another set of mappings for the terminal: tnoremap <C-J> <C-W><C-J> tnoremap <C-K> <C-W><C-K> tnoremap <C-L> <C-W><C-L> tnoremap <...


4

You mention in the comments, that the file Python.h is located in the directory $LOCAL_INSTALL/include/python3.8. This directory is not in the search path for include files. So it has to be added manually. export CFLAGS="-I$LOCAL_INSTALL/include/python3.8" ./configure ... The configure script adds the compiler flags from the environment variable ...


4

Terminal buffer is special: When the job has finished and no changes were made to the buffer: closing the window will wipe out the buffer. Change buffer type will stop this. Manual After job finished, clear buffer type: setlocal buftype= This also works: setlocal modifiable " make any change, the 1st change will convert terminal buffer to be a normal ...


4

I rarely ever run :Gpush on its own, so maybe try this: :Gstatus in the new split view, use - to toggle which changes you want to stage for the commit, then use cc to commit. After entering the commit message and save/quit, the split window shows unpushed commits; you can use - to push individual commits. The exact push line and parameters are shown in ...


3

Is there a reason you open each file in a different tab with -p? The standard way to open multiple files is to open them in different buffers. See this answer for more about buffers vs windows vs tabs. You can cycle through the buffer displayed in the top window with :bnext and similar. The workflow I would suggest to achieve what you want would be ...


3

You can use any of the popup_* functions that open popups with a buffer number, so, let bufnr = bufadd(expand('<cfile>')) let popup_id = popup_create (bufnr, {})


3

how to debug it? You can use the :verbose command to increase verbosity of a specific command. In this particular case, you need verbosity level above 3 to see the actual shell command executed by Vim, so this should work: :4verbose make Calling shell to execute: "pylint --output-format=text --msg-template="{path}:{line}:{column}:{C}: [{symbol}] {...


3

Based on Chris’s comments on the OP, I would make the shell do the work, using a level of indirection: terminal bash -c "cd wherever && do_something" The issue is that the bare :terminal command doesn’t ever execute a shell—it executes the name of the external program you give it (which, by default, happens to be the shell). So, terminal cd . tries ...


3

Quote from vim-fugitive README: FAQ Why can't I enter my password when I :Gpush? It is highly recommended to use SSH keys or credentials caching to avoid entering your password on every upstream interaction. If this isn't an option, the official solution is to use the core.askPass Git option to request the password via a GUI. Fugitive will ...


3

The solution was to define $HOME as a Windows environment variable. Once I did that and restarted gVim, it read my ~\_vimrc and also sourced my native Vim 8.1 packages correctly. Source: this answer at Stack Overflow.


3

Use the :vertical and :botright modifiers. nnoremap <F5> :wa \| vertical botright term ++kill=term<CR> Or: nnoremap <F5> :wa<CR>:vertical botright term ++kill=term<CR> (Also note that you need one of <CR> or \|, not both. Your original command ends up executing the Normal mode | motion, which moves the cursor to the first column, ...


3

I did a little investigation. At first I could not reproduce, but I think I have found the problem (part of it was, you did not mention what version you were using :/) I have a local machine with an Ubuntu 18.04.03 LTS installed. In it, I could reproduce the problem when using the system vim (I usually compile my own), that is version 8.0.1453. I traced ...


2

See :h Terminal-mode: Terminal-Job and Terminal-Normal mode Terminal-mode Terminal-Job When the job is running the contents of the terminal is under control of the job. That includes the cursor position. Typed keys are sent to the job. The terminal contents can change at any time. This is called Terminal-...


2

(Thanks to @d-ben-knoble) makeprg does not include filename, so :make % should be used to lint the current file


2

Without newish packages feature you can use ~/.vim/plugin/ folder. All vim files you have in this folder are auto sourced using :h :runtime: I do exactly this for my settings: main vimrc is ~45 lines having only core options separate ~/.vim/plugin/mappings.vim file for mappings and commands other separate vim files (foldtext setup, terminal setup etc) ...


2

Using 0read on BufNewFile actually works as expected, in fact the documentation for BufNewFile explicitly mentions using that event for loading a template or skeleton file. If we also rule out the other things that might have gone wrong there, then the most likely explanation is that 0read is working, but the contents of the buffer are later erased by ...


2

This question is largely addressing some follow-up questions OP had in response to an answer I gave to another question that they posted. This one also talks about a solution involving lambda functions and closures that is valid but more complicated than needed for most use cases. For both those reasons I recommend you check out that Q&A first: How to ...


2

I've done something similar before. I was learning Vim's fold commands. I just stuffed my cheat sheet in a string that separated each line with a comma... let g:foldcmds = split("zf (Plus a motion) Operator to create a fold.,zF Create a fold for [count] lines. Works like zf.,zd Delete one fold at the cursor.,zD Delete folds recursively at the ...


1

Is it possible to call a vim script function with the help of job_start? Not directly. I guess you would need Vim to be multithreaded, which might be possible in the future. In fact I've used the command :vimgrep to make my custom grep. It worked. Now I starts to use vim 8 so I'm thinking if it's possible to make my custom grep async. FWIW, I wrote some ...


1

You could open the terminal in a new tab page (:tab terminal) and then use :tabnext / :tabprevious to switch between them.


1

Option 1 (not in Gvim): Use CTRL-Z to suspend Vim. That will give you Vim's parent shell. To go back to Vim, enter fg in the command line. Option 2: Spawn a terminal in a Vim window with :ter (or :terminal). Now, go back to the original window with CTRL-W CTRL-W and press CTRL-W _ to maximize its height. Note that the terminal window will still occupy one ...


1

To detect afk you can use CursorHold and CursorHoldI events. If you want to run it once: augroup afk | au! autocmd CursorHold,CursorHoldI * ++once echo "Run my timer here" augroup END Or everytime user is AFK : augroup afk | au! autocmd CursorHold,CursorHoldI * echo "Run my timer here" augroup END Both events are fired after ...


1

Tested on Vim Version: 8.2.1537 Response: A timer's resources will be freed on one of three conditions: the timer_stop() function in Vim is called, invoking it's counterpart stop_timer() in the C source.1 after invoking the callback function, there are no repetitions left for the timer, upon which free_timer() is invoked.2 the timer has encountered an ...


1

I presume you run (g)Vim with a shortcut. there is current working directory in vim :lcd to see it and :lcd dir to change it. (if you run (g)vim.exe or shortcut it would be path to (g)vim executable) depending on how your python script is implemented, it might read this json file from current working directory (it is inherited by :!) not from your script ...


1

Those symbols are displayed in what's called the signcolumn. Fortunately, there's some degree of control over it using the 'signcolumn' setting. Available values will cause the column to be shown: "auto" only when there is a sign to display "no" never "yes" always "number" display signs in the 'number' column. If the ...


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

The help for the function term_setansicolors provides some more details. The short story is these 16 colors form a conventional palette which terminal programs use when outputting text. You can set them to anything you want, but it's best to stick to the vague color descriptions below. term_setansicolors({buf}, {colors}) *term_setansicolors()* ...


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