Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
1
votes
1
answers
2431
views
How to remap CapsLock to Esc in Vim, installed on Ubuntu (console only, no Desktop Environment)?
**The goal is to remap CapsLock to Esc in Vim, installed on Ubuntu** (console only, no Desktop Environment). This Ubuntu system is installed on Virtual Private Server. I'm logging to this server using Putty, from my home laptop with Windows 10. And everybody are talking about mapping this CapsLock k...
**The goal is to remap CapsLock to Esc in Vim, installed on Ubuntu** (console only, no Desktop Environment).
This Ubuntu system is installed on Virtual Private Server.
I'm logging to this server using Putty, from my home laptop with Windows 10.
And everybody are talking about mapping this CapsLock key to Esc in Vim, but I was unable to find actual line, that needs 2 be written in $HOME/.vimrc file.
This is what I've tried myself, but none of this works, except for the first line adding row numbers:
set number
inoremap
inoremap
inoremap
The goal is to remap CapsLock to Esc only in Vim, not the whole Ubuntu server.
I've checked and CapsLock works fine in Vim, and makes UpperCase when locked.
I've searched so many places like:
https://vim.fandom.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_1)
all 3 parts of this guide and here as well.
Like everything is written there: mapping "ii", "jj", "jk", "jw" different Ctrl and Shift combinations.
Everything except CapsLock to Esc remap.
??? Why ???
Why is it so hard to remap CapsLock to Esc in Vim?
It's almost my question, but unfortunately on Windows OS.
From the comments below my question I gather that mapping CapsLock to Esc is impossible in Vim alone.
I've also read this thread: https://unix.stackexchange.com/questions/165477/how-to-use-capslock-instead-of-escape-in-vim
And the answer that's accepted states: "For remapping in the console, if your distro uses systemd
, you can use a custom keyboard layout in /etc/vconsole.conf
as described on the Arch Wiki ."
I guess Ubuntu uses systemd
, **so I'm ready to accept the answer that's going to map CapsLock to Esc key in whole Ubuntu installed on my VPS,** providing my home, Windows machine key mappings, remain unchanged.
I've run this:
michal@localhost:~$ localectl status
System Locale: LANG=en_US.UTF-8
VC Keymap: n/a
X11 Layout: us
X11 Model: pc105
**What should I do next?**
I think I don't have this file /etc/vconsole.conf
on my Ubuntu VPS.
Should I create it myself, or should it be there by default?
michal roesler
(289 rep)
Oct 10, 2021, 12:13 PM
• Last activity: Jul 7, 2025, 09:05 AM
3
votes
2
answers
3287
views
gvim colors the same as is the terminal
Is there a command I can put in the `.vimrc` to make gvim look like vim's setup in the terminal? Same back ground, syntax highlighting, colors, and font. To add to my question, is there a may for gvim to follow vim's vimrc? That is, there layouts and actions are identical?
Is there a command I can put in the
.vimrc
to make gvim look like vim's setup in the terminal?
Same back ground, syntax highlighting, colors, and font.
To add to my question, is there a may for gvim to follow vim's vimrc? That is, there layouts and actions are identical?
dustin
(392 rep)
Apr 8, 2013, 02:56 AM
• Last activity: Jul 3, 2025, 09:02 PM
0
votes
1
answers
47
views
Changing font in my Vim text editor on Arch Linux? (DWM/X11)
I need your help! I am trying to set up a specific font and font size in my ```~/.vimrc``` file using ```set guifont=Monospace:h15```, but nothing is changing no matter if I put 12 or 20 in the size column. I've tried several fonts also, but it seems like changes just not apply - after writing the f...
I need your help! I am trying to set up a specific font and font size in my
~/.vimrc
file using guifont=Monospace:h15
, but nothing is changing no matter if I put 12 or 20 in the size column. I've tried several fonts also, but it seems like changes just not apply - after writing the file and reopening it, size of the font and the font itself stays the same. Also :set guifont=*
command doesn't show me anything. Here is my .vimrc
file:
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'nyngwang/nvimgelion'
syntax on
set termguicolors
set guifont=Monospace:h20
call vundle#end()
filetype plugin indent on
au BufNewFile, BufRead *.py
\ set tabstop=4
\ set softtabstop=4
\ set shiftwidth=4
\ set expandtab
\ set autoindent
\ set fileformat=unix
set laststatus=2
set wrap
set encoding=utf-8
vnoremap :w !xclip -i -sel c
How to set up a specific font in my Vim configuration file? Thank you for your help.
Alex
(3 rep)
Jun 9, 2025, 07:20 PM
• Last activity: Jun 10, 2025, 06:07 AM
1
votes
1
answers
1957
views
expand tab is not working on vim
I set the `expandtab` option to on, but still I don't get spaces when I click tab, but I get actual tab. This is how I set it: set expandtab set shiftwidth=4 set softtabstop=4 First I thought as [this question][1] says that a plugin is override it, but I executed: :verbose set expandtab? and indeed...
I set the
expandtab
option to on, but still I don't get spaces when I click tab, but I get actual tab.
This is how I set it:
set expandtab
set shiftwidth=4
set softtabstop=4
First I thought as this question says that a plugin is override it, but I executed:
:verbose set expandtab?
and indeed I get that last set is the line in my vimrc
how can I solve it?
Jack Thomson
(491 rep)
Jun 8, 2019, 01:56 PM
• Last activity: Jun 1, 2025, 10:07 PM
2
votes
1
answers
2127
views
Vim FoldColumn color different on Debian / Ubuntu
I sync my [.vimrc file](https://raw.githubusercontent.com/denten/.dotfiles/master/.vimrc) between two machines, one running Debian testing and the other Ubuntu. On Debian everything works fine. On Ubuntu, the fold column is gray instead of black, even though black is specified: ```213: hi FoldColumn...
I sync my [.vimrc file](https://raw.githubusercontent.com/denten/.dotfiles/master/.vimrc) between two machines, one running Debian testing and the other Ubuntu. On Debian everything works fine.
On Ubuntu, the fold column is gray instead of black, even though black is specified:
: hi FoldColumn ctermbg=Black ctermfg=Black
If I comment out line 213, the fold column turns black, but then foldmarkers default to white (the whole point is to hide them black on black). If i just do:
: hi FoldColumn ctermfg=Black
The FoldColumn is gray again. I do not find plugin conflicts with -r "FoldColumn" .vim/
. Any ideas?
denten
(400 rep)
Jul 31, 2014, 02:24 PM
• Last activity: May 8, 2025, 06:03 PM
0
votes
1
answers
36
views
Vim: How to Shift Screen Horizontally by One Character Column (Similar to Ctrl + E for Vertical Scrolling)
I'm currently using Vim and I'm looking for a way to shift the screen horizontally by one character column at a time, similar to how Ctrl + E shifts the screen up vertically by one row.
I'm currently using Vim and I'm looking for a way to shift the screen horizontally by one character column at a time, similar to how Ctrl + E shifts the screen up vertically by one row.
wasabi_nuts
(1 rep)
Apr 23, 2025, 05:05 PM
• Last activity: Apr 23, 2025, 05:15 PM
-4
votes
1
answers
217
views
New / different VIM for Debian?
On both my new Debian and Raspberry Pi: VIM version 9.0.1499 This vim is quite different and irksome to a user of the version that's been "standard issue" on Fedora for over a decade now. The current version I'm using is: version 9.0.1872 The biggest issue is insert mode. I'm used to just cursoring...
On both my new Debian and Raspberry Pi: VIM version 9.0.1499
This vim is quite different and irksome to a user of the version that's been "standard issue" on Fedora for over a decade now. The current version I'm using is: version 9.0.1872
The biggest issue is insert mode. I'm used to just cursoring where I want to go and continuing on. But in this version doing that just creates a lot of stuff (surely they're improperly interpreted escape characters that represent the cursor keys I'm typing) that has to then be deleted after, of course, escaping out of it and start a new insert. It's a HUGE time sink. ... There are likely other less obvious differences I haven't tripped over yet - I'm a newbie to both Debian and R. Pi.
Moving over my personal .vimrc hasn't helped.
It COULD be just a .vimrc issue - I'm ignorant about what impact that might have.
So, I'm unsure how to proceed. ... nano just doesn't do it for me, too slow! I guess it's like anything else; familiarity!
So... New version? Different vimrc contents? If so what cures this insert problem? I presume it's new-version time, but if so, what version?
Richard T
(268 rep)
Oct 6, 2024, 04:29 PM
• Last activity: Oct 18, 2024, 09:06 PM
1
votes
1
answers
138
views
Vim highlighting problems with large files
If I open a large file (using that term generously, like ~1000 lines is enough) in vim, and jump somewhere, I sometimes get highlighting that ignores text off screen. For example, if I jump to the end of a large while loop (in sh highlighting, but I have had the same type of problem with C highlight...
If I open a large file (using that term generously, like ~1000 lines is enough) in vim, and jump somewhere, I sometimes get highlighting that ignores text off screen. For example, if I jump to the end of a large while loop (in sh highlighting, but I have had the same type of problem with C highlighting), the "done" will be marked red as if it does not actually terminate a loop. It is like the program is not looking far enough back to properly contextualize what I am currently looking at. On the other hand, if I go to the start of the loop and 'j' my way down, it will properly highlight. Is there any way to fix this?
Kyle
(687 rep)
Sep 25, 2024, 05:08 PM
• Last activity: Sep 26, 2024, 01:38 AM
34
votes
4
answers
23571
views
How to automatically strip trailing spaces on save in Vi and Vim?
Is there a `.vimrc` setting to automatically remove trailing whitespace when saving a file? Ideally (to be safe) I would like to only have this functionality for certain files, e.g. `*.rb`
Is there a
.vimrc
setting to automatically remove trailing whitespace when saving a file?
Ideally (to be safe) I would like to only have this functionality for certain files, e.g. *.rb
Michael Durrant
(43563 rep)
May 11, 2013, 12:50 PM
• Last activity: Aug 24, 2024, 05:43 PM
1
votes
0
answers
71
views
Backspace on vim doesn't work after I create a ~/.vimrc file
I'm using `vim` on macOS, I did different tests.  Backspace doesn't work in `vim` with my `~/.vimrc`. I saw that when I remove my `~/.vimrc` file everything is ok, but whatever I write in it (any writable character or a `set nu` or anything.  When I `:wq` and come back to anyfile with `vim...
I'm using
vim
on macOS, I did different tests.
Backspace doesn't work in vim
with my ~/.vimrc
.
I saw that when I remove my ~/.vimrc
file everything is ok, but whatever I write in it (any writable character or a set nu
or anything. When I :wq
and come back to anyfile with vim
, I cannot use backspace anymore.
I tried to brew uninstall vim
and reinstall it many times,
and it doesn't change this behaviour.
Without ~/.vimrc
file, everything's perfect,
but with my ~/.vimrc
it doesn't behave as expected.
raphael levillain
(11 rep)
Aug 19, 2024, 05:52 PM
• Last activity: Aug 19, 2024, 08:24 PM
43
votes
4
answers
40002
views
Opening a vertical terminal in Vim 8.1
Vim 8.1 added the `:terminal` command, which opens up a new bash terminal as a split. However, it always seems to be a horizontal split, and I prefer vertical splits. Is there a way to open a terminal as a vertical split without using: :vsp :terminal j :q Alternatively, is there a way I could add it...
Vim 8.1 added the
:terminal
command, which opens up a new bash terminal as a split. However, it always seems to be a horizontal split, and I prefer vertical splits. Is there a way to open a terminal as a vertical split without using:
:vsp
:terminal
j
:q
Alternatively, is there a way I could add it as a command in my *.vimrc*, like so:
command Vterm :vsp | :terminal | j | :q
The command above chokes on trying to execute j
, opens a new vim split with the following:
> executing job failed: No such file or directory
Just having:
command Vterm :vsp | :terminal
Works fine, but leaves the original split.
Schiem
(533 rep)
May 18, 2018, 06:49 PM
• Last activity: Apr 26, 2024, 04:48 PM
4
votes
2
answers
6812
views
Why does 'set' syntax not work for syntax highlighting in vim?
On searching how to set syntax highlighting on in vim, I found [this page][1] which says that vimrc should have the following line syntax on **Why is it not something like `set syntax on`?** Like we have `set nu`, `set ai` etc. With `set syntax on`, I get this error $ vi syntax= Error detected while...
On searching how to set syntax highlighting on in vim, I found this page which says that vimrc should have the following line
syntax on
**Why is it not something like
set syntax on
?** Like we have set nu
, set ai
etc.
With set syntax on
, I get this error
$ vi
syntax=
Error detected while processing /home/lazer/.vimrc:
line 30:
E518: Unknown option: on
Hit ENTER or type command to continue
and with set syntax
, I get this
$ vi
syntax=
Hit ENTER or type command to continue
Lazer
(36085 rep)
Oct 16, 2010, 07:01 PM
• Last activity: Apr 22, 2024, 06:33 AM
14
votes
3
answers
17752
views
Disabling vim visual mode in /etc/vim/vimrc does not work
I found plenty of questions regarding disabling visual mode in vim but none that tackles my particular problem: I added `set mouse-=a` to my `/etc/vim/vimrc` file to disable visual mode for good. Thing is: That seems to do nothing. However when I put the exact same directive into my user's `.vimrc`...
I found plenty of questions regarding disabling visual mode in vim but none that tackles my particular problem:
I added
set mouse-=a
to my /etc/vim/vimrc
file to disable visual mode for good. Thing is: That seems to do nothing. However when I put the exact same directive into my user's .vimrc
file it works.
Is this expected behaviour? Did I miss something? Has anyone a solution which doesn't involve managing a .vimrc
file for each and every user?
Thanks in advance!
I am on Debian 10, fully updated by the way.
Thorian93
(772 rep)
Nov 11, 2019, 07:58 AM
• Last activity: Feb 25, 2024, 08:09 PM
0
votes
1
answers
107
views
Vim does not display other files in the same folder when opening a file
On a brand new debian installation, when no `~/.vimrc` is present, `vim` shows all files in the current directory when trying to open another file for editing in normal/command mode, as shown below: [![vim when pressing ":e"][1]][1] However, when a `~/.vimrc` is present, even an empty one, I suddenl...
On a brand new debian installation, when no
However, when a
~/.vimrc
is present, vim
shows all files in the current directory when trying to open another file for editing in normal/command mode, as shown below:

~/.vimrc
is present, even an empty one, I suddenly cannot see other files in the same directory.
I am looking for the vim
option that I have accidentally disabled, so that I can re-enable this behavior.
Adama
(125 rep)
Jan 25, 2024, 06:02 PM
• Last activity: Jan 26, 2024, 12:24 PM
1
votes
2
answers
1319
views
modes not showing in status bar of vim
I installed vim version 7.4.1689 in my linux mint 18. I opened any file with vim but after switching between modes on the status bar it is not showing anything like which mode I am currently in. I searched everywhere for the solution found one but it did not worked. The solution given was to use the...
I installed vim version 7.4.1689 in my linux mint 18. I opened any file with vim but after switching between modes on the status bar it is not showing anything like which mode I am currently in. I searched everywhere for the solution found one but it did not worked. The solution given was to use the command:
in
:set showmode

in
/.vimrc
file, I did that but nothing happened, can somebody please help me to solve this issue.
Shivam
(11 rep)
Jan 16, 2017, 01:04 AM
• Last activity: Jan 10, 2024, 02:21 PM
1
votes
1
answers
112
views
What's overriding my .vimrc tabstop size setting for CMake files?
In my `~/.vim/vimrc`, I have: ``` set shiftwidth=4 set tabstop=4 ``` and when I edit a plain text file, that is respected. However, when I edit a CMake file - these both becomes 8. I tried looking for the cause of this change, but couldn't figure it out: * Nothing in `/usr/share/vim/vim90/syntax/cma...
In my
~/.vim/vimrc
, I have:
set shiftwidth=4
set tabstop=4
and when I edit a plain text file, that is respected. However, when I edit a CMake file - these both becomes 8. I tried looking for the cause of this change, but couldn't figure it out:
* Nothing in /usr/share/vim/vim90/syntax/cmake.vim
seems to be related to tab stops, or to include another vim file.
* Same for /usr/share/vim/vim90/syntax/cmake.vim
.
* The CMakeLists.txt
files I'm editing have no modeline.
What's causing this? Is there a definition I've missed? And - can I override it somehow?
einpoklum
(10753 rep)
Dec 22, 2023, 09:59 PM
• Last activity: Dec 24, 2023, 01:30 AM
1
votes
0
answers
84
views
Vim. Close the quicklist and return to the original window
I'd like to write a function that toggles the quicklist and when closing it, it returns to the window it was in before the quicklist opening. I tried to improve some function I found but it does not work as expected: ``` function! ToggleQuickFix() if empty(filter(getwininfo(), 'v:val.quickfix')) cop...
I'd like to write a function that toggles the quicklist and when closing it, it returns to the window it was in before the quicklist opening.
I tried to improve some function I found but it does not work as expected:
function! ToggleQuickFix()
if empty(filter(getwininfo(), 'v:val.quickfix'))
copen 20
else
call feedkeys("^W^P")
cclose
endif
endfunction
MG5
(11 rep)
Nov 2, 2023, 11:32 AM
• Last activity: Nov 2, 2023, 11:33 AM
4
votes
3
answers
4390
views
Change the default comments in GIT's COMMIT_EDITMSG after typing "git commit"
Sometimes when I'm at work, I want to commit and push changes to my own projects on GitHub. So I do a lot of `git config user.email` to make sure that I don't *commit* with my email at the company and that I in fact use my own personal email. Now I have `export GIT_EDITOR=vim` in my `~/.zshrc` file,...
Sometimes when I'm at work, I want to commit and push changes to my own projects on GitHub. So I do a lot of
git config user.email
to make sure that I don't *commit* with my email at the company and that I in fact use my own personal email. Now I have export GIT_EDITOR=vim
in my ~/.zshrc
file, so that every time I type git commit
, vim opens up and I see a file like this:
my actual commit message
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Your branch is up to date with 'origin/master'.
#
# Changes to be committed:
# modified: vim/.vimrc
#
Is there a way that I can modify these comments? So that it shows something like this:
my actual commit message
# Email: me@my.site
#
# On branch master
# Your branch is up to date with 'origin/master'.
#
# Changes to be committed:
# modified: vim/.vimrc
#
Amir Shabani
(291 rep)
Feb 12, 2022, 01:16 PM
• Last activity: Oct 14, 2023, 01:11 AM
8
votes
3
answers
5521
views
How can I expand directories by default in Vim's netrw tree view?
I can make netrw use the tree view by default by adding this to my vimrc: let g:netrw_liststyle=3 But I can't figure out how to expand sub-directories by default, is there a way?
I can make netrw use the tree view by default by adding this to my vimrc:
let g:netrw_liststyle=3
But I can't figure out how to expand sub-directories by default, is there a way?
user12810
May 16, 2015, 03:12 PM
• Last activity: Oct 12, 2023, 01:36 AM
0
votes
1
answers
440
views
"E492: Not an editor command: PlugInstall" only when I "sudo vim"
My question is a spinoff from this previous question 6 months ago, so to get more details and see how I've installed Vim Plug have a look [here][1]. Currently I wanted to add this extension. https://github.com/mattn/emmet-vim Here's my `.vimrc` file. ``` 1 2 syntax on 3 map :source ~/.vimrc 4 5 set...
My question is a spinoff from this previous question 6 months ago, so to get more details and see how I've installed Vim Plug have a look here .
Currently I wanted to add this extension.
https://github.com/mattn/emmet-vim
Here's my
.vimrc
file.
1
2 syntax on
3 map :source ~/.vimrc
4
5 set background=light " set background = set bg
6
7 " colorscheme desert
8 colorscheme elflord
9 " colorscheme slate
10 " colorscheme pablo
11 " colorscheme koehler
12 " colorscheme murphy
13 " colorscheme industry
14 " colorscheme torte
15 " colorscheme default
16 " colorscheme morning
17 " colorscheme ron
18 "
19 set background=dark " Setting up background=dark, makes text lighter
20 "
21 "
22 "
23 set nocompatible " Set compatibility to Vim only
24 set wildmenu " Enable Vim's builtin auto completion engine
25 set ignorecase " By default searching in Vin using / command is case-sensitive.
26 " Use 'set ignorecase' to set searching in Vim case insensitive.
27 " Use 'set smartcase' to make search case insensitive if you type the search pattern using lower case only.
28 "
29 set number " Show line numbers. Opposite is set nonumber.
30 "
31 set shiftwidth=3 " Set tabulator size to 4
32 set tabstop=3 " Set tabulator size to 4
33 set softtabstop=3 " Set tabulator size to 4
34 "
35 set wrap " Automatically wrap text that extends beyond the screen length
36 "
37 set laststatus=2 " Show status bar
38 "
39 set encoding=utf-8 " Force encoding
40 set list " Shows hidden characters
41 set nolist " Hide invisible characters
42 "
43 "
44 "
45 " Call the .vimrc.plug file
46 if filereadable(expand("~/.vimrc.plug"))
47 source /home/michal/.vimrc.plug
48 endif
49
And here's my .vimrc.plug
file:
1 " Plugins will be downloaded under the specified directory.
2 call plug#begin('~/.vim/plugged')
3
4 " Fugitive Vim Github Wrapper
5 Plug 'tpope/vim-fugitive'
6 " Emmet Vim
7 Plug 'mattn/emmet-vim'
8
9 call plug#end()
Both of these files are located in my user directory /home/michal/
, like so:
michal@ubuntu:~$ ls -lah /home/michal/.vim*
-rw------- 1 michal michal 20K Jun 21 23:23 /home/michal/.viminfo
-rw-rw-r-- 1 michal michal 1.7K Jun 21 23:12 /home/michal/.vimrc
-rw-rw-r-- 1 michal michal 203 Jun 21 23:09 /home/michal/.vimrc.plug
-rw-rw-r-- 1 michal michal 110 Dec 14 2022 /home/michal/.vimrc.plug.bak
-rw-r--r-- 1 root root 12K Jun 21 23:53 /home/michal/.vimrc.plug.swp
When I execute the command :PlugInstall
while I run Vim as michal
user, everything works fine.
But when I open Vim using sudo vim
and then try to run :PlugInstall
, I get E492: Not an editor command: PlugInstall
error.
Why is that?
I'm using Vim 95/100 times using sudo vim filename
, therefore I need all those plugins I install with Vim Plug, to work in sudo mode.
michal roesler
(289 rep)
Jun 21, 2023, 10:10 PM
• Last activity: Jun 22, 2023, 02:19 AM
Showing page 1 of 20 total questions