Tag Info

Hot answers tagged

11

Visual Block Mode First, move the cursor to the first char of the first line in block code you want to comment, then type: CTRL + V then vim will go in to VISUAL BLOCK mode. Use j to move the cursor down until you reach the last line of your code block. Then type: Shift + I now vim go to INSERT mode and the cursor is at the first char of the firts ...


7

See the manpage: -u {vimrc} Use the commands in the file {vimrc} for initializations. All the other initializations are skipped. Use this to edit a special kind of files. It can also be used to skip all initializations by giving the name "NONE". See ":help initialization" within vim for more details.


7

So any way to provide a different vimrc file ( maybe at command line, giving it as parameter each time as vim --vimrc=somefile file-to-open) ? Yes, use the -u parameter: vim -u ~/.my-custom-vimrc From man vim: -u {vimrc} Use the commands in the file {vimrc} for initializations. All the other initializations are skipped. Use ...


6

Ranges: You can do it with the following command: :66,70s/^/# for comment, and for uncomment: :66,70s/^#/ obviously, here we're commenting lines from 66 to 70 (inclusive). Hope this helps. Regards.


3

Markers: Step1 -> go to first line and set the marker with mt step2 -> go to the line till which you want range and issue the command :'t,.s/^/#/In Step1, in mt t is just a name for marker, you can put any character in place of it ,but put the same character in place of t in Step2 also All the steps are done in command mode


3

Substitute For the sake of completeness here's another way: Enter visual mode by pressing v select the lines you like to comment (up/down arrow or j/k) enter :s/^/# / which translates to: in selection (:) replace beginning of line (^) with `# '


2

I took a vim function written by Jan Larres in the question " How to open or close NERDTree and Tagbar with < leader>\?" and modified it (I only added the wincmd commands)to make my vim look like this: +-----------+-------------+ | Tagbar | file | | contents | | +-----------+ | | NERDTree | | | contents ...


2

One is a synonym for the other. See :help S:         *S* ["x]S      Delete [count] lines [into register x] and start insert. Synonym for "cc" |linewise|.


1

When "Vim: caught deadly signal HUP" followed by "Vim: preserving files"., all files which are editing are saved to swap files. According to vim manual: The name of the swap file is normally the same as the file you are editing, with the extension ".swp". - On Unix, a '.' is prepended to swap file names in the same directory as the edited file. This ...


1

In Vim, syntax highlighting is a two-stage process: a syntax script (for a particular language) defines the parsing rules and with that determines what can be distinctly highlighted. There's usually an abstraction layer where individual elements are linked to logical highlight groups. your colorscheme (or the default one) assigns certain colors (depending ...


1

try use the command sed to change. sed -e 's/apple/grape/g' filethatyouwantchange this will just show the output , if you want to change the file use the parameter -i: sed -i -e 's/apple/grape/g' filethatyouwantchange if you are using vi or vim you can do the same thing with the file open :%s/apple/grape/g


1

Plugin There is a plugin, which offers an efficient way of commenting out based on the file system being used. Also, this answer discusses how to use the NERD commenter for vim. Few more basic instructions on how to use the plugin are discussed here.


1

Before you remove vim-minimal, login with root user or do: sudo -s After that remove vim-minimal with the command: #yum remove vim-minimal After you install vim: #yum install vim and after that install sudo: #yum install sudo


1

I think the behaviour you see is just because the Vim backup process is slow. On my plain Ext4 system, this problem manifests as a "file is empty" error from the compiler. To check the timings, I used this Bash sequence: strace -tt -o /dev/stdout gvim --nofork main.cxx | grep 'main.cxx\|close' With backups turned on, I see a 200 ms gap between the file ...



Only top voted, non community-wiki answers of a minimum length are eligible