Questions tagged [vi]

vi is a screen-oriented text editor originally created for the Unix operating system.

-1
votes
1answer
103 views

How to get into insert mode in vi editor?

I want to create a file with name text.txt, so I used a command vi text.txt then after that I need to enter the insert mode so while hitting i on the keyboard I'm not into the insert mode. I'm using ...
0
votes
1answer
44 views

Run zsh (oh-my-zsh) in Vi mode when connecting to remote server via ssh

I'd like to connect to a remote server using ssh and have the session running in Vi mode. I have found how to do that for bash: ssh username@server -t 'bash -o vi' But I need the same thing for zsh (...
0
votes
1answer
36 views

How to turn on syntax highlighting for vi/vim?

Running a minimal ISO of CentOS_7 I've tried writing a .sh script using vi but can't get syntax highlighting to work. Pressing escape and typing :syntax on as shown in articles like this one are not ...
0
votes
0answers
18 views

Vim autostart with Vexplore and terminal

I want to setup vim to behave like a traditional ide for the most part. What I would like to do is when I type the command vim it opens up this way: The problem is it opens this way: I would like ...
2
votes
1answer
56 views

Replace VI macro with Linux equivalent

My file arrives on a Linux server and contains ^M characters when seen in VI and the file format = unix, (ff=unix) I want to turn lines 1-4 into line lines 9 - 10. My vi macro solves my problem. /\r/...
1
vote
1answer
62 views

Binary executable file with write permission get READONLY from vim

First I know that use vim to write a binary executable program is not recommended. So, I don't want to talk about its rationality here. I have a binary program, with permission 755(owner is root), so ...
3
votes
1answer
66 views

When I try to load and edit files in nano or vi, it only creates a new blank file. Why is this?

When I try to load any files in nano or vi, it simply creates a blank [New File]. For some reason it won't load any files I'm trying to edit. I'm at a loss. Why would this be? I open up a terminal ...
0
votes
0answers
48 views

shell expansions while in vim

Being in vim.tiny in command mode and executing some shell command with :!, is there a way that I can benefit from the shell expansions, namely from the filename generation? When I simply enter key, ...
0
votes
3answers
49 views

“grep -Rl” results as vi arguments with proper space support

I am trying to do something like vi `grep -Rl 'keyword'` But I want to support spaces in the file names. vi "`grep -Rl 'keyword'`" Does not do what I need, it turns the grep output in a single ...
0
votes
0answers
60 views

`~/.inputrc` vi editing mode with emacs shortcut keys, `Control-e: end-of-line` not working

I am using Debian 9 with the Bash shell as default. This is my ~/.inputrc file. set editing-mode vi set show-mode-in-prompt on set vi-ins-mode-string "+ " set vi-cmd-mode-string "- " # in vi-command ...
0
votes
3answers
106 views

Error to Create symbolic binary link

I want to create a symbolic link for vi to see this program when calling from console run vim: ln -s /usr/bin/vi /usr/bin/vim` ln: failure to create symbolic link «/ usr / bin / vim»: The file ...
0
votes
3answers
49 views

are there side-effects to remapping/aliasing less to vim?

I added the following to .bashrc to remap less to vim alias vsi='vim -R -c ":map Q :q!<enter>" -' # Vim Standard Input [readonly] alias less='vsi' the reason is that I don't want to maintain ...
0
votes
0answers
22 views

Different behaviours of sudo [duplicate]

I created a file with sudo like this: sudo touch abc.txt Which understandably set the owner to root. Now when I try to edit the file via vi using sudo, it works: sudo vi abc.txt #works But when I ...
1
vote
1answer
269 views

Removing control M characters from a given file and to remove newline character if it is the only character in the entire file

We have a file named as abc.txt and its a empty file. Due to some junk or control M characters, the file size is populated as 5 byte file. In order to have clean file we are using dos2unix command to ...
0
votes
1answer
191 views

Close the file in vim without closing the file explorer

I am browsing the files in vim file explorer by entering vim dirname. Then I am opening the file, saving and closing it by entering :wq. Now the file explorer window disappears. How to prevent this ...
3
votes
2answers
59 views

FreeBSD's vi does not do control-D unindent properly?

I'm on a minimalist FreeBSD system and need to use the built-in vi editor to edit files. To be specific, this is not vim, or vim-tiny or other replacement. It's the "4BSD bug-for-bug compatible" nvi ...
9
votes
3answers
910 views

How to set and determine the command-line editing mode of Bash?

How to set the vi or emacs command line editing mode the Bash AND how to determine which mode is currently set?
1
vote
1answer
83 views

Should I learn to memorize these keys for Vim for moving - h,l,k,j? [closed]

For VIM in command mode, the keys h,l,k, and j are used to move the cursor but I see no point in memorizing these at the moment because when going into insert mode, I use the arrow keys to move the ...
-1
votes
1answer
37 views

Find the pattern in 1 line and replacing in another line

I have some local soft link paths of files as below. ./tech/finegrain/DUALDFTIO/synopsys/DUALDFTIO.TSMC7N.db ./tech/finegrain/ESD18V/synopsys/ESD18V.TSMC7N.db I got original paths till directories ...
5
votes
3answers
802 views

Opening most recently modified file in vim

The following commands work $ ls -1t | head -1 git_sync_log20180924_00.txt $ vi git_sync_log20180924_00.txt But this does not $ ls -1t | head -1 | vi Vim: Warning: Input is not from a terminal Vim:...
0
votes
2answers
194 views

How to search in vim ignoring all whitespace (and making it a function)

How can I search a string in vim and thereby ignoring any whitespace (or particularly line breaks) between any characters? And probably thereby making a function that can search ignoring all ...
0
votes
4answers
42 views

substitutions in vi editor

I have file called foo.txt. This file contains values: abc.tar.gz abc.1.1.tar.gz bca-1.2.tar.gz I would like to get an output like this abc abc.tar.gz abc.1.1 abc.1.1.tar.gz bca-1.2 bca-1.2.tar.gz ...
0
votes
3answers
519 views

Why doesn't root alias vi to vim if it's standard for other users?

On centos (and I believe many other distros) vi is aliased to vim for all users by default. However, for whatever reason vi is not aliased to vim for the root user, something that always annoys me ...
1
vote
1answer
3k views

vi - How go to line N?

In vi editor how do I go to a particular line ? For example if I open a file named file.py is there an option for open the file at a particular line or can I open my file and then go to line with ...
7
votes
2answers
394 views

Find any line in VI that has something other than ATCG

I have a file of genomic data that is approximately 5 million lines long and should have only the characters A, T, C, and G in it. The problem is, I know how large the file should be, but it's ...
0
votes
1answer
71 views

Vi editor message - input encoding conversion not supported

I'm currently using FreeBSD10, when i open a file using vi then a message displays at the end of file- "Input encoding conversion not supported". Is this to warning or error ? Note:- However the file ...
0
votes
3answers
98 views

resume reading a log file from the point I left it last time [duplicate]

I have a log file which is continuously updating(new line added) after few time period. I am fetching only error messages from the file in every 10 minutes. Initially, at 1st time I fetched all line ...
0
votes
2answers
115 views

How can I search matching pattern (stored in a variable) in a file using awk?

I have a log file in which I need to check if there are any error messages, if there are, extract the error message to another file. Like this I may have error file for the different file have ...
0
votes
1answer
63 views

Terminal doesn't understand some easy commands and keeps trying to install package 'sed' after trying to add directory to PATH

Learning linux so I wrote a simple script to test different scripting variables and arguments. Tried adding the directory to my PATH, something went wrong. I can't even use the ls command... I have ...
0
votes
1answer
18 views

Using Script edit the file and replace some variable value

I have n number of servers like: c0001234.cloud.com c0005678.cloud.com c0009123.cloud.com I need to write one script that will login to these servers and edit one file. Basically there is one ...
0
votes
1answer
63 views

Sed conditional removal of EOL [duplicate]

For the following example, where we have "\" at the end, the \ and EOL character should be removed. line 1\ line 2 line 3 line 4\ line 5 Output should be line 1 line 2 line 3 line 4 line 5 Using ...
0
votes
0answers
278 views

Vim color scheme in bash and byobu

I have a problem with the vim color scheme installation. I did the following: 1) a folder was created ~/.vimrc/colors 2) I put the color definition monokai_pro.vim there 3) I edited the file .vimrc ...
4
votes
1answer
111 views

How to delete “undeletable” lines in Vi?

Background I accidentally deleted an important python script, and so I ran the command sudo grep --binary-files=text --context=100 'unique string' /dev/sda1 > recover_file to search for it on my ...
-2
votes
1answer
32 views

What was the general workflow for finding/discovering/editing project files in VI(M) before virtual terminals? [closed]

When asked what is the native "VI(M) Way" to explore a directory tree and view/edit files, it is often stated that one would type the relative or direct path of the file being targeted and open it in ...
0
votes
1answer
375 views

Replacing non printable characters with hex numerical values

I have a badly corrupted Sqlite file The usual trick of dumping everything into a sql file and loading it into a fresh file doesn't work, but with a hex editor I can see that the data I need to ...
0
votes
1answer
373 views

How do I remove a special character in a file?

I had to use OCR to get the text of a very large script I did not want to type by hand. I have multiple lines like this echo "<91>ps <97>eF|grep... It should read; echo "`ps -eF|grep......
1
vote
1answer
33 views

vi with files/directories on the side?

I'm wondering if there's a plugin or a way to make vi/vim have collapseable folders/files on the left side like a regular IDE.
2
votes
1answer
558 views

editing sysctl.conf on oracle linux 7.5

I am going to install oracle database 12c on oracle linux 7.5. In the process, I have to edit following kernel parameters and set values. fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = ...
-1
votes
2answers
6k views

select all text in vi to copy and past in windows

How can I select all text in vi so that I can copy it, and then paste it in notepad on my windows server. I have a file with 3,000 lines in it. I cannot use FTP so I need to copy the text in the ...
2
votes
1answer
178 views

Vim: cw & dw whitespace inconsistency

vim seems to treat whitespace differently when using cw (change word) and dw (delete word). For instance with the example text below, if the cursor is over the letter a and I type dw, it will remove ...
1
vote
2answers
75 views

How to create a script to make a structure and sort files by moving them into directories?

I have a bunch of files which all have a first line being a date. All of them start with the same first 2 letters being "ff". I need to create a script which would use that first line in all files and ...
2
votes
2answers
1k views

Searching for a specific string at beginnning and end of the line in Vi

What command is used to search for a specific string at the beginning of line and at the end of the line in vi editor?
0
votes
1answer
23 views

Second vim split is not being saved

I got two files named as vim1 and vim2. vim1 files has some text in it, but vim2 is totaly empty. I used vim vim1 command to open that file. Later on i write :vsplit vim2 to open vim2 file on splited ...
3
votes
6answers
2k views

How to see which file a user is editing in vi

If I do a w, I can see that a user is editing a certain file in vi. However there are several files with the same name in different directories. How do I see which of these files is the one that the ...
1
vote
2answers
115 views

Why pass the argument to vi as vi itself? [closed]

Whats the reason behind passing the first argument to vi as vi itself like the following: /bin/vi vi Why not just write : /bin/vi The only difference that I have seen between the two commands is ...
6
votes
2answers
1k views

Incorrect UTF-8 accents in vi/vim on OpenBSD 6.2

After a default install of OpenBSD 6.2 with FVWM, I open an xterm on the FVWM GUI, with normal user, create a test file: $ echo 'árvíztűrő tükörfúrógép' > test.txt $ echo 'ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP' ...
0
votes
1answer
2k views

How do I add myself to the sudoers file?

I attempted to add myself to the sudoers file a couple of days ago. I didn't want to have to login into root to do anything so I went into the file and inserted my name under root. Now I cannot use ...
0
votes
1answer
3k views

Tmux command mode - Use vi shortcuts

In bash commandline, you can use vim shortcuts by setting set editing-mode vi in the ~/.inputrc file. I want to be able do the same when typing <prefix>:new to create a new window for example. (...
0
votes
2answers
31 views

linux + file printed with the linux prompt

when we print the file- /etc/hosts.txt we get after the last line the - [root@master02 data]# , why? we try dos2linux , and by vi we not see any charterer after the last line - worker03.yu.com 14.23....
0
votes
3answers
3k views

How to insert and delete text in vi on Debian 9

I have only used vi on Debain 8 before and I was able to press "i" to add any text. Even delete was working fine. But now on Debian 9 it seems vi behaviour is different as pressing "i" nothing happens....