Questions tagged [vimrc]

Vim reads initialization commands from a file called vimrc on startup. This can be used to set settings, define functions, execute autocommands, and more.

Filter by
Sorted by
Tagged with
0 votes
1 answer
21 views

How to set the mode from a vimscript?

If I save the result of :call mode() in a variable, how can I restore that mode later?
  • 1,931
-1 votes
1 answer
34 views

What is the meaning of command `:4w`?

As title. I just read a post that people accidentally delete(wipeout) their unsaved work by trying the command :4w. A bloody lesson to him, but I also want to prevent this from happening to myself. ...
  • 1,131
1 vote
1 answer
15 views

How to escape commas in au patterns and comma separated lists?

How do you specify a comma literal in the kinds of comma separated lists that are ubiquitous in vim configuration? The first example I can think of off the top of my head is in autocmds: au! BufRead,...
  • 1,931
1 vote
0 answers
24 views

How to manually implement autochdir?

'autochdir' 'acd' boolean (default off) global {not in Vi} {only available when compiled with it, use exists("+autochdir") to check} ...
  • 1,931
0 votes
1 answer
14 views

Toggle NERDTree in seperate window

I want to toggle vim in a whole new window and as I searched, I can open vim in new window using: :NERDTree | only So I set this in my vimrc: nnoremap <C-n> :NERDTreeToggle <bar> only<...
  • 3
0 votes
2 answers
32 views

Vim in Alacritty and inside tmux cannot display italic text

I am trying to have a better visualization while editing Markdown file in vim, I try to visualize the italic and bold text. However, I found the bold italic text work, while the italic itself doesn't ...
0 votes
0 answers
15 views

How to have placeholder text when Opening some filetypes

I would like to have a reminder of my mappings when I open say tex files. Idealy I would like something like the vim screen that shows vim version and stuff but I don't think that gonna be possible/...
1 vote
1 answer
45 views

Find git root directory in key mapping

I would like to find the git root directory and use it as argument for :FZF in a key mapping like this: nnoremap <Leader>eg :FZF `git rev-parse --show-toplevel`<CR> Unfortunately, this ...
  • 207
0 votes
2 answers
24 views

How to set all files under a folder to a specified filetype?

I have some zsh function files that I should not add extensions to for the convenience of calling, i.e. my_func instead of my_func.zsh. But this causes an issue that Neovim cannot detect their ...
  • 1,131
0 votes
0 answers
8 views

vim (8.2) "freezes" when :VimTexCompileSS is used (I need to write CTRL+C to make it work again)

I am using vim with vimtex, to use the background compilation. When I use the command :VimTexCompileSS, I am then unable to write anything on vim, unless I press CTRL+C to stop it. To click on the ...
0 votes
0 answers
33 views

Creating a local vimrc for a large LaTeX project with selective plugins, settings, and mappings

This is related to my previous question that you can find here: I am currently working on a large project (a PhD thesis with multiple chapters, each consisting of around 30 pages) and have found that ...
  • 213
-1 votes
0 answers
29 views

The key i to insert two double quotes at the current position is not working

On Vim, I try to record a key sequence macro to surround a selected text in double-quotes. First, I select a string of text and press key q followed by a register key to associate the macro, here I ...
1 vote
1 answer
116 views

When to use "set exrc" and local '.vimrc' in Vim, and how to manage plugins with multiple 'vimrc' files for large projects?

I'm using Vim for a project that has a lot of pages per chapter, and Vim is a little bit slow. I want to create a local '.vimrc' file for this project with only the plugins I need, and I'm trying to ...
  • 213
0 votes
1 answer
17 views

`Cmd+V`/`Ctrl+V` pasting has an extra new line

In init.vim I have: set clipboard^=unnamed,unnamedplus In order to ensure text is yanked into the system clipboard. In Neovim, I select the lines in line mode (V) and copy them with y: a b c In a ...
0 votes
1 answer
65 views

Is there a popular config for Neovim? [closed]

I found a lot of repositories in Github about init.vim like amix vimrc but I couldn't find anything about init.lua. Do you know some repository? I think many of people still using Vim.
1 vote
2 answers
116 views

Enable github copilot in Neovim for shell command editing

I use bash and like to use the built-in command Ctrl xCtrl e to invoke an editor in the shell in order to edit the current line. This creates a temporary file, named /tmp/bash-fc.[Some random ...
0 votes
1 answer
46 views

vim xterm-kitty problem

Using Vim with Kitty , the client area redraw doesn't work when I resize the window; in this context set term returns term=xterm-kitty. However, starting Vim with vim -T kitty the redrawing of the ...
0 votes
1 answer
22 views

Do I need to set `:filetype on` myself in Neovim?

As title. I'm a user of Neovim and am trying to learn something very basic. My point is that I don't want to set things that will be enabled by Vim by default. And what's the relation between :...
  • 1,131
1 vote
2 answers
121 views

Call original gf after remapping gf to custom function

gf doesn't work for absolute links used in Azure DevOps yaml files, p.e. - template: /devops/template/my-template.yml (It only works without the leading slash.) This is why I have created my custom ...
  • 207
0 votes
1 answer
15 views

Plugin specific config not loaded

I have in .vim/after/plugin/ a file called deoplete.vim Inside is this code let g:deoplete#enable_at_startup = 1 " Enable autocompletion at startup " Autocomplete Deoplete + Vimtex call ...
  • 213
1 vote
1 answer
47 views

How can we know if we can intall a plugin on both Vim and Neovim?

I find in noevimcraft a list of Neovim plugins Can we install them inside Vim or gVim? It seems that the plugins in vimawsome can be installed on Neovim but not always in Vim. Is that correct? How can ...
0 votes
1 answer
18 views

Having trouble understanding part of `'runtimepath'` documentation

I get the basics of the runtimepath as explained in :h 'runtimepath'. Except for the remark at the end for Neovim (nearly identical in Vim): You can put a directory before $VIMRUNTIME to find ...
0 votes
1 answer
37 views

How do I get coc.nvim to auto-open?

I installed Plug 'neoclide/coc.nvim', {'branch': 'release'} And now I seem to be able to use <C-n> and <C-p> to trigger autocomplete menu but it doesn't show up automatically as I type. I ...
  • 249
0 votes
2 answers
43 views

GNU Octave octave.vim syntax file auto indent not working

Before introducing the octave syntax file in ~/.config/nvim/syntax/octave.vim from here auto-indent worked as expected. After introducing the file, the syntax coloring works, but the auto-indentation ...
0 votes
1 answer
22 views

How to make auto-format portable?

I have these long lines, using Vim built in function to auto-indent programming files on saving file. How can I make this more compact ? Actually, I just want to exclude .txt files, because I don't ...
0 votes
1 answer
24 views

Invalid argument error with tab in listchars

I used list and listchars in vimrc file to display hidden characters but I get this error: E474: Invalid argument: listchars=tab:> after tab:> there is also a space. Below I have the complete ...
0 votes
0 answers
30 views

How to use the prefix key in tmux and Vim?

I am new to tmux. I have some configuration added to my tmux configuration file. I use Ctrl Space as prefix in tmux, and I want to use the same prefix key in Vim. But I find that Vim uses Ctrl Space ...
0 votes
1 answer
30 views

How to always open the `:h` as a split from the current window?

As title. Say I have A|B and already called :h foo on B then if I call :h bar on A it will not create a new split under A but change the content of the split from B instead. What I expect is that I ...
  • 1,131
0 votes
1 answer
36 views

How to map Vim command and CTRL-W R together?

Problem I am trying to map the F10 key with theterminal bash % command so I can execute the current open file with bash in a split pane setup (this functions works). The problem is when I try to add ...
  • 1
-1 votes
1 answer
81 views

What is the Vim shortcut on Mac to expand emmet snippet? [closed]

I am in newbie to Neovim. I have tried CMD Y but it is not working.
0 votes
2 answers
28 views

How can I use 'while' and 'if' in Vim script properly to turn off highlight automatically?

Consider: This is my code in Vim. As the code comment describes, I want to remove highlight when the cursor moved. Currently, I highlight will remove when entering insert mode, but it can still be ...
0 votes
2 answers
35 views

I am using Vim 7.4. I do not have admin privilege to update it. I want to use plugins as I cannot use plugin manager

I download Vim-plug but I am unable to use it. I have downloaded NERDTree in ~/.vim/pack/vendor/start/nerdtree. But when I give command :NERDTree in gVim editor it gives an error: Not an editor ...
0 votes
1 answer
33 views

Vim: mapping tab to ctrl space only if the cursor is in front of a non whitespace character

I am using the jedi-vim extension and really don't like pressing ctrl-space to bring up auto-complete. I would like to use tab, but also obviously when coding I need tab for indentation as well. I ...
  • 1
2 votes
1 answer
32 views

Get current vimscript script name and line number?

In C programming language, it's typical to log a message with filename and line number of the source code file the message is coming from: #define log(fmt, ...) printf("%s:%d: " fmt "\...
  • 213
0 votes
0 answers
20 views

Execute a command after successful EasyMotion's motion

I've EasyMotion plugin installed. I want to execute a command (G just for example) after a motion (note: the motion requires an user's input) is completed. In my ~/.vimrc I've tried to do it by ...
3 votes
3 answers
345 views

How can I create mappings to execute specific Vim commands, depending on if a makefile exists?

In general, I have makefiles setup anytime I'm working on C projects. To save and compile these projects, I've bound the ' key to do this: map ' :wa<CR>:!make<CR> However, I sometimes ...
1 vote
2 answers
52 views

why setting as autocmd

To display linenumbers, I can do: :set number in the edited file (that works) or insert set number in the .vimrc (that works too). To change the filetype, I can do: :set filetype=c in the ...
0 votes
0 answers
39 views

Coc Nvim automatically select all text between tags

I have mapped esc to < C-J> in .vimrc and whenever I try to go to normal mode after inserting some text inside any html tag using that mapping it selects all the character between that tag like ...
2 votes
1 answer
57 views

Cannot open terminal ini nvim

I installed Plugin terminal using the vim-terminal plugin and try to execute :TerminalSplit bash but before the terminal open I got a warning message. Python 2 interface is not installed, using Python ...
0 votes
1 answer
57 views

Changing the Vim backward search key from semicolon to period

I am trying to change the key used for going backwards in search results while using Vim. Currently, the key used is the semicolon (,), but this conflicts with another function in my config. I would ...
0 votes
1 answer
49 views

Statusline vs Rulerformat - What is the Difference?

Question What is the purpose of the ruler? I have recently learned about the statusline and the rulerformat, and was wondering what the difference between them is. Why does the ruler exist? Why can't ...
  • 172
1 vote
1 answer
25 views

Does `.rc` do anything in `after/plugin/foo.rc.vim`?

I see some people add a .rc. extention to files in after/plugin, is there any difference between: after/plugin/foo.vim after/plugin/foo.rc.vim ? Or: after/plugin/bar.lua after/plugin/bar.rc.lua ?
0 votes
1 answer
24 views

How can I set *.xsh filetypes as python?

I am trying to have set filetype=python automatically executed when I open a file ending in .xsh. However when I try it and then run the command set ft? it always shows me the file as xonsh. This is ...
1 vote
1 answer
145 views

`E492: Not an editor command` error only when opening file, but not when using :so %

I have the following in my vimrc: call plug#begin() Plug 'https://github.com/vim-scripts/RltvNmbr.vim' call plug#end() set number RltvNmbr When I type :so % while in my vimrc, it will turn on the ...
  • 21
1 vote
1 answer
22 views

Highlight a single word that would be encountered after a specific word

I want to highlight the next word encountered after a specific word (e.g.: "class"). In other terms, the next word after "class" should be highlighted with the highlight group that ...
0 votes
1 answer
43 views

Can I make a new mode in Nvim?

I want to create a new mode other than normal, visual, or insert because I want to: change the functions of all keys at once allow remapping preserve the mappings of other modes and retrieve when go ...
0 votes
0 answers
57 views

How to make `lead` override `trail` in listchars

I have the following lines in my .vimrc. set list set listchars=lead:·,trail:⎵ Whenever I have a line consisting of only spaces, the character shown is ⎵. How can I make vim prefer · in this scenario?...
  • 101
0 votes
1 answer
17 views

Rookie problem with Vim swaps

I am learning how to use Vim. I likely exited the editor by pressing Ctrl+Z which made it "crash". I now keep on having problems with swap files of .vimrc. Because of that, e. g., I cannot ...
  • 5
0 votes
1 answer
19 views

string substitution in statusline (change %F)

My current statusline (in .vimrc) contains %F to show the current filename. I want to perform a string substitution in %F. More specifically I want to substitute ~/remotes/foo -> [foo] Examples: ~/...
0 votes
1 answer
31 views

My key mapping appears when I run :map, but when I try to trigger it I get "E492: Not an editor command"

I am learning vim. I am at a part that I am very excited about because I think it will lead to a lot of productivity gains: key mapping. I added the following mapping to my .vimrc: let mapleader = &...

1
2 3 4 5
36