Maxim Kim
  • Member for 5 years, 4 months
  • Last seen this week
How do I disable vim from producing backup files?
Accepted answer
19 votes

Try adding: set nobackup nowritebackup to your vimrc. UPDATE with regards to Jason Lefler's answer If you want to prevent your backup/undo/swap files to be created next to your edited file ...

View answer
Change color of CoC suggestion box
Accepted answer
13 votes

I don't use coc, so I will just share my vision on how you can try to fix this. I assume that by suggestion box you mean regular vim Pmenu. Try to make sure if it is actually Pmenu: run :hi Pmenu ...

View answer
How can I add text to the end of words on each line?
Accepted answer
10 votes

You can also use :%s/\w\+/`&` to convert from Lorem ipsum dolor sit amet to `Lorem` `ipsum` `dolor` `sit` `amet` :% range to the next command (whole buffer) s is a substitute command :s/...

View answer
Import an error file to the quickfix list without leaving vim
Accepted answer
8 votes

Try :h :cfile or :h :cgetfile :cf[ile][!] [errorfile] Read the error file and jump to the first error. This is done automatically when Vim is started with the -q option. You ...

View answer
How to navigate long lines like separate lines?
Accepted answer
8 votes

You can use the gj and gk commands to move the cursor to the character in the next or previous display lines, even when lines wrap. See :help gj and :help gk for details. If you would like to ...

View answer
How to left-align two columns of text?
Accepted answer
8 votes

See accepted answer to Align a block of code on the basis of a single character To recap ggVG to select all :'<,'>normal f:5a you don't have to enter '<,'> and also note space at the end....

View answer
Visual Block Mode: How to insert text to multiple lines after line ending?
Accepted answer
7 votes

It could be done with virtualedit=ALL: set virtualedit=all select visually vertical part of the text A\<ESC> return set virtualedit=block See the screen:

View answer
How to change the command line status message color and font?
Accepted answer
6 votes

Try combination of :h echohl and :h echon: :echohl Statement | echon "Hello " | echohl Identifier | echon "World" | echohl None | echon "!!!" echohl will apply highlight ...

View answer
How to generate a string by concatenating another string with an environment variable
Accepted answer
6 votes

In vim dot is a concatenation operator: let repo = $Project . '/cfora' To "refer" variable in the string, well, in your case it is just a concatenation again: exe '!cmake ' . repo PS I would ...

View answer
Starting vim with a command typed in, but not executed (i.e. waiting for argument)?
Accepted answer
5 votes

You can use feedkeys(): vim +'call feedkeys(":MyCommand")'

View answer
How do I enter N carriage returns during a substitution?
Accepted answer
5 votes

You can use repeat function with replace expression: %s/\n\_s*$/\=repeat("\r", 10) Check :h sub-replace-expression and :h repeat() for details.

View answer
Can I define a function with '#'-namespace in a file with hyphen '-' in its name?
Accepted answer
5 votes

So how can I define function with namespace in a file foo-bar.vim? Is it possible? I don't think it is possible. See :h 41.15 of the User Manual for autoload feature of vim (which you call namespace) ...

View answer
How to detect whether the current line is empty line?
Accepted answer
5 votes

It is not entirely clear when you say to "trigger some mapping"... Do you want to create a mapping with nnoremap if current line is empty? I guess not. Or you want to have a mapping that ...

View answer
Why doesn't vimscript provide a random number generator?
5 votes

Vim has rand() function since 8.1.2342 rand([{expr}]) *rand()* *random* Return a pseudo-random Number generated with an xoshiro128** algorithm using seed {expr}. ...

View answer
How to use code highlighting and checking in markdown?
Accepted answer
5 votes

If you use default markdown filetype which is bundled with vim (tpope's markdown): make sure you have let g:markdown_fenced_languages = ['dart', 'python', 'ruby', 'go'] in your vimrc. This is the ...

View answer
How can I use a plugin mapping in my own mapping?
Accepted answer
5 votes

Change you mapping to nmap instead of nnoremap. nnoremap uses "default" mappings on the right mapped side (it doesn't allow nested mappings, like gcc). Thus nmap yc yygccpi

View answer
Switch between splitted file with SPACE + NUMBER instead of CTRL-W (like in spacevim)
Accepted answer
5 votes

To see window numbers you have to setup statusline (:h statusline), for example: set statusline=[%{winnr()}] set statusline+=%([\%R%M]\ %) set statusline+=%<%f set statusline+=%(\ %y%) set ...

View answer
How to insert text from a variable at current cursor position?
5 votes

You might go with setline function or simple: let text = "Lorem ipsum sit dolor amet ..." exe "normal! a" . text . "\<Esc>" exe (:execute) is to execute vimscript normal! a executes a command ...

View answer
How can I look up the current/default guifont reliably?
5 votes

So it looks like if no guifont is specified in your vimrc, gVim will use some built in default font and it would not be reflected in guifont -- set guifont is empty. But it turns out it is possible ...

View answer
How do I use 'cgn' for word under cursor?
Accepted answer
5 votes

There is no built-in way to do it (as an option), as far as I know. I have the following mapping: " change current word (like ciw) but repeatable with dot . for the same next " word nnoremap <...

View answer
Can not move to other buffers unless I save the current one
Accepted answer
4 votes

Add set hidden to your vimrc. Although :h 'hidden' doesn't state it clearly, it would allow you to switch buffers without saving them.

View answer
How can I expand a:000 list in order to pass through all varargs parameters to another function?
Accepted answer
4 votes

Use :h call(): func! Bar(...) abort return a:000 endfunc func! Foo(...) abort echo call('Bar', a:000) endfunc call Foo('asdf', 'qwer') " --> ['asdf', 'qwer']

View answer
How I can add <C-6> to a mapping
Accepted answer
4 votes

<C-6> is a normal mapping (I guess you want to switch to alternate buffer). But the way you call it is incorrect -- calling it as an ex-command. Normal mode commands in vimscript should be ...

View answer
Always show top bar with files names
Accepted answer
4 votes

How can I keep that top bar always open? set showtabline=2 As stated in the help topic: The value of this option specifies when the line with tab page labels will be displayed: 0: ...

View answer
In nowrap mode, is it possible to add a ">" sign to signal there's text rightward that hasn't been displayed?
Accepted answer
4 votes

Try :h 'list' and :h 'listchars' set list listchars=tab:›\ ,extends:→,precedes:←,nbsp:·,trail:· with list you activate > and < with listchars you can change > and < to other symbols if ...

View answer
Can I navigate backwards by word (not WORD) in command-line mode?
4 votes

I don't think there is a built-in way to do it with bare cmdline accroding to :h cmdline.txt. But if you are into heavy edit of the command line I suggest to use :<C-f> or q: to open command-...

View answer
Calling a function before autocmd event is triggered
Accepted answer
4 votes

Use <cmd> pseudo key to call a function without involving command-line mode (:h <cmd>) For example: func! Splitresize() echom "Resize!!!" endfunc nnoremap <silent> ...

View answer
How to use func to quickly add specific comments to certain lines of a file?
Accepted answer
4 votes

Use append() function instead as described in :h setline() help section. It accepts the line number and and either a text line or a list of text lines that would be inserted/appended after given line ...

View answer
Adding new filetypes with vim commentary
4 votes

Make sure you vim-commentary works, e.g. you can open python file and gcc to comment current line. To add support for a new filetype -- filetype has to provide commentstring, so if you are the author ...

View answer
Delete the content and the brackets of a level above while inside in the inner level
Accepted answer
4 votes

Delete a Block, delete a Block into a black hole register, Paste: daB"_daBP Almost what you want, cursor position would be different in the end. To fix indentation, do =aB For the second case, ...

View answer
1
2 3 4 5
10