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

learn more… | top users | synonyms

5
votes
1answer
2k views

vi[m] read range of lines from another file

On Linux, editing file_B in vim I want to add line 10-25 from file_A. Example: One has a whole set of HTML-Documents with quite the same header and yes, one could create a template and start from ...
0
votes
1answer
57 views

How can I hook functionality to the “go to line”-command in Vim?

I just got the idea that I wanted to make it so that Vim centered around a line when I jump to it. Is there a way to make zz be executed automatically after I have called the colon command followed ...
1
vote
2answers
1k 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 ...
3
votes
1answer
5k views

How do I highlight the current line and the cursor in .vimrc?

I am trying to highlight the current line as well as the cursor position in Vim. Here's my .vimrc: set cursorline hi CursorLine ctermbg=8 ctermfg=15 "8 = dark gray, 15 = white hi Cursor ctermbg=15 ...
0
votes
1answer
334 views

Why is vim offering me spelling suggestions instead of using the completefunc?

I am trying to set up vim for writing email. I have a plugin to provide autocompletion of email addresses (notmuch abook ). If I do :set completefunc it tells me it is CompleteAddressBook as ...
1
vote
1answer
171 views

Comment the if statement and the matching endif keyword

In vim, I can find the matching if statement and prepend the appropriate comment symbol. (e.g. %s/.alarm./#\0/g), but then I am left with dangling endifs that I have to find manually. I could simplify ...
1
vote
1answer
27 views

Is it possible to affect the behavior of all vim commands in normal mode?

Is there a way to affect the behavior of all vim normal-mode commands? Say, after every command succeeds, I want to trigger some post-behavior.
2
votes
2answers
240 views

Live diff-mode editing in vim

I want a live view of diffs while I am editing a file. vimdiff is able to do something I want, like highlighting the differences between two files. However there are two drawbacks of vimdiff that ...
2
votes
3answers
376 views

Open multiple files in Vim with a filelist

I have a file 'filelist' that contains the following lines: text1.txt text2.txt text3.txt I am looking for a command line invocation that opens the 3 files in vim. I tried the following: $ cat ...
49
votes
2answers
23k views

Ctrl-s hang terminal emulator?

I came across a sentence in vimdoc: Note: CTRL-S does not work on all terminals and might block further input, use CTRL-Q to get going again. and this key indeed hangs my vim. I was ...
2
votes
1answer
2k 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 ...
2
votes
2answers
2k 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'
2
votes
2answers
1k views

gvim colors the same as is the terminal

Is there a command I can put in the .vimrc to make gvim look like vim's setup in the terminal? Same back ground, syntax highlighting, colors, and font. To add to my question, is there a may for gvim ...
2
votes
1answer
243 views

Autocompletion of email addresses in vim

I'm playing around with various bits of an email solution, including notmuch and alot. I write my emails in vim and I'd like to have tab completion of email addresses while writing email. Is there a ...
1
vote
2answers
77 views

What are some ways to compare file type and encodings to resolve buggy grep…?

In this case I have a folder of .txt files I created using drag and copy and paste from Adobe Acrobat PDFs and Text Editor in OSX. I've been editing these files in vim. Now I'm using grep to find ...
2
votes
1answer
356 views

Is there a file menu plugin for vim (not gVim) that creates a text-based GUI menu system?

I'm curious to see if there are any plugins that create a menu inside vim (not gVim). Perhaps something simple like a menu bar at the top, with drop down menus that are drawn with text. EDIT: The ...
9
votes
5answers
11k views

How can I exit from read-only mode in Vim?

I opened a file in readonly mode; is there a way to get out of readonly mode?
0
votes
0answers
42 views

screen flashes when I press ^S in gvim

I bind ^S in gvim, by: map <C-S> :w<CR> Now if I press the ^S combination, althrough file is saved (I saw the XXX written message), but gvim window flashes, is there a way to avoid that? ...
2
votes
1answer
100 views

Convert table in LaTeX

I copy the table from Calc (or Tracker) In my research I know three ways: 1: Record a macro: @a0f cw & <ESC>;.;.I\hline <ESC>A \\ (the spaces count ;) ) And then VG:normal ...
2
votes
1answer
115 views

Vim :fold of python code not different to C/C++ code

When I enter the command :fold inside my python code in .py files, Vim inserts the /*{{{*/ and /*}}}*/ tags. They, of course, cannot be parsed by python interpreter. When I'm in python I would like ...
3
votes
1answer
87 views

Switching to edit mode in VIM rc?

Still related to the previous question, but switching mode with exe "a" doesn't seem to work, I still have to press the a button manually Here upon opening a newly created a file, a template is in ...
1
vote
1answer
60 views

Jump to the first position of text “<CURSOR>”

I'm using a file template directory for newly created files, autocmd! BufNewFile * silent! 0r ~/.vim/skel/tmpl.%:e Now I want to add another function, that move the cursor to somewhere (defined in ...
1
vote
2answers
766 views

No syntax highlighting when editing crontab

I am trying to figure out why I don't have syntax highlighting when editing my crontab. I have both $EDITOR and $VISUAL set to /usr/bin/vim: > echo $EDITOR /usr/bin/vim > echo $VISUAL ...
5
votes
3answers
2k views

Can't open syntax.vim error when using vimrc

When I try to open my .bashrc file. then it shows these lines: Errordetected while processing /etc/vimrc: line 45: E848: Can't open file /usr/share/vim/vim70/syntax/syntax.vim Press ENTER or type ...
5
votes
6answers
9k 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?
1
vote
2answers
53 views

Adding a line in vim adds it at the line after the cursor, I would like to insert

I have this keybinding in .vimrc: map + :put=''<cr> map - dd I find it really useful for fast layout and source file cleaning with + and -. But using :put=""<cr> adds a line after the ...
2
votes
2answers
348 views

Seeing scons file like python file in vim. File dependent properties

I know I can setf python and then the file is recognized as python. However I must redo this everytime I reload the scons file. I have read some weeks ago that one could write in the last lines of a ...
5
votes
2answers
2k views

exact match in regrex when using vim, man, or less

when using vim, man, or less, I want to do some exact match in regrex for example, when using man, I want to check the argument '-c' if I use /'-c' the matching could be -cim ...
2
votes
3answers
101 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" ...
21
votes
2answers
23k views

How do I get the solarized colour scheme working with gnome-terminal, tmux and vim?

There's a lot of questions around this, but it's because there are so many variables. I had to piece together instructions from many sites before I got this working. First, I could not easily set up ...
1
vote
2answers
162 views

How can I load the right hand pane of vim with a new file in linux?

I want to compare two files(say A and B) side by side(vertically) in in Vim. I open one of those two files(say A) and as per this answer in this site issue a Ctrl+w v . Now both the panels are showing ...
6
votes
2answers
672 views

Remove all Vim undo files in all but one directory

I just realized that I have tons of Vim undo (.un~) files sprinkled around my file system. I'd like to delete all of these files except in one directory—~/.tmp. My first problem is that I can't seem ...
2
votes
1answer
60 views

Manipulate color in VIM

In hlsearch mode, seems that you can set only one color. Now I want to use a script to get multiple colors for multiple keywords, is that possible?
0
votes
1answer
233 views

Vim - Tabs in :o Show up as ^I and Autocomplete Does Not Function

The title basically says it all - in Vim, my tab's show up as ^I, and I'm wondering if anybody knows why this might be. This is especially annoying when using :o to open a file, as the autocomplete ...
0
votes
1answer
77 views

Select line not selecting whitespace

Is there a way to select (or paste) text without trailing/ending whitespace? eg. To copy the whole line I press y, to paste it somewhere else I use p, but it pastes the whole text with the trailing ...
0
votes
1answer
92 views

Automatically insert fold tags around visually selected text in vim

I have started to use set foldmethod=marker, because I find it more convenient to use rather than syntax. But it has the disadvantage of needing to write // {{{ my title and // }}} around any ...
4
votes
1answer
203 views

Different vim colorscheme depending on mode

I'm often doing the same mistake in vim: I forget whether I'm in insert or command mode, then I type in, I get random commands or I modify/delete code, and I have to undo. I do this mistake really ...
2
votes
2answers
72 views

Is there a way in vim to know I am in the left most split?

I want to detect whether or not I am in the right most (or left, top, bottommost) split. In other words, when ctrl-w h would do nothing. Is there a way to do that?
1
vote
1answer
978 views

vim install on freebsd has taken 5 hours and counting

Ok, so installed portmaster and I'm trying with it, I'm hoping it won't take time. So I've been up all night and my vim installation is still going on. I have an amazon ec2 freebsd server setup. I ...
4
votes
1answer
222 views

lsof doesn't return files open by the same user

Consider this simple scenario: I open a text file ~/textfile.txt with vim in one terminal (tried with both edit and read-only modes). In a different terminal, I run /usr/sbin/lsof ~/textfile.txt ...
0
votes
1answer
628 views

Changing color of tabs titles in vim color files

In my custom color.vim file there are multiples entries like these ones: :hi VertSplit gui=none cterm=reverse :hi Folded ctermfg=grey ctermbg=darkgrey :hi FoldColumn ctermfg=4 ctermbg=7 :hi IncSearch ...
2
votes
2answers
1k views

How do I get pkg_add to look in the correct directory on the remote ftp repository when installing vim?

I have a brand new clean installation of FreeBSD 9.1 on Virtualbox. Running pkg_add -r -v vim, the terminal runs an ftp script to: ...
2
votes
2answers
633 views

.exrc file in home dir not effective

I made a simple .exrc vim config file in my home directory on RHEL 5.8. Here are the contents: set nu However, when I go into vim, the line number are not shown. It may be worth noting that I am ...
1
vote
4answers
88 views

Editors Nano/VIM not using resources

Does anyone here know the resources it takes for editors to search and replace in a large file? The reason I am asking, is I have a 32 core server that HTOP is only showing one core at 100% when ...
3
votes
3answers
213 views

File goes missing for a short period of time after saving it using VIM

I am having a strange problem that seams to be caused by VIM, the Linux VFS cache, ecryptfs and/or something file system related: I open a file in VIM, modify it and save it. I try to access the ...
2
votes
1answer
155 views

How to reload a file in vim?

Various editors like gedit detect if the file is changed and asks to reload it. Sometimes in vim when I got many files to edit, I sometimes end up opening same file in different tabs for quick look ...
3
votes
1answer
1k views

ls and vim color on SunOS 5.8/Solaris 8

I want to use ls and vim with color on Sunos 5.8 SunOS 5.8 Generic_117350-11 sun4u sparc SUNW,Sun-Blade-2500 I have installed ls (GNU coreutils) 6.9 and vim 7.2 In ~/.cshrc: setenv TERM sun-color ...
1
vote
2answers
113 views

Cron creates vim process but does not display vim

Under MacOSX 10.8.2 I am able to run vim as follows in the bash shell: /usr/bin/vim -c "normal G" -c 'startinsert' ~/.journal If I put the exact same command in a script: #! /bin/bash export ...
2
votes
1answer
393 views

Launch R code from within vim-r-plugin as separate window instead of inside tmux/screen?

I use the vim-r-plugin to write R code in vim. It is a nice plugin and I love that the plugin lets me run code directly from within vim. However, the R prompt is opened in a console which is ...
1
vote
1answer
50 views

Replaced matched text in Vim with pattern

Here's a minimal example of what I'm trying to do. Start with: "this") "that") [hundreds of lines like this] End with: "this",&this) "that",&that) [hundreds of lines like this] I have gotten this ...