Questions tagged [vim]

vim (Vi IMproved) is a text editor supporting different editing modes.

Filter by
Sorted by
Tagged with
0
votes
1answer
9 views

vim is showing strange behavior in bashscript

#!/bin/sh action() { screen -X stuff "xdotool key Ctrl+a $1"$(echo '\015') } action bar screen action 0 action Tab action 1 action S screen action Tab action 2 action Tab vim #action Tab #...
1
vote
1answer
15 views

How can I edit columns of numbers in vim using conditionals?

If I have, for example, a column of numbers: 4 6 8 10 12 Is there a way in Vim that I could find all numbers higher than 8, than do math only with these numbers? Obtaining a new column as a result: ...
101
votes
13answers
47k views

How can I do a 'change word' in Vim using the current paste buffer?

I have some text in my paste buffer, e.g. I did a yw (yank word) and now I have 'foo' in my buffer. I now go to the word 'bar', and I want to replace it with my paste buffer. To replace the text ...
1
vote
0answers
26 views

Editing a UTF-8 binary file

If I open a binary file in vim it shows the following text: ð<9F><92>¦. Encoding is set to UTF-8. But when I search for its content with strings --encoding=S myfile I see the 💦 emoji. As ...
0
votes
1answer
22 views

stop gvim from printing the filename onto console

In my unix environment when I use gvim to open a file it immediately print the file name onto console. Can someone help me on how to stop gvim from doing this? $ gvim ~/.cshrc.local "~/.cshrc.local" ...
0
votes
0answers
28 views

Vim automatically clear the command line

When using vim I like to keep my command line (the line where messages, warnings and errors are printed) empty, so after saving a file I usually issue a <C-l> to redraw the screen and clear it. ...
1
vote
0answers
34 views

Weird '?' characters all over inside vim editor in tmux session

So I am excited to use WSL feature of Windows 10 and I choose Ubuntu distribution. I installed vim version 8.0 and tmux version 2.6. However to my frustration, when I use vim inside tmux session, all ...
0
votes
1answer
23 views

How to set tab for all files to use two spaces when in vi?

When I edit ruby (.rb) and Javascript (.js) files my settings seem to work ok to make a tab be a space. However for other files, such as files with no extension, when I use tab I get a tab, not two ...
61
votes
3answers
40k views

How to make Vim display colors as indicated by color codes?

In short, I'm in an effort to replace less with vim (vimpager). I have settings for scripts to spit out colors (and bold and everything nice) whenever they can. less understands the color codes and ...
0
votes
1answer
21 views

Vim is inserting ^@ when I try to insert a line break

When I open Vim on my laptop and run regex like this: :%s/foo/\n/g vim inserts ^@ instead of line breaks. This problem started happening last week. I'm running Ubuntu 18.04.04. I think the problem ...
0
votes
1answer
25 views

How to replace a character with carriage return in vim

If you use \r or ^M in the replacement part of a substitution in vim, it inserts a newline. So how do I insert an actual carriage return character as part of the substitution? EDIT: This is ...
0
votes
0answers
25 views

^PgUp/^PGDown for tabswitching are not working

Vim has default keybindings for tabs navigation -- Ctrl+PgUp/Ctrl+PgDown But in st they are not working, I suppose that the reason lies in ~/.inputrc but I do not how to edit it. My current inputrc: ...
26
votes
3answers
12k 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 ...
0
votes
1answer
45 views

Vim binds not working in st

In my vimrc, I have keybinds set up for navigating through split windows in vim. They work perfectly in urxvt but refuse to work in st. The code I have is nnoremap <silent> <C-Up> :...
186
votes
6answers
410k views

delete line in vi

How can I delete a line in VI? Here what I am doing right now: Open up the terminal alt + ctrl + t vi a.txt I move my cursor to the line which I wan to delete, then what key-combination is should ...
1
vote
1answer
130 views

How to control an interactive shell (e.g. vim) from another machine?

My problem is: my bluetooth keyboard won't work with my new android phone (big screen), but it does work with my old android phone (small screen). So I'd like to connect the keyboard to my old phone ...
165
votes
12answers
222k views

What is `^M` and how do I get rid of it?

When I open the file in Vim, I see strange ^M characters. Unfortunately, the world's favorite search engine does not do well with special characters in queries, so I'm asking here: What is this ^M ...
0
votes
0answers
21 views

Splitting code to files [migrated]

I`m writing long c++ code using vim editor and I compile using bash terminal I want to organize my code by writing functions in separate files can I write a function in new sub-file and attach all sub-...
4
votes
4answers
3k views

Vim shortcuts in insert mode

When I'm entering some text in vim, sometimes I need to jump to some other place and enter more text. I know there are some shortcuts with ctrl key to simplify the movement. What are the most useful ...
1
vote
2answers
26 views

Vim is displaying medium dash as �~@~S and long dash as �~@~R

I'm using vim on a shared Bluehost server. When I try to type —, Vim inserts �~@~R. And when I try to type –, Vim inserts �~@~S. The problem is not specific to any particular file. It seems to ...
2
votes
2answers
61 views

Vim - How to replace a newline with the string “\n”

In vim, I want to replace newlines with the literal string \n. For example, if I open a file that contains this text: This is line one This is line two I want to replace the newlines and have the ...
0
votes
2answers
44 views

How to delete particular lines in vim editor

Suppose I have 50 lines in my vim editor and I have to delete particular lines (5,9,16,28) in a single command.
1
vote
1answer
15 views

How to keep heading tab when copy-paste in tmux

Follow below tips Copy text from one tmux pane to another (using vim) Seems all the heading tab will be replaced by space during copy-paste, I want to know is any tips to keep all the heading tab.
30
votes
6answers
79k views

How to move to last character of the file in vim?

File: i am someone1. i am someone2. i am someone3 ~ ~ Documentation says G takes me end of the file, but it only takes me to the beginning of last line. I want to be able to come to last character ...
3
votes
1answer
136 views

vim - how to … yank util phrase

I'm using the latest version of vim 8.2.148 on the latest version of arch linux 5.5.6-arch1-1. If I want to copy from the cursor until a letter further on in the sentence, I can do that, for example ...
0
votes
2answers
32 views

Difference beetwen default.vim and /etc/vim/vimrc [closed]

What is the difference between $VIMRUNTIME/default.vim and /etc/vim/vimrc? Why is $VIMRUNTIME/default.vim started first? Shouldn't /etc/vim/vimrc leave first? (Debian 9)
0
votes
0answers
20 views

overlay-fs and editing upper directory with vim

For developing purposes, I am using the overlay-fs to merge custom changes to the base file structure. The merged-folder is used by a java application. Now I experienced a strange behavior when using ...
17
votes
1answer
8k views

Replace unicode chars in VIM?

I got some logs from a Windows machine, which contains multiple instances of <200e>, I know it's a Unicode char, but how can I remove it with s command? I don't know how to input that in the ...
1
vote
3answers
39 views

VIM: scripted search and replace?

I am switching to Linux and used to have NoteTab Pro, which allowed me to do scripted search and replaces... as I need multiple replace sequences to achieve a certain outcome. I'd like to put these ...
0
votes
2answers
36 views

Conflict Ctrl-I with TAB in normal mode

I recently noticed that in normal mode when I type Ctrl-i (command for jumps) it is "confused" for the TAB key. In particular, I have this mapping: nnoremap <Tab> :tabnext<Enter>
0
votes
1answer
45 views

List of MARKS. Duplicate lines

The numbered marks, are used for trace history of the cursor position in the last closed session vim...and ok. therefore: 0 contain last position of the cursor before close VIM, 1 contain the ...
3
votes
1answer
1k views

How to edit files with VIM through FTP

I'm trying to use: vim ftp://user@hostname// - this gives me a correct directory tree, but when I try to open given file, by pressing Enter, at the first time - nothing happens (just cursor jumps to ...
148
votes
8answers
146k views

Copy text from one tmux pane to another (using vim)

I have two files opened in vim, each in one tmux pane. I would like to copy let's say 10 lines from one file to another. How can I accomplish this not using the mouse's Copy -> Paste ?
5
votes
2answers
2k views

Share a buffer between tmux / vim splits

+-------------+ | | | 1 | | | |=============| | | | 2 | | | +-------------+ Each tmux split has vim open. I would like to do stuff ...
6
votes
4answers
3k views

How to change the pair of a changed HTML tag in Vim?

How can I configure Vim so that when I change one member of a matching pair of HTML tags, the other is automatically changed to match? For example: given <span>content</span>, I want to ...
1
vote
1answer
41 views

Airline missing in URXVT

I am having a trouble configuring ViM in urxvt: The lower and upper (buffer) bars are transparent. Things I have tried: opened vim in tty2 and confirmed that it looks the same as in urxvt it looks ...
25
votes
2answers
6k views

What would cause vim not to retain command history?

On other distros I have run, vim remembers your command history even between sessions; this is especially handy when doing a lot of similar operations on different files. For some reason, it has been ...
2
votes
5answers
91 views

How can I match all characters up to the second to last white space character in a string?

I'm trying to replace the substring "Abbey Street E.2 " in the string "Abbey Street E.2 Buckfast Street" to get the result "Buckfast Street". I tried :s/[^ ]* [^ ]* //but I'm getting "Street". ...
29
votes
7answers
7k views

Vim interface on web browser input fields?

I am looking for a browser plugin which inputs textin of input boxes with the same keyboard interface of the Vim text editor. I have adopted Vimium which makes general navigation much more effective, ...
-2
votes
1answer
15 views

How to reduce numbering indent in vi in 19.10?

Upgraded to 19.10 and my terminal window without numbers is ok but with numbers (:set nu) it now has a large annoying indent! I tried the solution at https://unix.stackexchange.com/a/252200/10043 ...
1
vote
3answers
44 views

How can I replace text and change encoding from a shell script without Vim?

I have a line of shell script that looks like this: vim file.xml -c "s/\r/\r/g" -c "set fileencoding=utf8" -c "wq" It works perfectly from the (macOS) terminal, but when I execute it within another ...
5
votes
1answer
64 views

Make the Shebang of a script different color than comment lines for vim

Currently I have my .vimrc set to produce blue comment lines, I was wondering if it was possible within the vim framework to make the color of line that start with #! a different color than those that ...
0
votes
1answer
30 views

How do I change a value in a line of an existing script to reflect the (numerical) folder name?

I'm running a job where I have multiple folders (labelled 0 to 41), each containing an identical script which need the ninth line edited: #SBATCH -J aXau19 X should correspond to the name of the ...
3
votes
1answer
1k views

How can I see moved lines in a file comparison with vimdiff / diff?

Moved lines are frequently annotated as deletes and adds but they can be shown as moved-from and moved-to instead. Like in this screenshot of Notepad++.
22
votes
5answers
12k views

How can I count the number of words in a file whilst editing the file in vim

I know I can use wc for counting characters, words and lines of files at the command line. Is there any way I can can count the number of words while in vim?
0
votes
1answer
8 views

How can I delete marks in Kile/Kate in vim-mode?

When setting marks in Kile’s/Kate’s vim-mode via m. the line will be highlighted. This can be annoying and the attempt to remove the mark via :delmarks fails with unknown command: “delmarks”. Is it ...
12
votes
7answers
35k views

Copy/paste into SSH'd VIM from local (Windows) clipboard

I would like to copy from a local machine and paste into vim on a remote box which I am SSH'd into. That's it. I have tried "+p and "*p, mouse middle-clicking, and a couple other things to no ...
0
votes
1answer
36 views

How to set “less” and “lesspipe” correctly?

I had set less to a vim less functionality some years ago and I would like to reverse those changes. Therefore I started removing the alias from "~/.zshrc". Since after sourcing this file my system ...
0
votes
1answer
27 views

:n and :N not working when opening files with

Okay so I have already gone through this. So I know you can edit multiple files in VIM if you open them up in the following way: vim file1 file2 and you can change files using :n and :N. But what ...
1
vote
0answers
29 views

How can I start a terminal running vim with a input file

I can start a terminal running vim with : open -a Terminal /usr/bin/vim I'm trying to edit a file like: open -a Terminal /usr/bin/vim --args $HOME/.bashrc But --args $HOME/.bashrc has no effect at ...

1
2 3 4 5
32