Tag Info

Hot answers tagged

9

You can use: vi '+normal 15G25|' myfile.xml


5

Vim is acting as if you had typed all of your pasted code by hand, so Vim will add additional indentation and otherwise change whitespace as it normally would, such as with your autoindent setting. To paste code in Vim: :set paste to enable paste mode. Paste your code. :set nopaste to disable paste mode so your normal typing will work as expected again. ...


4

With the file-line plugin, you can simply append line and column to the file name, both when invoking Vim and inside with commands like :edit: vim myfile.xml:15:25


4

Yes, the vim command you're looking for is :source or :runtime to pull them from runtimepath. For example, you could do this in your .vimrc: runtime custom/java.vim runtime custom/haskell.vim presuming ~/.vim is in your runtimepath (which it is by default). You could also drop your scripts in the ~/.vim/plugin directory; see write-plugin in the docs. ...


4

You can use the vim command :X to encrypt the file. It will prompt you for an encryption key, twice. Then save the file as normal. If someone tries to read the file (including root user), it will be gibberish: Mark@MarkBeast ~ $ vim test.txt Mark@MarkBeast ~ $ cat test.txt VimCrypt~01!o▒rl▒_▒Ĩ7vE=▒g Mark@MarkBeast ~ $ When you vim the file later, it ...


3

Zsh allows you to bind a shell function to a key and also has a builtin to put text into your command line. So you can do something like this (in zsh): # define a function that does the work function my_browser_function () { local result result=$( some command that returns the filename ) # print -z $result (see comments) LBUFFER+=$result } # turn ...


2

When gvim starts, it sources a file called mswin.vim via the _vimrc file. In the mswin.vim file the keys are remapped. You can undo this two ways. One is edit the mswin.vim file and remove the mapping (not recommended). A second easier potentially less invasive way is to edit the _vimrc file. 1. Start gvim as Administrator. 2. Click ...


2

Vim can get close(r) to an IDE in terms of features via various plugins, but it will always remain a powerful text editor with great extension capabilities. So for anything larger than a hobby project, you'll certainly miss IDE features like debugging, variable inspection, refactoring, find usages, etc. But why not have both? It's easy to set up a command ...


2

There is a plugin called CodeOverview that can be used on windows (and Mac?): http://www.vim.org/scripts/script.php?script_id=2888?


2

This can be configured via a buffer-local b:browsefilter variable, which is set in filetype plugins; for C/C++, $VIMRUNTIME/ftplugin/c.vim. To change / override this, just put the following into ~/.vim/after/ftplugin/cpp.vim: let b:browsefilter = "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" . \ "C Header Files (*.hpp, *.h++)\t*.hpp;*.h++\n" . \ "C ...


2

You can use :redir for this: *:redi* *:redir* :redi[r][!] > {file} Redirect messages to file {file}. The messages which are the output of commands are written to that file, until redirection ends. The messages are also still ...


2

I don't know about the -c option, but you should be able to do: vi '+cal cursor(15,25)' myfile.xml (make sure you quote because of the parenthesis () )


2

If you let g:ycm_always_populate_location_list = 1, YouCompleteMe will populate vims location list with new diagnostic data. You can jump through the entries in that list with :lnext and :lprevious. You can read more about the location list in the documentation of the quickfix feature (:h location-list or use the online version).


2

You are looking for ftplugins. This is their purpose. And don't forget to define your mappings, setting, abbreviation, commands, ... as local. Otherwise they'll parasite other buffers once loaded. Here are some more complete answers: http://stackoverflow.com/questions/1413285/multiple-autocommands-in-vim/1414845#1414845 ...


2

just for fun there is -c 'normal 14j24l' which will put you on line 15 character 25


1

There's no way, unless you switch the complete UI to right-left mode via :set rightleft or $ vim -H. Even common workarounds such as using the signs column (which a plugin used to implement 'relativenumber' before that was built-in) won't do, as those appear on the left as well. The only, very clumsy hack would be a thin scratch buffer in a vertical split on ...


1

VIM's Hebrew Mode will put the line numbers on the right, with set nu To start VIM in Hebrew Mode use vim -H Documentation here Warning: It does reverse your text to rightleft as well


1

Worth noting: -c command Run the given ex command upon startup. Only one -c option is permitted for vi; Vim accepts up to 10. An older form of this option, +command, is still supported. The +command has the same single ex command limitation when using vi. The +/pattern is also limited to one command with vi. ( taken from vim and ex editor )


1

The shell options don't inherit to forked shells, but that's what Vim does when you use the :! command: it launches a new shell. You can influence those forked shells in Vim via the 'shell' option: :set shell+=\ -O\ globstar or :set shell=/bin/bash\ -O\ globstar


1

You basically already know the answer from here. It's quite easy to put this all together like this: function insert_files() { vifm -f < /dev/tty > /dev/tty while read l; do LBUFFER+="'$l' " done < ~/.vifm/vimfiles zle reset-prompt } zle -N insert_files bindkey '^t' insert_files I'm not a zsh-user, so I stole structure ...


1

You can use the built-in quickfix list to collect all matching lines, with :vimgrep. For example: :vimgrep /^rsync: / % :copen Plugin alternative My ExtractMatches plugin provides (among others) a :GrepToReg command. With it, you can collect the matching lines in a register and then paste that into a new scratch buffer: :GrepToReg /^rsync:/ :new | put! ...


1

Use redir to redirect to a new file: :redir > rsync.log :g/^rsync/ :redir > file_vanished.log :g/^file/ :redir END :q cat rsync.log rsync: send_files failed to open "/cygdrive/E/Users/SharedFiles/3DS SALES/3DS MARKETING/PORTFOLIOS/2012 - Portfolios/Signage"XXXXXXXX Full Res photos/xxxxx xx sky/.DS_Store": Permission denied (13) rsync: opendir ...


1

Commands with the word Plugin should be preferred. In past plugins used to be called "bundles", therefore all associated commands had "bundle" in the name. In the beginning of 2014 there was a global rename (see this commit). The old "bundle" commands were left only for compatibility reasons.


1

Do :set paste Above code solves your problem.


1

You can change the permissions on the file to 000. $ chmod 000 somefile Example Initially we have this file: $ cat afile secret Change the permissions, and confirm: $ chmod 000 afile $ ls -l afile ----------. 1 slm slm 7 Nov 26 13:07 afile Now we can't see it: $ cat afile cat: afile: Permission denied Caveats with this This is easy to ...


1

This is a buffer flush-to-disk problem. Vim tries to keep your work safe and doesn't assume you can type several thousand characters per second. Read :help swap-file for some details on the buffering. The solution to your problem is this: Turn off vim's swapfile either with: vim -n <your file> or from within vim before the paste: :set noswapfile ...



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