Skip to main content

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
27 views

Vim not setting t_Co after iTerm2 update

Follow up to this question - I've narrowed the issue down to the fact that set t_Co=16 in ~/.vimrc is not being applied. SO post on restricting vim to 16 colors. If I open vim and execute :echo &...
3 votes
1 answer
2k views

Vim to highlight functions and user-defined types

I have two scenarios where I want vim to highlight those items. Currently my fix for these are to add the return types directly into the after/syntax/c.vim file, but this gets incredibly tedious. Here ...
0 votes
2 answers
42 views

Homebrew Vim not sourcing ~/.vimrc after iTerm, MacOS updates

I am using vim installed via homebrew: > which vim /opt/homebrew/bin/vim > vim --version VIM - Vi IMproved 9.1 (2024 Jan 02, compiled May 09 2024 07:15:02) macOS version - arm64 Included ...
1 vote
2 answers
87 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 '...
1 vote
2 answers
132 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 ...
1 vote
1 answer
42 views

How do I start a search with the currently selected text?

What to add to init.lua such that / set the CLI with: / followed by the selected text if any / otherwise
2 votes
1 answer
1k views

Remapping Ctrl+backspace in insert mode to delete one word back

I want to bind Control+Backspace in insert mode to delete a word. I'm able to bind Control+Del in both insert and normal modes, but I can only seem to bind Control+Del in normal mode. I've checked ...
2 votes
1 answer
1k views

vim-airline tabs don't work. resetting airline theme when switching tabs

I faced an issue As you can see on the screenshot, vim does not show tabs with specified airline theme and it shows me this annoying X button at the end of the tabline. Here's my .vimrc: execute ...
5 votes
1 answer
866 views

How to use the value of a register in a key mapping?

I want to map a key to the system command `tmux set-buffer $var` where $var is the value of @0 register. How do i insert the @0 value into the map command map <leader>t :!tmux set-buffer @...
1 vote
1 answer
305 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&...
0 votes
1 answer
191 views

My Linux server doesn't have a .vimrc file but Vim has a lot of configurations

Not sure if this is the appropriate place to ask, but at work I use a laptop to SSH into a remote Linux server and do some work from there. I want to use the server's .vimrc file for my own laptop as ...
1 vote
1 answer
96 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 ...
1 vote
1 answer
2k views

Execute the contents of a register

Let's say I have the following text which I highlight: s/ /","/g And then I yank it into the a register: "ay How do I then run those commands? I thought doing @a would execute those commands, but ...
1 vote
1 answer
38 views

Suppress output of expression register?

Is it possible to suppress the output of a register? For example, I am using getchar() to 'consume' a character, but I don't need it to return anything. I suppose I could add in a hackish ternary ...
2 votes
1 answer
259 views

How can I show the + register in Airline?

I'm using the Airline plugin. How can I show the + register in Airline ?
0 votes
2 answers
2k views

Vim command to open zathura immediately after a latex compile?

I have the following line in my nvim configuration file: map <leader>c :w! \| !compiler <c-r>%<CR>\| !zathura $(echo %:r".pdf") && disown<CR><CR> The ...
0 votes
3 answers
742 views

Vim copy/paste from clipboard while keeping indentation

I am using Putty on Windows to connect to a Linux server. On the Linux server I am using Vim to edit code files. I am using my mouse to select an area to copy and then right click to paste the copied ...
0 votes
1 answer
19 views

Provide bash vars or at least develop ~ through let variable

To activate lsp I use this on my .vimrc: call plug#begin('~/.vim/plugged') Plug 'yegappan/lsp' call plug#end() let lspOpts = #{autoHighlightDiags: v:true} autocmd User LspSetup call LspOptionsSet(...
1 vote
1 answer
286 views

Vim go into insert mode when as a macro starts

When doing <ESC>qq you can record a macro into the q register (still in command mode though). How can I make <ESC>qq go into insert mode right away (without having to type i)? map qq qqi ...
1 vote
3 answers
151 views

Why `highlight X ...` from `.vimrc` does not work in gVim (but works in VIM) and I have to type it again during session?

For following snippet of code, to see what was highlighted I need to run :highlight LineHighlight ctermbg=darkgray guibg=drakgray after running vim session, and then rest of snippet works (i.e. loads ...
4 votes
2 answers
261 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 ...
3 votes
2 answers
275 views

Is there a way to insert documentation comments into a Vim macro definition?

I have found Vi / Vim macros extremely obtuse to understand even a week after I've written them. The syntax of a .vimrc file supports comments on lines beginning with a double-quote character (") ...
3 votes
3 answers
544 views

How do I swap key bindings without breaking plugins?

I'm thinking about exchanging some keys while in non insert-mode so that the bindings that I use most are easier to reach (i.e. on the home row). How can I swap two keys without breaking the ...
0 votes
0 answers
18 views

How to have Lexplore *really* toggle?

Starting with the fact that calling :Lexplore over an over works fine and it "toggles" on and off as most people would assume When I start B Vim by opening a directory, :Lexplore will show a ...
-1 votes
3 answers
133 views

Problem using the edit command in a function defined in vimrc

I am attempting to write a vim function that I would like to be loaded automatically when vim starts, thus I am putting it in my vimrc (but maybe that is wrong?). When called during normal editing, it ...
0 votes
2 answers
30 views

<c-n><c-p> start to scan tags in insert mode whereas I just want to complete with existing words in the buffer

I found this issue while editing my .vimrc. I tried to do the same in other files, such as .txt and .sh with no problems. While in insert mode, I use <c-p> for completing words that are in the ...
0 votes
1 answer
310 views

'autocmd OptionSet' - How to make it work?

The following .vimrc snippet is by Martin Tournoij's answer posted here: How do I stop the colorcolumn from breaking into multiple pieces when there are wrapped lines? augroup wrappedcc autocmd! ...
1 vote
1 answer
34 views

Is there an option for setting undo files' extension, similar to the one for backups?

For backup files, there's the option backupext for changing the extension of backups from filename.ext~ to (for example) filename.ext.bak by using set backupext=.bak in a vimrc file. Is there a ...
0 votes
1 answer
25 views

Disable a specific case provided by cindent when enter a colon `:`

As title. What I have currently after entering : after the std: std::memset(tempArr, 0, MAX_LEN_CASE*sizeof(int)); for (int i=0; i<MAX_LEN_CASE; ++i) { std: } What I expect is: std::memset(...
0 votes
1 answer
365 views

Go back to previous cursor position (column) on same line

When I execute a function in vim, it puts my cursor back on the line at column 1. Is there a way to get back to where my cursor previously was on that line, i.e., the exact column number? I thought ...
0 votes
0 answers
25 views

abbreviation stops expanding with "/"

The following problem with ab is seriously annoying me (seems to have started with vim 9.1): In my .vimrc, I have ab FF ftp://test.com/www. This will usually be expanded with e.g. / when I type the ...
3 votes
2 answers
204 views

Preload a named register?

Is there a way to preload a named register in vim? For example: I would like to have an empty comment always available in register "c". This way I could insert it and quickly add the text.
0 votes
1 answer
441 views

vim-surround not working properly in macro (ideavim)

vim-surround not working properly in macro: I want to change all li's <li><a href="/">home</a></li> <li><a href="/stuff">...
3 votes
1 answer
806 views

Why does terminal vim enter replace mode with my vimrc file? [duplicate]

I mostly use MacVim, but sometimes I'm in the terminal and use the CLI vim. I recently decided to clean up my vimrc file, retaining only what I knew I wanted. It works fine with MacVim, but when I ...
1 vote
1 answer
227 views

Silent mapping that automatically redraws -- no messages or blank screen

I would like to open a url in vim. Using gx from netrw has been problematic, so I created the following simple mapping: nnoremap <leader>k !open <C-R><C-F><CR> This gets the ...
6 votes
5 answers
6k views

Change $HOME before it gets accessed

I'm using vim 8.1 on windows. The IT department has set $HOME to a slow network drive. Every time a file gets written to $HOME vim slows down. I have $VIM/vimrc with the following content. let $HOME ...
0 votes
3 answers
155 views

How to jump to the last non-blank character in soft wrapped long line in vim?

I have those setting in .vimrc setlocal textwidth=0 wrap formatoptions=tc2n linebreak noremap <buffer> j gj noremap <buffer> k gk noremap <buffer> $ g$ noremap <buffer> ^ g^ ...
3 votes
2 answers
294 views

Prevent buffer loads within NERDTree

If I have many buffers opened and, if the cursor (focus) is within NERDTree, when I change the buffer with :bn or :bp, the content of buffer loads within NERDTree. There's a way to, before buffer ...
0 votes
1 answer
224 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 vote
2 answers
522 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
1 answer
624 views

Vim / Neovim PlantUML Preview didn't work

Environment macOS Ventura on M1 iTerm2 Homebrew Google Chrome I have tried to install a PlantUML-Preview in (Neo)Vim with this plantuml-previewer.vim plugin. There are described some dependencies: ...
0 votes
2 answers
50 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 ...
1 vote
1 answer
117 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 ...
0 votes
0 answers
35 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: "...
2 votes
3 answers
40 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 ...
1 vote
1 answer
1k views

Mapping doesn't work for tabs

I have several files opened in tabs in Vim. I want to switch between tabs, so I use Ctrl+left to move left (previous) and for next also. But my mapping doesn't work. :map <C-Left> :tabprevious&...
2 votes
1 answer
36 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 ~?
0 votes
1 answer
103 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?
9 votes
3 answers
5k views

Sending command to different tmux pane from vim

behave test language need to execute different lines of the behave feature file, for example, if I want to test the line number 99, I'll need to input the following line in the terminal behave ...
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-...

1
2 3 4 5
37