vi

Move entire line up and down in Vim

In Notepad++, I can use ctrl + shift + up/down to move the current line up and down. Is there a similar command to this in Vim? I have looked through endless guides, but have found nothing. If there isn't, how could I bind the action to that key combination? Edit: Mykola's answer works for all lines, apart from those at the beginning ...

How do I prevent the vim from using the wrong viewport after the :make command?

I often have multiple viewports opened in vim, using the :vsp and :sp commands. After I've been editing for a while, I'll often run the :make command from within vim. When I get errors, vim will then show me the lines that gcc says caused my errors. However, vim will often open the file with errors in another viewport, even if that file ...

VIM Key map

HI, Im beginning VIM. I hate pressing the Esc command, which is a little far in T61, in order to return to command mode. How do I map it to F4? ...

Is it possible to use vim with the mouse

Is it possible to use vim with the mouse? If so, how? ...

Find and Replace within selection in `vi`

How do I do a Find and Replace within a selection in vi? ...

Columns in VI

I have a bunch of lines that I'd like to split into two columns, and get the data from each column. The data looks something like this: current_well.well_number current_well.well_name current_well.well_type_code well_location.section well_location.range Essentially what I'd like to do is split the line based o...

How do I "source" something in my .vimrc file?

I've been working on expanding my vim-foo lately and I've run across a couple of plugins (autotag.vim for example) that require them to be "sourced" in my .vimrc file. What exactly does this mean and how do I do it? ...

Linux vi arrow keys broken in insert mode

My arrow keys don't work in vi in insert mode at home, they just each insert a newline and a capital letter, like 'A'. Is there a way to fix that? ...

How do I tidy up an HTML file's indentation in VI?

The other day my friend asked me how to fix the indentation of his huge html files which was all messed up. I tried the usual "gg=G" command, which is what I use to fix the indentation of code files. However, it didn't seem to work right on HTML files. It simply removed all the formatting. I also tried setting :filetype = xml, to see...

Using VI how can I search and replace for the following statement?

I need to replace the following: CREATE TABLE /*!32312 IF NOT EXISTS*/ `access` to CREATE TABLE IF NOT EXISTS `access` I've tried :%s/\/\*\!\d+(.*)\*\//\1/g But that didn't seem to go. What am I doing wrong? ...

Making Vim ubiquitous?

The Pragmatic Programmer recommends that you should use one text editor for everything. My chosen weapon editor is Vim. So I want to collect all the ways in which Vim (and the Vim keybindings) can be used and setting up your computer to make Vim work well. This includes how to embed Vim in your IDE, web browser, email client, command sh...

vim - yank entire file

I often write something in gvim, then need to copy-paste it into another application. Is there an easy way to yank the entire file? I usually do something like this, but is there a better way that I'm missing out on? ggVG"+y (Go to top, visual-line mode, go to bottom, yank) ...

Replace text from line above in Vim

How can I replace the first ten characters of a line where those ten characters match a particular pattern with the first ten characters from the line above? Edit: It wasn't clear if I was asking to replace the first ten characters where the match could appear anywhere within the line, so maybe make a note in your answer if it deals wit...

Hide all (not)matching lines in VI(M)

Is it possible to show/hide all matching lines in vi or vim? Not highlight but just show only that lines. For example I have a text with ERROR word. How to show only lines containing ERROR and how to show only lines without ERROR ? Is there a solution without deleting all matching lines and than just undoing this? ...

How to avoid indentation error after changing tab stops in Vim?

I used to have 8-space tabs in Vim. Then I changed to 4 spaces, but now whenever I add a line to some code I had written before changing to 4 spaces, it gives me an indentation mismatch error even though everything is lining up nicely. Is there any way to avoid this problem? ...

in vim, how to set "args" to the result of a "grep -l"?

To illustrate, here's how to do it from the command-line: vim `grep "hello" * -Rl` This opens vim with all the files that have "hello" in them (-l gives the filenames alone). I want to do the same thing, but from within vim. Conceptually, something like this (which doesn't work): :args !grep "hello" * -Rl I'm open to completely di...

in vim, how to append/insert text with argdo?

There's the ":a" command, but that's multi-line, and argdo asks you for the text again for each file. The docs mention the global command (g/pat/command) that will use an alternative version of ":a" that is terminated by a newline instead of by "." on a line (you can include newlines by escaping them with "\"). But I couldn't get this ...

vi search copy paste search copy

Hi, I was just wondering if anyone could help out with how to do the following using vi. I have a text file and it might contain something like start of text file: --something1.something2-- --anotherThing1.something2-- end of text file: If I want to take this line and convert it by way of searching for anything matching the first oc...

Omit 'Pattern not found' error message in Vim script

I added a function in my .vimrc that's just few search and replace commands. However if one of the patterns is not found I get an error message that I need to enter through. How can I suppress this? ...

VIM Background

When I am trying to change background in vimrc or directly in vim using set background=dark it doesn't affect my background at all, same with light option, however it looks okay when I run gvim. Is there a way to change background in vim without changing my Konsole settings? Thanks. UPD: Okay there is a difference between guifg/guibg an...