Andrew Ho-Lee
  • Member for 1 year, 2 months
  • Last seen more than a month ago
How does the underscore forward movement work? _f
Accepted answer
5 votes

_fe should go to the first occurrence of e on that line. Can you give an example of where it doesn't? From :h _: _ <underscore> [count] - 1 lines downward, on the first non-blank ...

View answer
Use vi to replace everything between two known strings on multiple lines
Accepted answer
4 votes

This will do that for you: :%s/\v^AAA,([^,]+)/AAA,0.05/ Explanation: %s/{pattern}/{string}/: for each line in the whole file (%) substitute a match of {pattern} with {string} (:h :s) \v: one of vim'...

View answer
How to inverse boolean in Vimscript?
4 votes

You can invert a boolean with !: let foo = 1 echo foo " will print 1 let foo = !foo echo foo " will print 0 I'm afraid I can't help much with the overall function as I am unfamiliar with ...

View answer
Open two terminal windows side by side
Accepted answer
4 votes

You can specify commands to be run using the -c argument. Therefore, this should work for you: vim -c 'terminal ++curwin' -c 'vertical terminal' If your goal is just to have two terminal windows ...

View answer
How to prevent whitespace associated with items in the statusline from taking up space, when the item is not shown?
4 votes

Another option is to use a conditional: set statusline+=%{&readonly?'\ [RO]':''} This allows you to also change what is shown. For example, I have: set statusline+=%{&readonly?'\ !!':''}

View answer
How to multi select for the purpose of copy operation?
Accepted answer
3 votes

If you want to copy multiple separate words and paste them at the end of a long document, here are some options. Option 1: splits You can open the same buffer side-by-side using :vsplit. You can then ...

View answer
Why isn't netrw (:Explore) loaded, when starting vim using `vim -u NONE`?
Accepted answer
3 votes

netrw is a plugin, just one that is distributed with vim itself. For me, :Explore and friends are defined in /usr/local/share/vim/vim82/plugin/netrwPlugin.vim. From the load-plugins section of :h ...

View answer
How to copy text to clipboard in visual mode?
Accepted answer
3 votes

Vim uses registers to store text. It may be helpful for you to read :h registers if you haven't already, as well as the user manual (this is covered in section 04.7) Assuming you are using a version ...

View answer
How to show a terminal under all tabs?
3 votes

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 ...

View answer
Prevent cycling / wrapping to first buffer after last
Accepted answer
2 votes

Whilst there isn't a vim-native option to configure this, you can simulate it by writing your own functions to overload :bnext and :bprev. function! Bnext() let bufnrs = range(1, bufnr("$&...

View answer
How to run internal (Neo)Vim ":Command" from external Terminal?
Accepted answer
2 votes

You can pass a command when starting up with -c (or +): vim -c 'PlugUpdate' You may also want to pass qall if you are running this from a script.

View answer
Can I make a bufwrite bound command save the buffer without triggering infinite filewrite operations?
Accepted answer
2 votes

You could write the file again in BufWritePost but without triggering the autocmd using noautocmd. For example, if I open a file called tmp and do: autocmd BufWritePost * call append(0, "foo&...

View answer
I need two windows on the same file but screen too small for split
2 votes

Another option is to use marks. Marks are a way of remembering a position within a file. To set a mark in a file, use ma to set mark a. To jump back to that mark, use 'a to jump to that line, or `a ...

View answer
How can I compile all spell .add files?
Accepted answer
2 votes

This should do it: for d in globpath(&runtimepath, "spell/*.add", 0, 1) execute "mkspell! " . fnameescape(d) endfor This finds all spell/*.add files in your &...

View answer
Enter insert mode automatically after moving (e.g. with e, w)
Accepted answer
2 votes

There isn't, but it is possible to create a mapping to do this. For example, if you want <leader>e to do the equivalent of e then i: nnoremap <leader>e ei Edit: as statox notes in the ...

View answer
How to stop Vim hanging until keypress?
Accepted answer
2 votes

I suspect the answer is in set colorscheme blue which should just read colorscheme blue. Further reading on changing colours can be found in :h usr_06 and :h :colorscheme.

View answer
How do you prevent a new window from opening when running :make
Accepted answer
2 votes

One way to do this natively in vim is to utilise system() or systemlist(). I'm not familiar with pyunit, but something like the following may help you get started. function! MyMake() abort let l:...

View answer
What's the name of the highlight group for the number column?
Accepted answer
2 votes

It’s LineNr and CursorLineNr.

View answer
Send command to :terminal buffer in Vim?
Accepted answer
2 votes

:! runs the command in a (usually non-interactive) shell. See chapter 21 of the user manual and :h :! for more information. This is different to :term which runs an interactive terminal in a vim ...

View answer
Pipe file list to vim and browser them like a folder
Accepted answer
2 votes

Here are three options depending on what you are trying to achieve: If you specifically want the output of grep, then you can just use :grep/:vimgrep from within vim. This will populate the quickfix ...

View answer
How to make neovim cmdline-completion suggests common matched substring?
1 votes

It is likely that there are other commands that start with :Vim but not :Vimspector that are being offered in the completion, hence why it stops there. Natively, vim offers the :VimballList command. ...

View answer
How to automatically re-apply max window height + width upon terminal resize?
Accepted answer
1 votes

You could set a global variable (g:zoom_status) to remember whether you are meant to be zoomed in (maximised) or not. Then, every time the terminal is resized restore the windows to that status. For ...

View answer
Yanking range into register while ignoring blank lines
1 votes

An alternative to using :global which doesn't overwrite a lettered register is to do this with vimscript calls: :call getline(10, '$')->filter({_, v->strlen(v)})->setreg('*') You could take ...

View answer
Vim's spell check: Ignore abbreviations in acro package commands?
1 votes

If I'm reading the acro manual correctly, you have to define all acronyms in the preamble with \DeclareAcronym{abc}{properties}; if that's not correct you can adapt the code below to use \ac{} and ...

View answer
Automatically resize window based on filetype
1 votes

Caveat: I don't have the :Man command which you have presumably defined yourself, but this should work: autocmd BufEnter * if &filetype ==# "man" | wincmd _ | endif

View answer
How to change cursor position when using iabbrev
1 votes

How about this: iabbrev sysout System.out.println ();<Left><Left> Note that unless you plan on adding a space inside the parentheses, you'd want to expand the abbreviation with e.g. <C-...

View answer
cannot save raw plug.vim file
Accepted answer
1 votes

You shouldn't alter the base vim configuration. Instead, you should put this in your user's vim configuration directory, which on macOS would be ~/.vim i.e. ~/.vim/autoload/plug.vim. To answer you ...

View answer
vim get error properly formatted in quickfix
1 votes

As Biggybi notes, there may be a misunderstanding as I'm not sure if you want the quickfix window to correctly interpret the output of latexmk or you want it to display the errors in a different way. ...

View answer
How do I manage the activation of vim abbreviation?
1 votes

I don't think this is possible using vim abbreviations. The closest you can come is to press CTRL-V before pressing the next key that would otherwise trigger the abbreviation. If you wish to have ...

View answer
Is there a reason why the short for `'modifiable'` is `'ma'` and not `'mo'`?
1 votes

It is probably because there are two similarly-named options: 'modifiable' (shortened to 'ma') and 'modified' (shortened to 'mod').

View answer