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
1 vote
0 answers
115 views

error: there was a problem with the editor "vi" -- while trying to change deployment file

Facing this error error: there was a problem with the editor "vi" when trying to change a deployment file in the Kubernetes cluster (AKS) kubectl edit deploy xxxxx -o yaml upon exiting the ...
user avatar
-1 votes
1 answer
58 views

Problem setting cursor colors in vimrc: suppress the `-ne` that is written to my xterm on exit

Following the vim manual and also some threads on this site, I can set the color of my cursor to orange in insert mode and red otherwise, with the following lines in my .vimrc file. " use an ...
user avatar
  • 645
0 votes
1 answer
206 views

Typescript add missing import on cursor?

I'm working on a TypeScript-React project using neovim, because I love it. I want a feature: when my cursor is on a name that has not been imported, I can press some key-combination to choose which ...
user avatar
  • 771
0 votes
0 answers
107 views

Mouse navigation not working in VIM

I started using VIM today and I found out that we could use the mouse pointer to go to a line in vim using set mouse=a But unfortunately, it is not working here is the config file https://pastebin.com/...
user avatar
0 votes
1 answer
71 views

Automatically launch debugging session if make succeeds, quickfix list otherwise

Currently, I have begun using vim for C++ projects. I use vimspector for debugging help. This offers a command :call vimspector#Launch() to debug the current successful build. To build the current ...
user avatar
  • 165
0 votes
1 answer
68 views

Trouble with persistence of background setting via vimrc

I have a structure thus: myproject/ .vim/ .vimrc Contents of .vimrc are: let g:usercolour = 0 if g:usercolour == 0 set background=dark colorscheme default endif if g:usercolour == 1 set ...
user avatar
  • 165
0 votes
1 answer
53 views

Using a vim syntax file, I would like some Keywords, such as ??, to be colored

I have been trying to get through the syntax file documentation on vim help, https://vimhelp.org/syntax.txt.html#%3Asyn-files but it's quite the read and I figured someone here may know how to go ...
user avatar
  • 1
0 votes
1 answer
49 views

Is there a way to have specific settings activated when using the term feature?

I often have neovim in a horizontal split mode with two buffers. The top buffer is the text file that I'm editing, and the bottom buffer is running a terminal using the term feature. I typically use ...
user avatar
  • 103
-1 votes
1 answer
53 views

Why are so many underscore lines in my file when to open it with vim?

Everytime i opened a file with vim,so many underscore lines in it such as below: How can remove all the underscore lines ? :colorsheme is desert. The highlight output: The terminal is LXTerminal. ...
user avatar
  • 860
1 vote
1 answer
48 views

To toggle statusline colors when switching modes. Problem with C-C

I use the following code to have different statusline colors for Normal and Insert modes: highlight statusLine ctermfg=black ctermbg=red guifg=red guibg=black autocmd ...
user avatar
2 votes
1 answer
86 views

Making Vim work with Unicode: what is the reason to use "setglobal fileencoding=utf-8"?

There is a tip on Vim Wiki about working with Unicode: if has("multi_byte") if &encoding !~? '^u' if &termencoding == "" let &termencoding = &encoding ...
user avatar
  • 203
0 votes
1 answer
85 views

Difference between %f and %F (it's not that obvious!)

This might be a silly question, but what is the actual difference between %f and %F in status line? From :h statusline: f Path to the file in the buffer, as typed or relative to current directory. F ...
user avatar
3 votes
1 answer
157 views

What is the reason to specify ':cANSI' (or another character set) for a font

I often see that fonts intended to be used on Windows are defined with :cANSI. set guifont=Consolas:h11:cANSI The help is, of course, provide some explanation, but I don't really understand it. cXX -...
user avatar
  • 203
1 vote
1 answer
106 views

How to get timezone using strftime command?

I have a custom command for stamping time in my log files. However, I would like that format to match the one of bash command date. For example, I use this command: :command InLog pu=strftime(\"\...
user avatar
  • 135
2 votes
2 answers
81 views

choose template option for newfiles in vim

I have different templates in this directory ~/Documents/Library/ like: Template.cpp, normal.cpp, advanced.cpp normally i use this autocmd BufNewFile *.cpp 0r ~/Documents/Library/Template.cpp I want ...
user avatar
  • 121
1 vote
2 answers
70 views

jedi-vim prevents mapping [[ to * and ]] to #

jedi-vim appears to prevent mapping [[ to # and ]] to * mapping does not alter behaviour produced by [[ or ]] in .py files when jedi-vim in bundle folder (and does alter behaviour in .py files ...
user avatar
0 votes
1 answer
53 views

Can you have relative numbers, but for characters/words in a line?

This is relativenumber. It shows the line numbers, relative to your cursor: 1 one line before your cursor 0 your cursor is here 1 first line after 2 second line 3 third line 4 and so on It's super ...
user avatar
2 votes
1 answer
799 views

How can I detect the encoding of a file correctly?

Sometimes I download files in cp1251, cp866, and koi8r encodings, all of which are used to represent Cyrillic characters. How should I specify them in set fileencodings=... so that when I open such a ...
user avatar
  • 203
3 votes
1 answer
3k views

How does smarttab actually works?

Yes, I'm aware of what :h smarttab says, but I still cannot figure it out. " My vimrc set backspace=indent,eol,start set tabstop=8 " I always keep this 8 set shiftwidth=4 set softtabstop=-1 &...
user avatar
  • 89
0 votes
2 answers
120 views

To reload vimrc on file save

I'm trying to make Vim reload its vimrc when I save a file. I have found different solutions, but none of them works for me for some reason. Vim version: 8.2.2824, OS: Windows 7. My vimrc: " I ...
user avatar
  • 203
0 votes
1 answer
42 views

How can I create a command alias for :Ex /path/to/directory

I'm trying to make my life easier by making a shortcut for the following command :Ex /path/to/directory I need to to be able to press :akeyword and execute the command above. The directory needs to ...
user avatar
  • 3
0 votes
2 answers
43 views

how to make a word turn into certain commands in vim command line?

I want :cup in vim command line to turn into :tabdo call MapRunCmd()<CR> Hope that somebody can help me out PS: I've tried this nnoremap :cup :tabdo call MapRunCmd()<CR> but didn't like ...
user avatar
  • 121
0 votes
1 answer
68 views

How to escape a pipe (|) in my vimrc

I've seen How to escape pipe character in `:make`, `:grep` and friends How to escape pipe (|) in mapped substitution? https://stackoverflow.com/questions/29596150/use-to-diplay-tabs-in-vim But none ...
user avatar
1 vote
1 answer
70 views

Run `vim -c <command>` before loading vimrc?

I'm adding some setup to my .vimrc, and what I want to do is to be able to run a command using the command line before the vimrc is executed. I tried vim -c 'command' but it runs after the .vimrc. The ...
user avatar
1 vote
2 answers
101 views

inserting non-printables in vi

After a near-crash, the assistence has installed LINUX 20.4 instead of 16.04. When in vi I try to insert a ^C using ^V^C I insert [27;5;99~ Is someone able to tell me which initialization file ...
user avatar
0 votes
1 answer
48 views

Need help to make a by-default `:RunWithFile` of this toggle function

related to this post, How to make a toggle function in .vimrc that toggles multiple configs of almost same type? @BLayer's code func! MapRunCmd() abort if exists("b:rwfcmd1") && ...
user avatar
  • 121
18 votes
2 answers
4k views

Vim cannot find medical spell files

Problem specification I would love to have a medical spell dictionary in vim. Currently, I have a lot of medical terms in my own personal English dictionary right now. However, using an official ...
user avatar
  • 567
0 votes
2 answers
61 views

How to move `n` number char <left> in vim command line?

My init.vim code autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt I want my cursor position to be exact 31 times <left> in command ...
user avatar
  • 121
1 vote
1 answer
363 views

How does "set mouse=a" actually work?

Could somebody explain, what is the reason to use set mouse=a? People say that thus I will be able, for example, to resize split windows (:sp, :vsp) by dragging separators, but I already can do it if ...
user avatar
  • 203
1 vote
1 answer
51 views

Is there a reason to include "set ruler" and "syntax on" in my vimrc?

Could somebody explain, why some people add set ruler syntax on to their vimrcs? Aren't these settings are already enabled by default? Is there an objective reason for it?
user avatar
  • 203
0 votes
1 answer
140 views

Youcompleteme: shortcut key to format selection

According to this documentation :'<,'>YcmCompleter Format will format the selected text. I am struggling to map this to shortcut key <S-F2>. I have tried all of the following after having ...
user avatar
  • 165
0 votes
1 answer
48 views

Why vim creates an extra last line when importing a template?

My init.vim code: autocmd BufNewFile *.cpp 0r C:\Users\User\Desktop\cp\Template.cpp When i create a .cpp file, Template.cpp code is imported in that cpp file. upto this point, everything is fine. ...
user avatar
  • 121
0 votes
0 answers
52 views

Difficulty mapping normal key strokes into .vimrc

I am trying to create a shortcut key that does the following steps in normal mode: Go to stack trace window Go to second line from top in this window Press Enter In step 2, the second line from top ...
user avatar
  • 165
0 votes
1 answer
140 views

Line continuation and commenting out

This is a part in my .vimrc that is used to change appearance of tabs to → (arrow right) and spaces to · (dot). set list set listchars= \tab:→\ , \space:·, \nbsp:·, \extends:›, \precedes:‹ ...
user avatar
  • 203
0 votes
2 answers
74 views

project-based config: how to load plugins/colors from custom subdir of $PWD when doing `vim -u local/vimrc ...`?

The Need, the Goal... By "project-based config" I mean a project contained in a git repo that contains all the vim configuration -- vimrc and plugins and colorschemes -- right there in the ...
user avatar
  • 705
0 votes
1 answer
207 views

how to deduplicate packpath / runtimepath?

Problem: I noticed that my "&packpath" has some duplicates, I want to remove them. What I have tried: My viml knowledge is not very strong but I did manage to create a unique "List&...
user avatar
  • 23
0 votes
1 answer
41 views

How do I make the statusline selectable in gvim/macvim?

With terminal vim I can just double click the statusline and select the filename, which is very handy. In gvim or macvim clicking the statusline prompts me to resize the active window, not very useful....
user avatar
  • 103
1 vote
0 answers
35 views

How to suppress "file written" shortmess?

Upon saving a file, vim shows a message like, "file" [New] 0L, 0C written I want to suppress this message. I have tried adding shortmess+=FW to my ~/.vimrc but it doesn't seem to work.
user avatar
1 vote
1 answer
116 views

Setting 'viewdir' does not work with :mkview

I'm trying to use :mkview with 'viewdir'. I set 'viewdir' as the help page said: set viewdir='C:/Users/MyPC/vimfiles/view' and made sure that C:/Users/MyPc/vimfiles/view exists, but I still get error ...
user avatar
3 votes
2 answers
360 views

Call plugin-defined function in .vimrc

I use tpope/vim-fugitive and airblade/vim-gitgutter and I want to selectively enable gitgutter only in git repositories. Since vim-fugitive provides FugitiveIsGitDir which returns 0 or 1, this could ...
user avatar
0 votes
1 answer
40 views

Root using symlink for .vim. Vim configuration of other user not inherited as expected!

I have customized my Vim environment under my "login" ID ${HOME}. Everything is under ~login_ID/.vim (no customizations under ~login_ID/.gvim). I have created a symbolic link /root/.vim ...
user avatar
  • 3
0 votes
1 answer
42 views

How to get: "Warning: You set a onFileEdit warning for this file, and now you are attempting to modify it. Enable edits for the next N minutes?"

How do I set up Vim to achieve the effect in the title?
user avatar
2 votes
2 answers
160 views

Vim 8.2 no user defined functions

Yesterday I updated Vim to version 8.2 thru my Linux distro repositories (Fedora). And now I noticed that no user defined functions exist. They worked just yesterday, before the update. I define ...
user avatar
0 votes
2 answers
156 views

Why does an empty vimrc file change my configuration (e.g. disable syntax highlighting)?

Here is the sshconfig syntax highlighting when i do not have any .vimrc file: Let's create an empty .virmc : $touch ~/.vimrc Now let's edit that same file again: Why is this happening? I'd like to ...
user avatar
1 vote
1 answer
105 views

How to copy contents of wl-clipboard into a Vim register?

I would like to swap content between my system clipboard and a Vim register. I am missing one last piece of the puzzle, indicated below. Any thoughts? map <Leader>" :call SwapBuffer()<CR&...
user avatar
2 votes
1 answer
95 views

How to quickly search for today's date in a file?

Question How does one effectively find today's date in a file? The format of the date is given by GNU's date(1)'s command as: $ date '+%a %d-%m-%Y' Mon 16-08-2021 What I already tried This is how I ...
user avatar
  • 567
0 votes
1 answer
81 views

How to map <BS> to do nothing?

(I'm using Alacritty + NeoVim, I'm not sure about whether this issue is from Alacritty or NeoVim.) I want to map <BS> in insert mode to do nothing, i.e. <Nop>. I have tried: inoremap <...
user avatar
  • 771
0 votes
0 answers
66 views

How to keybind vim to a shell script

I'm new to vim and apologize if the question seems redundant, but I couldn't find a suitable answer. I have a shell script compile.sh that I would like to run each time I press some key (say, F8) on ...
user avatar
  • 1
1 vote
1 answer
786 views

Configuring coc.nvim coc-solargraph with standardrb for RSpec files

I am trying to configure coc.nvim for my vim 8.2. I mapped my formatting to leader-d with: nnoremap <Leader>d :call CocAction('format') <CR> which works fine for ruby filetype. However, ...
user avatar
  • 121
1 vote
1 answer
49 views

How I can add <C-6> to a mapping

I am trying to create a mapping that will close the current buffer and replaced by the previous buffer. I tried this noremap <silent><Leader>bd :<C-6><Bar>bd #<CR> But ...
user avatar
  • 149

1 2 3
4
5
34