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
0 answers
32 views

How to fix a direction keys remapping bug?

I don't want to change the default position of my right hand to use the direction keys, also I'd like to be able to use them in the insert mode. So I've got the following part in my .vimrc file: "...
Fyodor's user avatar
  • 1
2 votes
3 answers
35 views

Setting variables in file in ftplugin directory

I am currently cleaning up my .vimrc. I learned that I can spread out filetype specific commands into separate files in the .vim/vimfiles directory by putting them into ftplugin and after/ftplugin ...
Matthias's user avatar
1 vote
1 answer
110 views

How do I Conditionally Execute an autocmd Based on the File Extension?

I have an autocmd which removes all trailing white space on write: The autocmd: autocmd BufWritePre * :%s/\s\+$//e For markdown files I need there to be trailing spaces. I'm looking for something ...
Nickotine's user avatar
  • 202
2 votes
1 answer
22 views

How do I prevent/remove/delete temp files?

When I create .txt files using Vim the following files are also created. How do I prevent/remove/auto-delete the files ending in ~?
javilan's user avatar
  • 23
0 votes
1 answer
38 views

Renumbering in Vim: g<C-A> won't work in vimscript function

I'm trying to use the feature g<C-A> in a vimscript function to renumber a visual selection-ed list, but it never does the renumbering. function! ReNumber() execute "normal! g$\<C-...
wxz's user avatar
  • 155
0 votes
2 answers
39 views

How to copy text to clipboard from status bar (statusline) in Vim

Problem is present when there is the following option for mouse in ~./vimrc: set mouse=a | " active
Anton Samokat's user avatar
0 votes
2 answers
40 views

Why does ":normal gv" keep removing one line from my visual block?

I'm trying to create a vimscript function that does a substitution on a visual block and then highlights the visual block again with gv. For instance: function! MySubstitution() s/foo/bar/ ...
wxz's user avatar
  • 155
0 votes
2 answers
39 views

How to enforce settings on debian Vim?

I have some settings in my debian (in /etc/vim/vimrc.local), which are overwritten by some plugins. Exactly which ones, at the moment is it hard to say, however I find it quite an annoying one. I ...
peterh's user avatar
  • 1,159
1 vote
1 answer
19 views

if endif oneliner failure in VIM

I followed QA_1. I use vim 9.1.0 instead of nvim which seems to also have the following bug and I have the following in foo.vim at line 67: if g:LOG_MSG==v:true | echow "g:mode_class " | ...
An5Drama's user avatar
  • 125
0 votes
2 answers
25 views

How to split terminal and start in the other buffer?

I currently have the following abbreviation: cnoreabbrev tright vert rightb terminal zsh With this, :tright in normal mode will open a terminal buffer on the right side of the screen, which is great. ...
Patrick O'Brien's user avatar
0 votes
1 answer
27 views

Using the return of a user defined function in an :execute statement

I am trying to get the output of the following function to an :execute statement such as I have this in my .vimrc def GetBufAbsPath(): string return substitute(expand("%:p"), '[^\/]\+$', ...
freddie_ventura's user avatar
0 votes
1 answer
19 views

mapping works on next line instead of current

I have this mapping in my .vimrc: inoremap <C-f> <Esc> : exec '.!printf "world"'<CR> I expected it to replace the current line with "world" after pressing C-f in ...
k-dx's user avatar
  • 3
0 votes
1 answer
25 views

Why is this showing everytime I try to open Neovim?

When I start Neovim I get the following error message: Error detected while processing /home/dell/.config/nvim/init.lua: E5113: Error while calling lua chunk: /home/dell/.config/nvim/lua/core/bootstra ...
Ankit Kumar Sahu's user avatar
0 votes
2 answers
38 views

Trying to display current mode leads to vimscript where variable is undefined inside function

I have following in my .vimrc set laststatus=2 set showcmd set wildmenu function! UpdateStatusline() let currentMode = mode() if currentMode ==# 'n' let currentMode = "Normal&...
Wakan Tanka's user avatar
1 vote
1 answer
38 views

Add new filetype syntax to markdown code fence [duplicate]

For work I use a certain SQL-like DSL. We'll call it lang. I write my docs in vim(wiki), and these docs contain a lot of lang snippets. I have written my simple syntax highlight rules for lang, and ...
Fedja's user avatar
  • 45
2 votes
2 answers
111 views

Neovim has wrong background setting

I'm having a trouble with Neovim colors when using my vimrc file as Neovim's init.vim. Here's the expected look, how it looks in Vim: And here is how it looks in Neovim: I guess that's because of ...
d.k's user avatar
  • 692
1 vote
1 answer
74 views

Start Vim window at a certain size?

Is there anything I can put in my _vimrc for gVim to make the window open a certain width/height?
leeand00's user avatar
  • 3,579
1 vote
3 answers
266 views

Order of sourcing scripts

I've recently been organizing my vimrc and putting mappings into vimfiles/plugin and vimfiles/ftplugin files (not to mention abbs, functions and commands). However, these scripts are sourced before ...
Tom's user avatar
  • 67
1 vote
1 answer
42 views

Running vim with custom vimrc does not load colorscheme

Inside my home dir I have 2 .vimrc files (.vimrc and .vimrc2). They both use the same coloscheme badwolf.vim. Location of colorscheme is ~/.vim/colors/badwolf.vim If I execute: vim everything looks ...
 MarieGosnell's user avatar
0 votes
1 answer
34 views

Is it possible to have the filename and cursor position displayed continuously -- WITHOUT using statusline?

Typing ^G gives "filename" 119 lines --17%-- 21,0-1 Top Setting statusline=%t\ %m%r%50l,%c%V\ %P gives e.g.: filename [+] 21, 0-...
colinh's user avatar
  • 33
1 vote
2 answers
59 views

How to display line number for visually wrapped lines?

I need to find a method to manage long lines in Vim that span multiple display lines as separate entities for navigation purposes. To elaborate, I use Vim with the 'relative numbers' feature, which ...
yegor's user avatar
  • 11
0 votes
2 answers
59 views

Clipboard Copy and paste remap

I'm working a lot with vim and have looked up the commands mapped below in the :help docs They don't appear to be in use. I'm using a Windows 10 os and running a centos VM. I want to map: clipboard ...
Lauro235's user avatar
  • 101
1 vote
1 answer
41 views

Not displaying symbols in vim-airline

My vim-airline has an unexpected ? symbol next to the program being run: I have tried manually setting the airline_symbols from here, for ex: let g:airline_left_sep = '>' and so on but this does ...
blackthorne18's user avatar
0 votes
1 answer
51 views

init.vim: E194: No alternate file name to substitute for '#'

I have a problem with adding a keymap to delete all my buffers. Namely, I used the following map in my init.vim file (source): nnoremap <leader>B :%bd|e#|bd#<CR> And I get the following ...
satk0's user avatar
  • 101
1 vote
1 answer
136 views

A map command not working correctly in Vim

imap command does not work for me as expected in Vim. I place inoremap <F2> abcde in my .vimrc file, but when I press the F2 button in the insert mode, all I get is the <F2> symbol ...
Maxim's user avatar
  • 113
1 vote
1 answer
86 views

Choices for pasting

In my local PC I use p in Vim command mode for pasting and it works fine and the :echo has('clipboard') returns 1. But, in the cluster I am working p in command mode, which just inserts a 0 instead of ...
Dimitris Tsiaousidis's user avatar
1 vote
1 answer
33 views

How to undo reversed changes after a while in insert mode?

I'm moving from Emacs to Neovim and still like a few things in Emacs functionality. One of the things I find I would like is to stay in insert mode when I'm typing large documents (instead of ...
user3236841's user avatar
1 vote
1 answer
78 views

Can't use "lua require" before call plug#end()

I'm using this minimal setup for easy repro: call plug#begin() Plug 'nvim-tree/nvim-tree.lua' lua require('nvim-tree-init') call plug#end() Running neovim results in this error upon opening of neovim:...
Fedja's user avatar
  • 45
1 vote
1 answer
237 views

How to search and replace the highlighted text from visual mode?

The following is the functionality I am attempting to implement. 1. What works (normal mode): Search/highlight the word the cursor is on. Replace the word the cursor is on. Note that the word doesn'...
Vladimir's user avatar
1 vote
2 answers
93 views

How can I extend syntax highlighting with my own keywords?

I already have syntax highlighting for javascript, but what I'd like to do is extend it with some additional rules. What I've been trying to start, is using highlight "Prototype" with a cyan ...
Sophie McCarrell's user avatar
0 votes
0 answers
56 views

Why is key binding for CTRL-L key messed up?

I have run into a Vim key binding issue at the office recently. On the Linux system where I do my development work, while running Vim the CTRL-L key no longer redraws the screen. The .exrc file in my ...
Barry Kimelman's user avatar
0 votes
1 answer
34 views

Is there an efficient way to delete the duplicated block with same start and end to keep unique?

Description I have many large size files may including the same function definition. The block description is start with .start .* and end with .end In this example there is one duplicate definition ....
M_Sea's user avatar
  • 157
1 vote
1 answer
108 views

Is user vimfiles/after/ftplugin supposed to be after system/indent?

Should user vimfiles/after/ftplugin scripts loaded after any system script?
Konstantin Glukhov's user avatar
1 vote
1 answer
56 views

How to save the files when global replace completed in one command line

I have so many huge size of files and always need to do search and replacement so I map the command as nnoremap aa :let i=1 \| g/regexp/ s/^/\=printf("%1d. ",i)/g \|let i =i+1\|:w! 1.txt ...
M_Sea's user avatar
  • 157
3 votes
2 answers
558 views

How do I undo the result of the remap of ( to ()?

If my vimrc file has the following: inoremap ( ()<Left> which essentially auto-closes a (, changing it to () whenever I type ( in insert mode. How do I undo the change when I don't want that ...
siralbert's user avatar
2 votes
2 answers
176 views

Additional filetypes for different types of yaml files

Is it possible to create additional subcategories of filetypes? For example, it would be great if (neo)vim could pick up that the yaml file I'm editing is acutally a Kubernetes yaml file and set the ...
moo's user avatar
  • 155
0 votes
2 answers
63 views

Change what Vim does by default when no files are given

When running vim with no command line arguments, it opens a splash screen describing Vim. I would like to control what vim does "by default", so I can make it do something more useful like ...
Greg Nisbet's user avatar
  • 1,849
1 vote
2 answers
68 views

Conversion in Lua: how to tabdo all the visible buffers without changing view of the current tab?

Related to this post, how to tabdo all the visible buffers without changing view of the current tab? function! TabLcd() let current_tab = tabpagenr() tabdo <commands> execute '...
Mega Bang's user avatar
  • 199
0 votes
1 answer
67 views

Calling variables from SHELL and using them in Vim config (vimrc) [closed]

Question I am trying to use variables from SHELL inside my Vim configuration file, now, I have researched how to do this and asked ChatGPT about how as well. It is possibly due to the specific ...
Ella H's user avatar
  • 13
1 vote
1 answer
46 views

How can I use Regex in helpgrep?

I would like to use Regex in helpgrep. For example, searching for lines or sections that contain two words. Something like :helpg 'word1' & 'word4' to find this line as my result: word1 word2 ...
mohamadi_arch's user avatar
0 votes
1 answer
102 views

When I use helpgrep, how can I highlight my search results?

I'm using :helpg session in my Vim. I would like to highlight the pattern in the results like :set hls does for normal search. Is there a way to do this?
mohamadi_arch's user avatar
1 vote
1 answer
159 views

Why so % does not work when vimrc changes with another editor?

I opened a file in Vim. Then opened vimrc file with another editor (VsCode) and made some changes. I would like those changes to be reflected in my Vim session. I tried :so % but it didn't work ...
mohamadi_arch's user avatar
0 votes
2 answers
77 views

Why doesn't echo % do anything in command mode?

I read the section of current-file in the document. (see :h current-file) And I have a question. if % stands for the current file name, why I can not use echo %?
mohamadi_arch's user avatar
1 vote
1 answer
93 views

What is the meaning of lbr in Vim?

I write set lbr in my vimrc file but I don't know the meaning of that. What does this option do? I know it's about line-breaking but I need more explanation. This is from the Vim document and I can ...
mohamadi_arch's user avatar
1 vote
1 answer
125 views

What is the difference between `au BufNewFile,BufRead *.py` and `au Filetype python` in this specific case?

The issue Consider the following two Vimrc configuration lines for the YouCompleteMe plugin: au BufRead, BufNewFile *.py,*.pyw match BadWhitespace /\s\+$/ au FileType python match BadWhitespace /\s\+$...
Attilio's user avatar
  • 369
1 vote
1 answer
71 views

Whitespace character which is not the usual 'space'

I came across this character which looks like the usual space character but it is not identified with the usual highlight search '/' in Vim. For context, I added a space at the very last line to show ...
Stephen Jacob's user avatar
0 votes
0 answers
26 views

Replacing text in non selected lines

I have \begin{thm} in a lot of my .tex files. Whenever I am not in the selected line I would like this to be rendered as Theorem. I have tried using conceal but it is limited to rendering a single ...
Maths Wizzard's user avatar
1 vote
1 answer
211 views

Error when using vim-plug from git-bash

I just installed vim-plug to use the doxygen plugin. Added call plug#begin() Plug 'vim-scripts/DoxygenToolkit.vim' call plug#end() to the .vimrc (_vimrc because Win10..). Using the doxygen plugin ...
Max's user avatar
  • 113
0 votes
1 answer
25 views

Convert sequence of external commands to a Vim custom command

To reformat Markdown tables, I use the following sequence of external commands (e.g. after visually selecting my table lines): :<,>! sed 's/[[:space:]]\{1,\}\|/\#\|/g' :<,>! column -t -s '\...
gjherbiet's user avatar
0 votes
1 answer
119 views

MacOS - Vim overriding my highlight config in ~/.vimrc

~/.vimrc: set backspace=2 set nocompatible set clipboard^=unnamed,unnamedplus syntax on set expandtab tabstop=2 shiftwidth=2 set smartindent set hlsearch set incsearch set ignorecase set number ...
ray's user avatar
  • 1

1
2 3 4 5
37