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

learn more… | top users | synonyms

6
votes
1answer
322 views

How to change Vim's command type mode programmatically?

Is there a simple way to switch from one command type mode to another without loosing the current command line? In my ~/.vimrc file I remap the <space> and <c-space> character, coming ...
4
votes
1answer
809 views

Jump between the “if” and “fi” in vim, while editing a bash script?

Just like you could jump between pairs, i.e (), can I extend this feature to jump between beginning tags and ending tags? i.e in bash, jump between if and fi
6
votes
4answers
1k views

How to search the current word in all opened tabs in Vim?

I have started learning Vim word-search using * and # while the cursor is over the current word. But this search is limited to the current file buffer. Is there a command or a shortcut to extend this ...
0
votes
3answers
3k views

vim backspace not working normally

The Backspace key is not working as expected in vim and also in vi. It is working as the Delete key, and Delete key is deleting the char, but instead something wierd happens. But, for now, I am trying ...
3
votes
1answer
1k views

Saving with CTRL-s in vim

I have added this line in .vimrc so that pressing control-s saves the current file :nmap <C-s> :w!<cr> :imap <C-s> <esc>:w!<cr> But this is not working. Any ...
0
votes
1answer
401 views

Pretty print in VIM?

I have few lines that each of them are colon separated values, abc:def:3 Now I could do the reformat with printf plus IFS variable, while read line; do IFS=":" printf "%-20s %-16s %5d\n" ...
3
votes
4answers
243 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 ...
6
votes
1answer
1k 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 ...
3
votes
2answers
163 views

How to add a line in many files

I have many .html files and I need to add a meta tag after <head>'s start tag in each file. How I can do that? Can vim help me?
3
votes
1answer
380 views

Clipboard over SSH session through VIM

I have a server running SSH, when I edit a file with vim on the remote server, :y+ doesn't work since the VIM binary on that linux system wasn't compiled with X support. (E488: Trailing characters) ...
7
votes
3answers
639 views

Vim to print file on terminal and exit

I would like vim to do this in order to have syntax highlight as set up in vim (or without need for extra tools). So instead to use cat file | <some_sh_tool> I would use vim +"some_opts" +"..." ...
5
votes
1answer
1k views

How to automatically refresh Vim on buffer/window focus?

I often use Control+L to redraw the screen in Vim. In particular, when I come out of sleep or change monitor configurations I often find that Vim needs to be redrawn. I thought it might be simpler to ...
35
votes
3answers
2k views

How does vim steal root owned files?

Witness the following: sh-3.2$ mkdir testcase sh-3.2$ cd testcase sh-3.2$ sudo touch temp sh-3.2$ ls -al total 0 drwxr-xr-x 3 glen staff 102 19 Dec 12:38 . drwxr-xr-x 12 glen staff 408 19 Dec ...
10
votes
2answers
4k 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 ?
2
votes
4answers
411 views

Remove large chunks from json using vim

I have a huge file (1/2 million lines) of json. I need to delete a set of entries that contain a certain string. { "bla1": { "Part1": "Plop1", "Part2": "Plop2", "Part3": ...
3
votes
1answer
279 views

How to reference a script-local dictionary in a Vim mapping?

Somehow I'm not able to execute the following mapping: function! s:MySurroundingFunctionIWantToKeep() let s:Foobar={'foo': 'bar'} map \42 :echo <sid>Foobar.foo<cr> endfunction call ...
1
vote
1answer
371 views

Reassigning Ctrl + Arrow keys in Vim [duplicate]

Possible Duplicate: How to fix Ctrl + arrows in Vim? Through the several tutorials and tips and tricks site about Vim, I think I happened to read that one can reassign a combination of keys ...
2
votes
3answers
944 views

How to reverse-match a string in the Vim programming language?

I want to find the last index of any character in the [abc] set in the abcabc string but the search should start from the end of the string: " Returns the 0th index but I want the 5th. let ...
3
votes
1answer
1k views

How to fix the shifted function keys in vim in xterm in gnome-terminal?

When I hit the <s-f2> key to execute my nnoremap <s-f2> :set number! mapping Vim opens its "Insert" mode above (O) and types the 1;2Q string. In order to see the entire terminal key code – ...
3
votes
1answer
163 views

How to display the permissions of a new file in the status line of the Vim editor?

With the following piece of code I get the permissions for an existing file: augroup Get_file_perm autocmd! autocmd BufWinEnter,FileChangedShell * let w:file_perm=getfperm(expand('%:p')) augroup ...
5
votes
2answers
2k 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 ...
1
vote
2answers
932 views

Loading a color scheme has no effect in Vim

I had selected some really smart looking color schemes for Vim here Following the instruction inside those files I've copied them in my $VIMRUNTIME/colors directory. When Vim is launched in normal ...
2
votes
1answer
176 views

Insert newlines with vim

How to insert newlines in vim? For example in a file containing test-classes; classes; xmlunit-1.3.jar I am looking for the vim equivalent of sed command sed -i 's/; /\n/g' classpath to obtain ...
11
votes
2answers
2k views

Modeless vs modal editors

I just started learning Linux and all my previous experience of programming has been using the Windows platform. I came across Vim editor and read that it is modal editor unlike notepad which is ...
7
votes
4answers
1k views

vim insert current filename into the contents

After some searching, I got to know :echo @% display's the current file-name in the bottom line of vim-screen. I would like to dump the file-name(with and without full path) into the contents of the ...
14
votes
8answers
759 views

Suggested setup for an ultra-lightweight text-based programming environment in linux

I am looking for suggestions for a setup for my particular needs. I haven't done much linux since college and want to get back into it as a hobby. I have some not-too-powerful hardware (512 MB ram, ...
4
votes
2answers
949 views

How to enable vim addon packages?

I have installed vim-nox as well as vim-latexsuite and vim-outliner on Ubuntu 12.10. There's nothing wrong with Vim but neither of the add-on packages does anything. What do I have to do to in order ...
15
votes
5answers
2k views

Automatically create matching braces in vim

How do I automatically create matching braces in vim? It should work as follows: If I input an open brace the closing one should appear automatically and the cursor should be placed in between. To ...
3
votes
2answers
2k views

In Vim, how can I delete all text from the current cursor position until the next space?

In Vim, I know 'd$', that deletes everything to the end of line. But how can I delete all text from the current cursor position until the next space? dw doesn't work, since it treats symbols like ...
4
votes
1answer
263 views

vim auto complete custom list

I had these two questions about this function " how do I load a file into a list here? " set some variable func! CustomComplete() " and then read the variable here so that b:list = a \n split ...
7
votes
2answers
1k 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 ...
1
vote
0answers
106 views

Vim R plugin installation problem on Ubuntu in Android phone

There was another thread on vim-R-plugin but since it was bit old, I started this new thread. Also my situation is kind of different, since I am trying this on a mobile device, Samsung vibrate. I ...
12
votes
2answers
8k views

How do I cycle through panes inside a window in tmux like in screen?

I thought Tmux - move window to pane was the same question but it doesn't seem to be. Coming from using GNU screen regularly, I'm looking for tmux to do the same things. On of the things I do ...
1
vote
1answer
217 views

map “Ñ” to “:” in vim

I want map the key Ñ (Shift+ñ) to : in the normal mode of vim. I've searched vim configs with Ntilde but I've found nothing. Any idea?.
2
votes
5answers
115 views

vim automatic substitution

I have the following lines: '0, '1, '2, '3, How to put quote before the comma? I've tried the following so far: %s/[0-9],/&/g so & here replaces the matched pattern...
2
votes
1answer
105 views

Avoid a prompt about change file mode in a Vim script

I'm trying to make every file that start with shebang to be executable by default, so I use the following line in my vimrc, au BufWritePost * if getline(1) =~ "^#!" | silent !chmod a+x <afile> ...
2
votes
1answer
593 views

Solarized color definitions in vimrc file

The solarized theme defines some base colors and assigns those to variables, as seen here. I would like to know how I can use these color definitions in my .vimrc file. Currently, I use pathogen to ...
27
votes
1answer
9k views

What's the recommended way of copying changes with vimdiff?

When comparing files, and updating a source code repository, I like to use vimdiff. To copy changes made from one file to the other, I usually use a key sequence like this:- Shift + V (select line) k ...
2
votes
2answers
57 views

Can't do backward search with big N in vim, some plugins override it

I just found I couldn't do the backward search with N anymore, it looks like to be overridden by some other plugins, Not sure how that happened, how do I find out which plugin got this?
3
votes
2answers
185 views

Vim colorize edit mode

I'm trying to tailor vim to my needs and I would like vim to visually indicate when it is in some kind of edit mode (insert/replace) by, for example, coloring the background red. Is there any way to ...
9
votes
2answers
11k views

How to compile a c program without leaving the editor? [duplicate]

I am using vim editor on Linux mint. I want to know if there is any way to compile c program without leaving the editor.
4
votes
4answers
604 views

Export terminal display to PDF

I want to include the display of my terminal in a beamer presentation. Simply taking a screenshot, however, produces a fairly low-resolution png that looks poor in the presentation. I would like it ...
6
votes
3answers
3k views

vim: How to switch to the directory listing from file view?

I have opened a dir vim some/dir. I can navigate within the tree, yet once I opened a file I wonder, how do I close the file view in order to go back to the directory listing to navigate to another ...
1
vote
1answer
53 views

Vim, netrw plugin tmp files not uploaded at server

If I connect via sftp with netrw plugin and open the file, filepath looks like sftp://.. In current session if I close this file and reopen it, netrw loads file from /tmp/.. and after saving this file ...
3
votes
1answer
524 views

vim latex: disable quickfix

How can I disable latex's quickfix feature when editing tex files (having vimlatex installed). But I want to keep it for any other language… Pretty sure this is just a small flag, didn't find it ...
2
votes
1answer
890 views

Can't use mouse properly when running vim in tmux

I'm running VIM in tmux, When I'm try to select a range of texts in VIM, the mouse kept resetting its position, thus I can only select one line (the last line where mouse occurs). Does anyone know ...
6
votes
1answer
1k views

Only one file name allowed error

Sometimes I forget to do sudo vim and open files to which I don't have write permission. I saw this post and it was really helpful. When I did :w !sudo tee % it asked me for a password and then the ...
3
votes
2answers
141 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
269 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 ...
10
votes
2answers
1k views

vim - open file and goto line number using <filename>:<line nbr>:

Several tools such as grep, py.test, etc ... use the pattern <FileName>:<line number>: to point to errors. For example: ; grep -Hn Common setup.cfg setup.cfg:11: Common How can I ...