Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
10
votes
4
answers
4312
views
Make vimdiff display different lines as different lines (not partially different)
vimdiff has an annoying habit of displaying two almost-completely-different lines as the same partially-different line just because they share a character in common at the beginning or end. For example: `foo.txt` contains: `The quick brown fox jumps over the lazy dog`. `bar.txt` contains: `This is a...
vimdiff has an annoying habit of displaying two almost-completely-different lines as the same partially-different line just because they share a character in common at the beginning or end.
For example:
foo.txt
contains: The quick brown fox jumps over the lazy dog
.
bar.txt
contains: This is a completely different line
.
vimdiff foo.txt bar.txt
displays these two lines side-by-side with everything but the Th
at the beginning highlighted.
Is there a way to disable this behaviour and just display different lines as being different lines?
Shum
(1375 rep)
Oct 30, 2013, 04:50 AM
• Last activity: Jul 25, 2025, 10:49 AM
33
votes
1
answers
15789
views
Use case sensitive search for lower-case string using smartcase
I normally enable `smartcase` in my `.vimrc`. **Without `smartcase`:** - If I want case-insensitive search, I write in upper-case or lower-case (doesn't matter) and append a `\c` at the end of the query. - Case-sensitive search happens by default. **With `smartcase`:** - If I want case insensitive s...
I normally enable
smartcase
in my .vimrc
.
**Without smartcase
:**
- If I want case-insensitive search, I write in upper-case or lower-case (doesn't matter) and append a \c
at the end of the query.
- Case-sensitive search happens by default.
**With smartcase
:**
- If I want case insensitive search, I write all in lower-case.
- If I want case sensitive search, I write the upper-case letters in upper-case.
But, with smartcase
enabled, how can I say that I want a case sensitive search of a lower-case pattern? I was expecting that appending a \c
would revert the type of search (so that if I had written all in lower-case, i.e. case-insensitive search, it would turn to a case-sensitive search; and if I had written some upper-case letters, i.e. case-sensitive search, it would turn to a case-insensitive search), but that does not seem to be the case (no pun intended).
user2891462
(433 rep)
Apr 5, 2017, 12:03 PM
• Last activity: Jul 23, 2025, 08:07 PM
0
votes
0
answers
27
views
How to preset slime target to vim terminal by default?
When I use [vim-slime][1], every time I open a vimterminal I have to reconfigure it. ``` :let g:slime_target="vimterminal" ``` Followed by: ``` SlimeConfig ``` And then I choose the terminal I just opened as the target for the buffer I am in via a read statement from the plugin. This is becoming tir...
When I use vim-slime , every time I open a vimterminal I have to reconfigure it.
:let g:slime_target="vimterminal"
Followed by:
SlimeConfig
And then I choose the terminal I just opened as the target for the buffer I am in via a read statement from the plugin.
This is becoming tiresome; I seem to be able to set the slime_target as vimterminal
using my .vimrc
, but it is still unclear to me how to call the SlimeConfig
command and pass it an argument on the latest newly opened terminal upon opening the vimterminal.
I've found the following thread that seems to address this, but it appears that it's fired every time one switches windows.
leeand00
(4937 rep)
Jul 23, 2025, 03:52 PM
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
0
votes
1
answers
1908
views
terminal in Tmux is 256color but vim isn't
Recently I installed tmux on my Ubuntu 16.04. The terminal screen in `tmux` shows 256 color correctly however when I opened `vim` within `tmux`, the color was different from what it showed when it was run directly on the terminal. I tried to add set -g default-terminal "screen-256color" in my `.tmux...
Recently I installed tmux on my Ubuntu 16.04.
The terminal screen in
tmux
shows 256 color correctly however when I opened vim
within tmux
, the color was different from what it showed when it was run directly on the terminal.
I tried to add
set -g default-terminal "screen-256color"
in my .tmux.conf
file but the problem still exists.
* my terminal screen in tmux
: 
* vim
run directly on the terminal: 
* vim
run within tmux
: 
The output of
echo $TERM; tput colors; tput longname
* outside tmux: xterm-256color 256 xterm* with 256 colors inside tmux:
screen-256color 256 GUN Screen with 256 colors
Dyckia
(101 rep)
May 24, 2018, 09:59 PM
• Last activity: Jul 6, 2025, 03: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
75
views
Recompiling Vim with +clipboard on Arch Linux (DWM/X11)
I use Arch Linux + DWM on the X Window System. I can't copy from Vim to an external application, and the `vim --version` command returns `-xterm_clipboard`. As I understand it, I need to recompile my Vim and add clipboard support into the config file, but I don't know where to find it. Is it the `~/...
I use Arch Linux + DWM on the X Window System. I can't copy from Vim to an external application, and the
vim --version
command returns -xterm_clipboard
. As I understand it, I need to recompile my Vim and add clipboard support into the config file, but I don't know where to find it. Is it the ~/.vimrc
file? I can't find the original PKGBUILD in my ~/vim/
directory either.
I've tried to use **pacbuilder-svn** and ran:
$ pacbuilder --install --edit vim vim-runtime
But the script doesn't ask me whether I want to edit the PKGBUILD file; it just builds the packages and that's it.
I've also tried to use **devtools** and ran:
$ sudo pkgctl repo clone https://github.com/vim/vim.git
But it says:
failed to clone https://github.com/vim/vim.git
How can I recompile my Vim with clipboard support? I would be grateful for your help.
Bernadette
(13 rep)
Jun 8, 2025, 06:33 AM
• Last activity: Jun 8, 2025, 07:53 AM
22
votes
8
answers
19139
views
vi commandline, goto line and column
I have been mixing the use of `emacs` and `vi` (`vim`) for a long time. Each of them has its advantage. I parse error output from a compilation like process and get a line and column number but I can only use `emacs` to directly go to a line and column: emacs +15:25 myfile.xml with `vi` I only have...
I have been mixing the use of
emacs
and vi
(vim
) for a long time. Each of them has its advantage. I parse error output from a compilation like process and get a line and column number but I can only use emacs
to directly go to a line and column:
emacs +15:25 myfile.xml
with vi
I only have the line number (according to the man page)
vi +15 myfile.xml
There is an option to go position cursor on a pattern (vi +/pattern myfile.xml
) which i never got to work. But that would not help me as the pattern is not always the first occurrence in the file.
How can I start vi
so it goes to column 25 on line 15 of my file? Can I do something with -c
option?
Dominique
(305 rep)
Dec 18, 2014, 04:21 PM
• Last activity: Jun 4, 2025, 12:13 PM
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
80
votes
5
answers
55057
views
less command and syntax highlighting
I need to use the `less` command with the syntax highlighting of the vim command for `python`, `C`, `bash` and other languages. How do I apply syntax highlighting colors according to `vim` colors for `less` command?
I need to use the
less
command with the syntax highlighting of the vim command for python
, C
, bash
and other languages.
How do I apply syntax highlighting colors according to vim
colors for less
command?
PersianGulf
(11308 rep)
Sep 17, 2013, 06:17 AM
• Last activity: May 29, 2025, 02:29 PM
79
votes
6
answers
59346
views
Change default editor to vim for _ sudo systemctl edit [unit-file] _
*[4.13.12-1-ARCH with gnome3 and gdm on Xorg]* I already have set my VISUAL and EDITOR env-vars to `vim`. Similarly I did try `SYSTEMD_EDITOR="vim"; export SYSTEMD_EDITOR` in my ~/.bashrc, to no avail. When modifying unit files in Arch (systemd) via $ sudo systemctl edit _unit_ I find myself staring...
*[4.13.12-1-ARCH with gnome3 and gdm on Xorg]*
I already have set my VISUAL and EDITOR env-vars to
vim
. Similarly I did try SYSTEMD_EDITOR="vim"; export SYSTEMD_EDITOR
in my ~/.bashrc, to no avail.
When modifying unit files in Arch (systemd) via
$ sudo systemctl edit _unit_
I find myself staring at nano
. Life is too short and I want vim
by all means. How do I do this ?
Cbhihe
(2880 rep)
Dec 2, 2017, 06:11 PM
• Last activity: May 25, 2025, 07:41 AM
5
votes
1
answers
1174
views
Why RHEL has two vim installed by default?
I'm on a RHEL 8.3 system. I found that the built-in `vim` and `vi` are all `vim`. They have the same version, but compiled differently. Below is my testing: ``` [root@192 ~]# which vim /usr/bin/vim [root@192 ~]# which vi /usr/bin/vi [root@192 ~]# ls -lah `which vim` -rwxr-xr-x. 1 root root 3.0M Jun...
I'm on a RHEL 8.3 system. I found that the built-in
vim
and vi
are all vim
. They have the same version, but compiled differently. Below is my testing:
[root@192 ~]# which vim
/usr/bin/vim
[root@192 ~]# which vi
/usr/bin/vi
[root@192 ~]# ls -lah which vim
-rwxr-xr-x. 1 root root 3.0M Jun 3 2020 /usr/bin/vim
[root@192 ~]# ls -lah which vi
-rwxr-xr-x. 1 root root 1.2M Jun 3 2020 /usr/bin/vi
[root@192 ~]# vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 3 2020 09:07:54)
Included patches: 1-1763
Modified by
Compiled by
Huge version without GUI. Features included (+) or not (-):
+acl +farsi +mouse_sgr -tag_any_white
+arabic +file_in_path -mouse_sysmouse -tcl
+autocmd +find_in_path +mouse_urxvt +termguicolors
-autoservername +float +mouse_xterm +terminal
-balloon_eval +folding +multi_byte +terminfo
+balloon_eval_term -footer +multi_lang +termresponse
-browse +fork() -mzscheme +textobjects
++builtin_terms +gettext +netbeans_intg +timers
+byte_offset -hangul_input +num64 +title
+channel +iconv +packages -toolbar
+cindent +insert_expand +path_extra +user_commands
-clientserver +job +perl/dyn +vertsplit
-clipboard +jumplist +persistent_undo +virtualedit
+cmdline_compl +keymap +postscript +visual
+cmdline_hist +lambda +printer +visualextra
+cmdline_info +langmap +profile +viminfo
+comments +libcall +python/dyn +vreplace
+conceal +linebreak +python3/dyn +wildignore
+cryptv +lispindent +quickfix +wildmenu
+cscope +listcmds +reltime +windows
+cursorbind +localmap +rightleft +writebackup
+cursorshape +lua/dyn +ruby/dyn -X11
+dialog_con +menu +scrollbind -xfontset
+diff +mksession +signs -xim
+digraphs +modify_fname +smartindent -xpm
-dnd +mouse +startuptime -xsmp
-ebcdic -mouseshape +statusline -xterm_clipboard
+emacs_tags +mouse_dec -sun_workshop -xterm_save
+eval +mouse_gpm +syntax
+ex_extra -mouse_jsbterm +tag_binary
+extra_search +mouse_netterm +tag_old_static
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim80"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/python3.6m -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -Wl,--as-needed -o vim -lm -lselinux -lncurses -lacl -lattr -lgpm -ldl -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -L/usr/local/lib -L/usr/lib64/perl5/CORE -lperl -lpthread -lresolv -ldl -lm -lcrypt -lutil -lc
[root@192 ~]# vi --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 3 2020 09:07:06)
Included patches: 1-1763
Modified by
Compiled by
Small version without GUI. Features included (+) or not (-):
+acl -extra_search -mouse_netterm -tag_old_static
-arabic -farsi -mouse_sgr -tag_any_white
+autocmd -file_in_path -mouse_sysmouse -tcl
-autoservername -find_in_path -mouse_urxvt -termguicolors
-balloon_eval -float -mouse_xterm -terminal
-balloon_eval_term -folding +multi_byte +terminfo
-browse -footer -multi_lang -termresponse
+builtin_terms +fork() -mzscheme -textobjects
-byte_offset -gettext -netbeans_intg -timers
-channel -hangul_input -num64 -title
-cindent +iconv +packages -toolbar
-clientserver -insert_expand -path_extra -user_commands
-clipboard -job -perl +vertsplit
-cmdline_compl +jumplist -persistent_undo -virtualedit
+cmdline_hist -keymap -printer +visual
-cmdline_info -lambda -profile -visualextra
-comments -langmap -python -viminfo
-conceal -libcall -python3 -vreplace
-cryptv -linebreak -quickfix +wildignore
-cscope -lispindent -reltime -wildmenu
+cursorbind +listcmds -rightleft +windows
-cursorshape -localmap -ruby +writebackup
-dialog -lua +scrollbind -X11
-diff -menu -signs -xfontset
-digraphs -mksession -smartindent -xim
-dnd -modify_fname -startuptime -xpm
-ebcdic -mouse -statusline -xsmp
-emacs_tags -mouse_dec -sun_workshop -xterm_clipboard
-eval -mouse_gpm -syntax -xterm_save
+ex_extra -mouse_jsbterm +tag_binary
system vimrc file: "/etc/virc"
user vimrc file: "$HOME/.virc"
2nd user vimrc file: "~/.vim/virc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim80"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/python3.6m -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -Wl,--as-needed -o vim -lm -lselinux -lncurses -lacl -lattr -ldl
[root@192 ~]#
Why they maintain two different versions? It's a little weird to me. If they want vi
users to have a modern editor, they can simply symlink to vim
. Out of curiosity, below is the result on a Ubuntu 20.04 system. Both vi
and vim
points to nvim
, which is reasonable.
root@u2004:~# which vi
/usr/bin/vi
root@u2004:~# which vim
/usr/bin/vim
root@u2004:~# ls -la which vi
lrwxrwxrwx 1 root root 20 Aug 28 2020 /usr/bin/vi -> /etc/alternatives/vi
root@u2004:~# ls -la which vim
lrwxrwxrwx 1 root root 21 Apr 1 08:28 /usr/bin/vim -> /etc/alternatives/vim
root@u2004:~# ls -la /etc/alternatives/vi
lrwxrwxrwx 1 root root 13 Apr 1 08:28 /etc/alternatives/vi -> /usr/bin/nvim
root@u2004:~# ls -la /etc/alternatives/vim
lrwxrwxrwx 1 root root 13 Apr 1 08:28 /etc/alternatives/vim -> /usr/bin/nvim
root@u2004:~# man hier
root@u2004:~# readlink -f which vi
/usr/bin/nvim
root@u2004:~# readlink -f which vim
/usr/bin/nvim
root@u2004:~#
Fajela Tajkiya
(1065 rep)
Apr 14, 2022, 01:52 PM
• Last activity: May 23, 2025, 10:10 AM
3
votes
1
answers
219
views
Multiple selection with fzf and vim having new lines in path/file names
I have a Bash function that follows the [fzf](https://github.com/junegunn/fzf/tree/master) key-bindings in [key-bindings.bash](https://raw.githubusercontent.com/junegunn/fzf/refs/heads/master/shell/key-bindings.bash). ``` # shellcheck disable=SC2206 __fzf_edit_file__() { builtin local -a opts builti...
I have a Bash function that follows the [fzf](https://github.com/junegunn/fzf/tree/master) key-bindings in [key-bindings.bash](https://raw.githubusercontent.com/junegunn/fzf/refs/heads/master/shell/key-bindings.bash) .
# shellcheck disable=SC2206
__fzf_edit_file__() {
builtin local -a opts
builtin local edit_file file
opts=(
"+m"
--read0
"--reverse"
"--header-first"
"--scheme='path'"
'--preview-window=right:80%:wrap'
"--height" ${FZF_TMUX_HEIGHT:-80%}
"--walker='file,dir,follow,hidden'"
"--preview 'bat --color=always --wrap never {}'"
"--header='Key: [CTRL-F] Select, preview and edit file(s) in [${PWD}]'."
--bind='ctrl-z:ignore,ctrl-a:toggle-all,ctrl-s:toggle-preview,ctrl-d:preview-down,ctrl-u:preview-up'
)
# shellcheck disable=SC2091
builtin exec {edit_file}CTRL+F
• Use arrow keys to move up and down or CTRL+J, CTRL+K
• CTRL+D to scroll the file contents (or mouse scrolling, if allowed)
• CTRL+S to toggle preview window.
• Enter/return key to select
• CTRL+A to toggle all from fzf, but that is disabled now because of the +m
• TAB to select multiple files, also disable because of the +m
• ESC to exit.
---
That works as expected; the issue is when selecting multiple (with the TAB key) file/path names
with newlines embedded. The +m
option allows only a single selection. It used to be -m
and mapfile
instead of read
to allow multiple file selections, but that causes a problem.
vim
opens a new file that contains all the file or path names, including embedded newlines.
How can I fix that issue? I checked vim; doesn't appear to support null delimited input like -z
.
As far as I know, vim can handle spaces/tabs/newlines in path/file names with:
files=(*.txt)
vim -- "${files[@]}"
---
The version that works for multiple files selection, but fails with newlines.
- Remove the --read0
- Change the +m
to -m
And use mapfile
LC_ALL=C IFS= builtin mapfile -u"$edit_file" file
((${#file[*]})) && {
vim -- "${file[@]%?}"
}
```
---
Jetchisel
(1544 rep)
May 7, 2025, 09:05 PM
• Last activity: May 18, 2025, 01:18 AM
59
votes
5
answers
44646
views
How can I constantly see the current filename in vim?
I am using vim and I need a way to always be able to see the file that I am working on without having to do `^G`. I see the file name when I start vim but when I start to work and use various functions it gets lost. Also I have seen other people have some kind of "addons" in the lower part of the vi...
I am using vim and I need a way to always be able to see the file that I am working on without having to do
^G
.
I see the file name when I start vim but when I start to work and use various functions it gets lost.
Also I have seen other people have some kind of "addons" in the lower part of the vim console that seem like they are "button"/"tabs" (I am not sure how to describe them) that show various info constantly including the file name.
Any idea what are these plugins? Or how can I achieve what I want?
Jim
(10550 rep)
Jan 29, 2014, 10:42 PM
• Last activity: May 16, 2025, 01:26 PM
71
votes
7
answers
28229
views
Replacing Multiple blank lines with a single blank line in vim / sed
Question more or less says it all. I'm aware that `/^$/d` will remove all blank lines, but I can't see how to say 'replace two or more blank lines with a single blank line' Any ideas?
Question more or less says it all. I'm aware that
/^$/d
will remove all blank lines, but I can't see how to say 'replace two or more blank lines with a single blank line'
Any ideas?
Andrew Bolster
(1005 rep)
May 7, 2011, 08:19 PM
• Last activity: May 16, 2025, 08:23 AM
0
votes
0
answers
93
views
Opening Vim under script(1) breaks output. Can Vim detect script?
Opening `vim` while recording with [`script`][1] causes `script` to go wild (my screen starts filling up with a bunch of crap, some of which says "script", and I also believe it is colored neon green). Does `script` set any environment variables that `vim` can check to stop from opening? [1]: https:...
Opening
vim
while recording with script
causes script
to go wild (my screen starts filling up with a bunch of crap, some of which says "script", and I also believe it is colored neon green).
Does script
set any environment variables that vim
can check to stop from opening?
leeand00
(4937 rep)
May 8, 2025, 08:08 PM
• Last activity: May 9, 2025, 11:26 AM
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
3
votes
2
answers
3448
views
alacritty - change background color based on application
Is it possible to change the background color depending on which application is running currently? My vim theme background differs with the terminal but I don't want to change the background of my terminal permanently just because of vim.
Is it possible to change the background color depending on which application is running currently?
My vim theme background differs with the terminal but I don't want to change the background of my terminal permanently just because of vim.
GhostOrder
(181 rep)
Jul 22, 2022, 03:54 PM
• Last activity: Apr 27, 2025, 11:01 AM
3
votes
1
answers
2153
views
Vim Syntax Highlight for Configuration Files
The vim version on my faculty cluster has a great feature in highlighting the syntax for Linux standard configuration files (like /etc/network/interfaces or httpd.conf). I've tried a lot of settings and options in the way to obtain the same behavior, but nothing helps. Any ideas? Thank you! :)
The vim version on my faculty cluster has a great feature in highlighting the syntax for Linux standard configuration files (like /etc/network/interfaces or httpd.conf).
I've tried a lot of settings and options in the way to obtain the same behavior, but nothing helps.
Any ideas?
Thank you! :)
Filip Ion Dorinel
(131 rep)
Jan 9, 2016, 02:56 PM
• Last activity: Apr 24, 2025, 09:03 AM
Showing page 1 of 20 total questions