Tagged Questions
3
votes
3answers
56 views
vi: backspace in insert mode not erasing characters
I am new to vi, actually I have started learning vi from today and I have got stuck at the behavior of the backspace key. Actually when I fired up vi on my Ubuntu 12.04 for the first time my backspace ...
3
votes
3answers
99 views
vi / vim - how to automatically strip trailing spaces on save?
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
0
votes
1answer
55 views
vi / vim - extra indents when pasting text? [duplicate]
I can copy characters in other apps such as browsers with ctrlc.
I can then press i to enter insert mode in vim and press shiftctrlv to paste the text in.
The problem is that each line gets indented ...
3
votes
2answers
47 views
vim shortcut to open a file under cursor in an already opened window
In vim you can open a file under the cursor by using the gf command.
One can also easily open that file in a new split window by hitting <c-w> f. This is a really nice and time saving feature. ...
1
vote
2answers
92 views
How can I set “vi” as my default editor in UNIX?
I believe I can do something like export EDITOR=vi, but I'm not sure what exactly to enter, and where.
How can I set "vi" as my default editor?
1
vote
2answers
53 views
How do I set vim as the default editor when I sudo?
I'm working on a CentOS 5.9 machine, and I simply want to type
sudo vi somefile
and have my trusty vim with syntax highlighting, etc. This seems simple enough, but after many attempts, it's ...
2
votes
1answer
72 views
Vim - how to increase each number in visual block?
I have the following SQL:
update am.PERMISSIONS set PRM_ORDER = 35 PRM_VISIBLE = b'1' where PRM_ID = 3;
update am.PERMISSIONS set PRM_ORDER = [35] PRM_VISIBLE = b'1' where PRM_ID = 7;
update ...
1
vote
2answers
76 views
How do I set bash aliases and variables from within vim?
In cmdline mode, the following examples do not work for me.
!alias lol='echo lol'
!lol='echo lol'
5
votes
6answers
171 views
How to select complete file in vi, to be pasted in gedit?
I know that doing %y a will yank complete file into register a. However this doesn't help in pasting the file content in another text editor (say gedit). What alternative is there for doing so?
2
votes
3answers
70 views
Ctrl+W in vi[m] to erase to whitespace
I want to mimic the functionality of bash readline in vim. Is there an easy way to do that?
Currently in vim Ctrl+W "cuts" from cursor back to special char or whitespace.
ie. In bash Ctrl+W "cuts" ...
2
votes
4answers
113 views
What are some of the main differences between vim and vi?
What are a few of the main differences between vi and vim? Are there any significant keyboard shortcut differences, any features that one has that the other does not? Yes, I do know that I asked ...
7
votes
1answer
140 views
Vim: Making XML text “pretty”
Is there an easy way within vi to make your XML text "pretty"?
For example:
I want this..
<person>
<name>Nick</name>
<age>26</age>
...
0
votes
1answer
138 views
Write out without quitting in Vim?
I looked through the vim manual, and I could only find the commands for "write and quit" and "write (if edited) and quit". Is there a command for "write out without quitting", similar to ^o in nano?
16
votes
6answers
1k views
Vi vs vim, or, is there any reason why I would ever want to use vi?
I know a bit about *NIX text editors (currently migrating from nano to vim), and, after looking around a bit on the Unix & Linux SE, have noticed that a fair about of question use vi instead of ...
2
votes
4answers
113 views
Disable vi from going to the last visited line upon file opening
Is there something I can put in my exrc file to prevent vi from going to the last line I was on last time I had the file open and just set the cursor at the top by default?
I think it is ...
3
votes
2answers
229 views
Globally replace Vi with Vim on Fedora
On Debian-based systems the alternatives system handles both the vi and vim executable. So if vim is installed and you execute vi, you also get vim, which I find very nice, because I absolutely hate ...
5
votes
2answers
289 views
Does using ctrl+c instead of esc to exit insert mode break anything in vi?
When using vi, you can exit insert mode with Ctrl + C instead of the more traditional Esc. Are there any situations where it would be undesirable to use for former instead of the latter? Does it break ...
3
votes
2answers
75 views
Shortcut for tabn & tabp in vim/vi
When I open several files using vim+tabf, switching across the files will involve using tabp & tabn.
Can I have a quicker way to do so?
1
vote
2answers
135 views
concat file content horizontally in vi/vim
I have a text file that contains a big matrix, that columns are split like the following example:
col1 col2 col3
row1 .. .. ..
row2 .. .. ..
row3 .. .. ..
row4 .. .. ..
row5 ...
4
votes
2answers
125 views
vim customized with emacs commands (insert mode only)
I was an emacs user, and I have to switch to vim. But I miss some basic emacs commands in vim insert mode:
C-A
C-E
C-K
C-Y
C-x C-s
... and some other
I know that I can press Escape and then press ...
6
votes
1answer
194 views
How can I switch 2 characters in vi?
I like the fact that I've memorized ddp for switching two lines (i.e. dd deletes the line and then p puts it back '1 higher').
Is there are similar set of keystrokes for switching 2 characters so ...
2
votes
1answer
61 views
Finding parentheses with % in vim across lines
In the following text block, starting at 1 or 3, and pressing % in normal mode in vim, finds the pair of matching parentheses, and toggles between them if you press % again. Starting at 1 finds the ...
17
votes
9answers
986 views
Bash commands inside vi
Is it possible to type a bash command inside vi and get the stdout?
I find it often tedious to close and reopen vi just because I want to look something up in the shell.
2
votes
5answers
633 views
Comment all lines in a text file?
In a text file I need to comment out all lines by adding a ";" as first character of each line. What is a good way to do this? I thought of Vim's visual block mode, but I couldn't find a "select all" ...
0
votes
1answer
59 views
How do I get bcvi installed and working (with Cygwin and Perl 5.8.8)?
I'm trying to install bcvi (under Cygwin), and there are apparently no directions that apply to this setup. The directions at http://sshmenu.sourceforge.net/articles/bcvi/#installation state that ...
3
votes
3answers
274 views
vi/vim, how can I write out a number of lines to a new file
I have a bunch of lines that I want to write out to a different file.
How can I do that?
15
votes
6answers
1k views
Using VI to edit shell commands in UNIX
I used to have a co-worker who was really good at UNIX.
He showed me how to use Vi to edit my shell commands.
He placed the command in a file that ran every time I logged in.
Since then, I've ...
4
votes
1answer
104 views
vim: how do I set :match and :2match search results to different colors?
For example, I want something along the lines of:
:match search /<div/ guib=Green
:match search /<\/div>/ guibf=Blue
only that doesn't work.
2
votes
1answer
130 views
Beep when typing backslash in cvim normal mode
I installed the cvim plugin for vim.
Almost all the cvim commands start with '\'.
But I when enter this character in normal mode, all I hear is a beep. Nothing happens. What might be causing this ...
7
votes
2answers
642 views
why inode value changes when we edit in “vi” editor?
When I edit a file in "vi" editor the inode value of the file is changing. But when edited with cat command the inode value is not changing.
2
votes
1answer
871 views
Replace using VIM, reuse part of the search pattern
I am working with VIm and trying to set up a search and replace command to do some replacements where I can re-use the regular expression that is part of my search string.
A simple example would be a ...
6
votes
2answers
743 views
How different is Elvis from Vim?
I've been using Slackware for a while now, which ships with Elvis as its default editor.
Most other Linux distributions seem to ship with Vim, instead of Elvis. Having gotten quite used to Elvis, ...
12
votes
2answers
2k views
What is the difference between vi and vim?
As far as I know vi is more commonly found on out-of-the-box unix systems while vim often has to be installed. Also vim stands for vi improved, but improved how?
What are the main differences?
8
votes
3answers
1k views
Advantages of using set -o vi
I have seen many developers using this command to set the option to vi. I never understood the real use of this?
When using bash commands, what help does switching to vi provide?
5
votes
3answers
258 views
Search and replace next n words in vi [duplicate]
Possible Duplicate:
Vim :s replace first N < g occurrences on a line
In vi, how do I search and replace a word's first n occurrences with a word, say "hello", and the next m occurrences ...
8
votes
4answers
362 views
How can I paste (overwriting) with vim?
In vim I use yy and p all the time to yank and paste lines. However, if I want to replace one line multiple places in the file, I can't use yy p dd p because the dd deletes the line to the clipboard ...
3
votes
5answers
383 views
vi - how to join differents specific lines
I'm looking for a solution about a "paste" problem on vi/vim .
How to join specific lines in a text file? I have a file like this:
15/10/2011 Revolution day
16/10/2011 About Rome
- differents ...
2
votes
1answer
100 views
How to open a file in the last closed position in VI
I want to open a file which is closed in line xxx. So I can easily continue editing
5
votes
1answer
3k views
Switch VI to use backspace key instead of Control+H for backspace?
I'm on Solaris 10 and by default vi version SVR4.0, Solaris 2.5.0 is installed.
The system was set up so that when I ssh to it Control+H does backspace, and backspace outputs ^?
I added stty erase ...
1
vote
5answers
1k views
How can I check what version of the VI editor I have?
How can I check what version of the vi editor I have? What's the best way to upgrade it or install vim on Solaris?
7
votes
1answer
354 views
Note-taking and outlining using Vi: On startup, highlight tags and display tags in a preview window
I am using vi as a note-taking and outlining tool and therefore I thought that this stackexchange site would be appropriate to ask this question. I am constructing the "tags" file by myself. What I ...
2
votes
1answer
163 views
Vi: On startup, highlight tags and display tags in a preview window
I am using vi as a note-taking and outlining tool. I am constructing the "tags" file by myself. What I would like to do is that when I open my notes or
outline file, vi reads the tags present in this ...
3
votes
1answer
226 views
Select between given characters in vim
Given three sample lines:
some('lorem _ ipsum');
$some['lorem _ ipsum'];
<span class="some _ class">
(cursor is in _ position)
Which is the fastest way to select (for pasting in other ...
1
vote
1answer
236 views
How to set keycodes manually in vim?
Sometimes when I fire up vim, my Insert key doesn't work (need to use i) and my arrows don't work (they give me letters instead).
I'm guessing this has to do with my keys not being mapped correctly. ...
2
votes
1answer
140 views
Why does Vim have different cursor positions for different modes?
Why does vim have different cursor positions for the different modes? First, in insert mode, the cursor is between characters (like every other editor), second, in command mode, the cursor is under a ...
6
votes
4answers
512 views
Indent several lines with VIM?
For eample, I'm editing this code:
<html>
<body>
<script>
var a = 10;
a += 100;
</script>
</body>
</html>
now I need to indent the script line:
...
7
votes
2answers
161 views
How do I get just the user-manual for Vim
To get the vim user-manual I am doing
vi test
and then, once the file is opened, I do
:help user-manual
This opens up a split window, which makes reading manual inconvenient to read. How do I ...
3
votes
5answers
2k views
vi command for adding blank line?
In vi, I can use o or O to add a blank line and go into insertion mode. But what if I want to stay in command mode, is there a command for this?
In googling, I'm seeing suggestions to add stuff to my ...
20
votes
3answers
2k views
Why does `ESC` move the cursor back in vim?
In vim, when I hit ESC to return to command mode, the cursor moves one character to the left. This is not what I would hope for, occasional I immediately hit l to move back to that spot, perhaps to ...
6
votes
4answers
2k 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 ...


