vi

Remove colon using VI

Hi, I am trying do a find and replace in VI to remove a timestamp. I usually do this in VI using the S command but how do I tell VI I need to remove colons when its part of the structure of the VI command itself EX: " xxxxx xxxxx 24:00:00 CDT" tried s:24:00:00 CDT::g s:"24:00:00 CDT"::g s:/:::g Any assistance is appre...

vim / vi / linux: properly indent html file

how can I easily indent html files with linux or vi or vim. ...

Yank lines from one file in vi ( not vim ) to another?

I'm used to VIM and usually I split screen with and open another file, yank the text into the second one. However I'm dealing with a legacy server which only has vi, how could I either open multiple files with it if it doesn't support split views or copy text from one file to another ( 2 separate vim instances I guess ). I don't think ...

What are most useful/used vim commands in C/C++ dev environment

Here is the list of mine Unlike me -- as I did it for illustrative purposes -- don't paste too many. And most importantly, provide an explanation Commands shouldn't be generic but relevant to C++/C environment. ctags & scope are welcome too gi .....................init insert mode in last insertion position '0 ...................

how to move to the next enclosing brackets in VI

Are there any shortcuts to move to the next enclosing brackets. For ex: int func() { if(true) {//this point for(int i=0;i<10;i++) {//need to jump from here to //blah blah blah } } } I can move to the beginning of a function using [[ but not sure how to move to the next enclosing brackets. Thanks for any info... ...

How can I execute a command when a buffer is closed in vim?

Is there something like a close-window-hook in vim/vimscript, so that I can call a function every time a window is closed? I want to use it for the following scenario: I use an extra scratch window to display information about the file, and when I close the file I want the scratch window to be closed automatically so that vim exits. If...

make gvim 7.2 background black

I am sick and tired of the white background when I edit c/c++/etc code. I want the black backround. that is what I currently have in my .vimrc file in regard to coloring. Please help me change it: if !has('gui_running') set t_Co=8 t_md= highlight NORMAL ctermbg=black ctermfg=white thanks ...

Mapping of <ctrl-#> characters

I've been trying to map certain sequences to parenthesis/bracket completion without any success. I've been trying the following commands to map certain control sequences but they don't seem to work. Does anyone know what I'm doing wrong here? :imap <ctrl-9> ( )hha :imap <ctrl-(> ( )hha ...

Best tool in unix for viewing large files

I am a novice in unix. i am facing a problem in viewing big log files in unix using Vi tool. could you please suggest the best tool for fast viewing of big files on unix. Request you to post your own ways of viewing the big files on unix. appreciate your help:) ...

how to change file permission from within VI

I sometimes open a read-only file in vi, forgetting to do chmod +w before opening it. Is there way to change the file from within the vi? something like that !r chmod +w filename ? is there a shortcut to refer to the currently open file without spelling it 50 letter name? thanks ...

Using vi how to obtain a number of time a word or pattern occur in the file

How do calculate the number from inside the vim? ...

How can I search for 3 strings at a time in the vi editor?

How can I search for 3 strings at a time in the vi editor? I was wondering how could we do it. I.e. search for 3 strings at a time in vi like I do: :/xyz in command mode. How could I add 2 more strings so that the cursor will stop at a string which ever is found first among the three and if we press n it will stop at the string that i...

Moving a block of code by a tabspace

I am currently visually selecting the code and typing ">" which moves the code by 2 tabs. But I only want to move it by one tab. Is there any alternate command in VIM to move the code by a tabspace. Ideally I would like to put a marker and then move the whole code block by a tabspace. Thanks ...

Highlight text ranges in Vim

Is it possible to mark a range of text in Vim and change the highlight color of it (to red) than select another range of text and change that color (to green) keeping the previous highlight and so on? ...

Post your Vim config.

Please share and vote for the best! Please do not close this. This is a subjective question, but is programming related and can be beneficial to people. ...

what's the syntax for telling VI to read/write a source file with soft-tabs and a specified indentation?

Someplace I saw a snippet of code which told vi to use soft tabs and set the size of a tab. If you put this snippet at the bottom of a source file, then vi would magically use those settings for that file. What is the syntax and rules for including that snippet in a source file? Can emacs be made to use these settings as well? ...

Make Vim show ALL white spaces as a character

I can't find a way to make Vim show all white spaces as a character. All I found was about tabs, trailing spaces etc. ...

code completion in vi editor

is there an autocomplete feature for vi. ctrl p looks for keywords already used in the document. but suppose i want a.funcname to automatically show members of object a. is it possible with vi. ...

vim regexps from the perl's point of view: which special characters to escape with backslash

Imagine, we have to construct a regexp in vi/vim. Which special characters we have to escape with backslash? By special characters I mean the following chars: {}|()-[]+*.^$? Seems like we have to escape: {|()+? And leave as is: }^$*.[]- Thanks. p.s. AFAIK, we have no '?' character in vi/vim but '=' instead which should be also esc...

Opening files in the same folder as the current file, in vim

In vim, when I have a buffer open, I often need to load another file in the same directory that file is in, but since I don't usually cd into it, the pwd is a parent folder, so I have to retype the path every time. Is there a shortcut for this? or a way to change the pwd to the directory the file is in? example: cd /src vi lib/foo/file...