Questions tagged [vim]
vim (Vi IMproved) is a text editor supporting different editing modes.
1,860
questions
0
votes
3
answers
43
views
How to delete all occurrences of `Answer.*` and paste it to the end of a file
How to delete all occurrences of Answer.* from a file and paste it to the end of a file using vim. I can use commands like sed or any others.
1. Lorem ipsum? Answer: lorem
2. Lorem? Answer: ipsum
.......
0
votes
2
answers
30
views
In the Vim editor, I want to enable Github Copilot manually and have it disabled by default
If one installs the Github Copilot software for the Vim editor, it enables the co-pilot by default, which could be seen as a privacy issue.
I want to disable the co-pilot by default and only enable it ...
0
votes
1
answer
38
views
How to specify [[hints.enabled]] Alacritty section one matching hypelinks (open on mac) and second any file paths and open in vim
I am using Alacritty terminal for quite some time and it has a great feature to follow hyperlinks when clicking Ctrl+Shift+U. I am using MAC so a default program is open.
Iam trying to add one more ...
0
votes
0
answers
25
views
how to use `vi`/`vim` in cli mode like `sed` [duplicate]
i need to replace some strings and due to some reason, vi or vim is my only options.
but the problem is i need this to be done in a shell script, is it possible to use vi/vim in cli mode like sed?
e.g....
1
vote
0
answers
36
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 ...
0
votes
2
answers
57
views
Paste the value of a shell expression into Vim
I need to make the text returned by echo $(which bash) available for pasting in a text file opened in Vim.
The cause of my confusion is that it seems there are at least three clipboards:
system ...
0
votes
0
answers
33
views
how do I map <F7> to :argument with the file buffer number as input
I have several files opened with :argadd command. To traverse the files I use F2 and F3 which is mapped to :prev and :next.
When a number like 15 and F7 is pressed then it should do
:argument 15
...
3
votes
1
answer
130
views
Match any character except a specific one at the start of a string, or any whitespace
I have a command mapping ("ESC-P") in my .vimrc which underlines the current line, leaving whitespace or # intact.
map ^[p :.t.^M:s/[^[:space:]#]/-/g^M
If I run this on a line of text, it ...
0
votes
0
answers
57
views
Vim: using a match (/ regexp) as a boolean to direct program flow
I'm developing a script for Vim to automatically update a "Last modified" timestamp on files. I'm sure this has been done before. I suspect answers will direct me to these existing ...
0
votes
1
answer
43
views
vim does not write file without showing error
vim is unable to write to a file, it just shows '<filename>' 1L, 0C when writing.
I have tried :w, :wq, and :w! with the same result. The file is created (if it did not exist), but no contents ...
0
votes
1
answer
29
views
Crontab run after deleting a file
I have a script thar I want to be executed each first minute of each hour. Thus, i made a second file named crontab.sh:
$ cat crontab.sh
#!/bin/bash
#cript path
script_path="/mnt/lap_c/home/...
-2
votes
1
answer
79
views
How to make sed "silent" in a vim script?
This vim script make its work
#!/usr/bin/vim
%!sed 's/ .*//'
%!sort -fu
norm dd
% norm $D
The only problem is this message at the end (i have to press ENTER in keyboard)
"20 lines filtered
20 ...
1
vote
1
answer
72
views
Fontawesome icons are not pasted correctly
I am using Fedora and installed fontawesome via sudo dnf install fontawesome fonts. Later because it didn't work I also additionally installed the font manually via downloading the zip from the Github ...
0
votes
2
answers
50
views
E325 Error with permission denied while deleting
I have this message on Linux Mint:
325: ATTENTION
Found a swap file by the name "/etc/default/.grub.swp"
owned by: root dated: Fri Mar 29 17:37:00 2024
file name: /etc/...
12
votes
1
answer
3k
views
Why does typing 'q' exit vim? (.man file)
When I type the character q on my keyboard in vim, it exits vim. Why?
Today I tried it edit a file with the file extension .man. I wanted to edit the file with a macro, so I tried to type qq -- but ...
0
votes
0
answers
656
views
How to enable <Ctrl+Backspace> with Tmux, Neovim and Alacritty to delete the previous word?
I use the alacritty terminal, and neovim editor with tmux.
At first Ctrl+Backspace (for deleting a previous) wasn't working at all in the terminal. So added the following line to alacritty.yml:
...
2
votes
2
answers
642
views
Vim enable Ctrl+Shift+C
So...I'm using Vim (in the terminal, not any sort of other gui; whenever Vim is used by itself, assume it's terminal vim).
Vim is decent, I actually don't find the learning curve to be too bad. I'm a ...
0
votes
1
answer
61
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:
...
4
votes
2
answers
802
views
Can a file be closed in vim without exiting?
I have a file open in vim, and I have finished my edits. Is there a way for me to close the file (or buffer) so that the vim screen is blank?
0
votes
0
answers
37
views
How to diff command outputs in vim
I tried vim -d <(ffprobe one.mp4 2>&1) <(ffprobe two.mp4 2>&1) to see the difference between the two videos' codecs etc., but vim doesn't show anything when it opens, just an empty ...
1
vote
2
answers
31
views
Disable $keyword$ expansion by RCS ci check in?
For better or worse, I am using rcs to track changes to HTML and JSON files exported from chatGPT. Some of these contain chats with embedded $keyword$'s. These get expanded on ci check in. How do I ...
0
votes
1
answer
71
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 ...
0
votes
1
answer
54
views
Vim Colour Theme Problem
My goal "was" to set the text-width persistently to 72. I seem to be only able to achieve this by creating a custom .vimrc file. However when I did that, I immediately ran into a colour ...
0
votes
1
answer
96
views
yamlfix not using configuration + (neo)vim usage
I'm using yamlfix with ale in vim.
I followed these steps because I wanted to remove the automatic "---" adding on top of the file every time I save my work (and some others default ...
0
votes
1
answer
48
views
Vim keeps resetting textwidth to 0, why?
I am trying to understand why VIM keeps resetting my textwidth to 0.
To create the problem, I open a new file in Vim, and I type:
:set textwidth=72
I then enter a sentenace or two and I can see that ...
-1
votes
1
answer
87
views
Mouse events not working in Vim on Debian?
If I click on a line, I can see "19m" or "18m" etc. show up in the bottom right of the screen. If I scroll, nothing happens, but shift+click&drag works.
set encoding=utf8 ...
0
votes
2
answers
137
views
Highlight for two strings simultaneously in vi or less editor?
https://stackoverflow.com/questions/41901319/how-to-search-for-multiple-strings-in-a-log-file-using-less-command-in-unix
I found this.
awk '/pattern1/ && /pattern2/ && /pattern3/' file....
1
vote
0
answers
161
views
I feel like my :colorscheme is not displayed correctly. There is so much terminology involved. What are vim color modes?
I have a feeling that the :colorschemes I'm using in Vim are not displayed properly.
That the colors are corrupted.
I think this because I have 3 virtual machines rented from 3 different vendors, two ...
2
votes
0
answers
101
views
How to configure coc and nvim to sort react imports correcty?
I use nvim daily in conjunction with coc and it has been extremely more efficient than VS code, however, something that is done in vscode and I can't configure for when I use React is the import in ...
2
votes
1
answer
157
views
Vim intercepts ssh escape
There is no issues to solve (that I know of). I am trying to better understand ssh.
On my system the ssh escape character is tilde (~). If I ssh somewhere I can use it as expected:
me@local$ ssh ...
1
vote
1
answer
393
views
.vimrc file not working
I have the following short and simple .vimrc file that I've started as I begin to learn and write my own .vimrc:
1 set number
2
3 highlight GoComment xtermfg=blue
4
5 syntax on
However, ...
1
vote
0
answers
55
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 ...
0
votes
1
answer
43
views
Using vim, how do I fix word wrapping with leading comment markers like #
How do I fix the word wrapping in the following text, so that the comment # characters are also fixed up?
Given this:
# This is documentation
# that
# is very helpful. Lorem ipsum dolor sit amet, ...
3
votes
2
answers
560
views
How can I automatically wrap every command in Zsh/Bash with a custom command before execution?
I'm trying to modify the behaviour of the Zsh (or Bash) shell to automatically prepend a custom command, named myapp for example, to all input before it's executed. Essentially, I want to intercept ...
0
votes
1
answer
235
views
tying together the 'xxd' command with output
I have the following hex dump:
00000000: 2345 5854 5241 530a 0a31 2e20 746f 2061 #EXTRAS..1. to a
00000010: 6464 2075 7365 723a 2060 7375 646f 2075 dd user: `sudo u
00000020: 7365 7261 6464 205b ...
0
votes
3
answers
177
views
open man (or info) pages from the same position where you left off last time
I treat man pages is the primary source of documentation about installed software.
I would like to use them not only as a reference, but actually read them from beginning to end.
And here comes the ...
0
votes
0
answers
17
views
vim remove pattern not working [duplicate]
I'm trying to remove all occurrences of '[01;34m' from the following file:
Script started on 2023-09-16 10:06:45-04:00 [TERM="xterm-256color" TTY="/dev/pts/1" COLUMNS="204&...
0
votes
0
answers
15
views
vim replace all characters in one cmd [duplicate]
I'm trying to remove the following special characters:
^M, ^[, ^G
from the script:
Script started on 2023-09-16 08:49:25-04:00 [TERM="xterm-256color" TTY="/dev/pts/1" COLUMNS="...
1
vote
1
answer
112
views
In vim: stop SHIFT+SPACE from discarding all unsaved changes
Every time I type Shift+Space in vim, it undoes all changes to the file that have not yet been written. I would like this to not happen, as it is extremely easy to press Shift+Space by accident.
I am ...
-1
votes
2
answers
191
views
How to force write (`:w!`) and quit (`:q`) vim in the same command? [duplicate]
How can I force write (:w!) and quit (:q) vim in the same command? I try :w!q but that doesn't work.
0
votes
1
answer
123
views
How does vim catch mouse scroll events?
I am writing a text editor.
With 1049 (alternate screen) mode + 1000 (mouse tracking) mode enabled, the terminal is able to catch both mouse scroll events and click events. I do not need the click ...
0
votes
1
answer
130
views
Calling vim in subprocess after running cat
I am trying to create a bash function vim_run which operates as follows:
user pipes command output into vim_run
user can edit output
user exits vim and the contents of that buffer are now executed ...
0
votes
1
answer
123
views
jump back into vim directory browser after closing a file
vim is able to open directories (and then browse in them).
vim roles/webservices/tasks/
" ============================================================================
" Netrw Directory ...
2
votes
0
answers
51
views
How do I get the man page for a sub command using vim?
For example, I get the manpage for a command using 'K':
docker run
+------------ cursor is on d
# if I press 'ESC-SHIFT-K', I'll get a manpage for docker
Now, if I want to get the manpage for docker ...
1
vote
0
answers
4k
views
How can install vim on the new debian12 version?
Version conflict when to install vim on my debian12:
sudo apt install vim
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be ...
0
votes
1
answer
222
views
In vim, how do I prevent pasting on top of visually selected text from erasing the contents of the clipboard?
In Vim, if I have a file like this:
one
two
I visually select "one" by using ve and then yank it by using y, it gets copied to the default register (referred to as the "clipboard")...
0
votes
1
answer
363
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.
Currently I wanted to add this extension.
https://github....
0
votes
0
answers
104
views
piping text file contents with unsaved modifications to a command with the neovim interactive terminal emulator
I want to know if theres an equivalent to :w !cmd for the nvim terminal emulator. Like :te cat % | cmd is almost there but you would have to save the file before using it.
Is there another way?
Like ...
0
votes
1
answer
424
views
Map <C-S-A-hjkl> to Arrow Keys with XKB Map
I'm trying to also have access to my arrow keys from the default Vim hjkl.
Since CtrlShiftAlt seems to be a rare key combo, I was thinking about using that.
How would I do that using setxkbmap (or ...
3
votes
1
answer
161
views
How to make bash keyboard editing default to vi from emacs?
I know how to set the keyboard editing in bash to vi (set -o vi), and probably I could do it in bashrc. But I use bash in a variety accounts and contexts and want it to just default to vi over emacs ...