Tag Info

Hot answers tagged

9

Beside the paste option mentioned by Mat, you can also directly access the X clipboard from VIM: "*p to insert the X11 selection "+p to insert the X11 clipboard You need a VIM version with X11 support (in Debian and its derivatives you need to install the vim-gtk or vim-gnome package). For more information, see the documentation (:help x11-selection).


8

You can use the VIMINIT environment variable to override the use of the usual .vimrc while keeping other parts of the initialization process. VIMINIT should be set to one or more ex-style commands (“colon” commands; use pipe (|) to separate multiple commands), not just the path to a different initialization file. VIMINIT='so /tmp/myvimrc'; export VIMINIT ...


8

Suppose you have this other set of settings in /tmp/myvimrc. If my reading of man vim is correct you can start vim with this set of settings using the following: $ vim -u /tmp/myvimrc Thus, to make this an option for the rest of the session, I would create a function that sets this as an alias for vim. Thus, in bash I would put something like this in my ...


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 ...


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.


6

using .zshrc to modify my environment variables That's the root cause of your problem. .zshrc is a startup file for interactive shell sessions. Use it to set shell settings, not to set environment variables. Environment variables are typically set in a session file such as .profile. See Alternative to .bashrc (what goes for .bashrc also goes for ...


5

Central configuration If it's okay to configure the local exceptions centrally, you can put such autocmds into your ~/.vimrc: :autocmd BufRead,BufNewFile /path/to/dir/* setlocal ts=4 sw=4 On the other hand, if you want the specific configuration stored with the project (and don't want to embed this in all files via modelines), you have the following two ...


5

You have to change the color of your cursor line to a color other than the color of your cursor. If you're in a terminal emulator like st or rxvt, Vim cannot change the color of your cursor; it will always be the color your terminal application decides to make it. Only the graphical version of Vim is able to change the color of your cursor. You can change ...


5

You could use :confirm quit, e.g. map <C-w> :confirm quit<CR> By the way: C-w is a bad choice for a shortcut, because it is used as the start of other shortcuts, e.g. C-w v for splitting vertically. That's why you experience a short delay before the dialog pops open: after you press C-w, vim waits a short time for other keypresses, before it ...


4

Yes, it is possible. You can load menu.vim (the default gvim menu definitions), or you can just start from scratch and create your own, then access them through :emenu. This doesn't give you nano-like always-visible menus, though; it gives you the ability to navigate menus using command-line tab completion. If the user doesn't have a vimrc, you'll want to ...


4

Your server is trying to use a file for lexical highlighting. The file does not exist at the place where vim is looking for it. At this point, you can do any one of the following: Remove the reference to syntax in /etc/vimrc Look for the syntax file on your server (e.g. find / -name syntax.vim) and copy or symlink that file to the directory where vim is ...


4

Yes, the :! command takes the remainder of the command-line as arguments. To concatenate other Vim commands, you can wrap the command with :execute: nnoremap <leader>ss :w\|:silent execute '!execute_external_script > output_of_script.txt'\|:redraw!<cr> Alternatively, you can just issue multiple command-lines, separated by <CR>; after ...


4

Here's what's happening. There are Vim formatting options that automatically comment out new lines when you are on a comment line. Some of these options are usually enabled by default. For example, # a comment<CR> # As you can see, the new line was automatically prepended with a comment character. You can disable the majority of these options by ...


3

Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. (Unless your terminal sends a distinct termcap code for it, which most don't.) In insert or ...


3

If it is not an interactive or a login shell I think you're left with using ~/.zshenv. The following is from section "STARTUP/SHUTDOWN FILES" in zshall(1): Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login shell, commands are read from /etc/zsh/zprofile and then $ZDOT- DIR/.zprofile. Then, if the shell is interactive, commands ...


3

See this wikia.com article for the exact thing you're tyring to do: http://vim.wikia.com/wiki/Map_Ctrl-S_to_save_current_or_new_files In a nutshell you need to do the following. 1. Add this to ~/.vimrc " If the current buffer has never been saved, it will have no name, " call the file browser to save it, otherwise just save it. nnoremap <silent> ...


3

You can split and open a new file at the named tag with the command :stag, it appears to default to the binding Ctrl-w, Ctrl-]. You could bind that to whatever then: map <F2> :stag If needs to be done in a tab, then, you can do it in two steps: Ctrl-w,Ctrl-] Ctrl-w, T Or you can map it: map <F2> :tab split <CR>:exec("tag ...


3

The autoread option does not have a timer. A reload is triggered when a shell command is launched or checktime is executed. Furthermore, vim does not have built-in timer functionality, so there's no simple way (meaning without plugins or ugly hacks) to call checktime every n seconds. You can misuse updatetime and events like CursorHold to execute checktime ...


3

This vim wikia article titled: Keep incremental backups of edited files, sounds like what you're looking for. There's this method which attaches a save routine so that it's mapped to the Esc key. With the following mapping: fun! InitBex() let myvar = strftime("(%y%m%d)[%Hh%M]") let myvar = "set backupext=_". myvar execute myvar ...


3

Unfortunately, there's no way to do this without support from the plugin. (Sort of.) The key lines here are: setlocal foldmethod=expr setlocal foldexpr=WorkflowishCompactFoldLevel(v:lnum) The first means "use the value of 'foldexpr' to determine the fold level of each line". The second sets that option to use the value of a function defined in the ...


2

You have several options here: Git commit your .vim folder and have your group members clone it from there. Have each group member symlink their /.vim to a shared folder. Have each user modify their .vimrc to point to a shared folder like this: call pathogen#infect('foobundle/{}', '/foovim/foobundle/{}') The first argument specifies the name of the ...


2

It should be syntax on or syntax off. set syntax=something is used to change the current syntax (c, perl, nasm, etc). UPDATE: As @garyjohn pointed in comments, it's possible to turn it on/off for the current buffer and its corresponding filetype using set syntax=ON and set syntax=OFF.


2

As far as i know there is no way to have menues with vim (in the terminal). Depending on the role of your server you may consider talking to the admins and demand the installation of additional editors like nano, emacs, mcedit…. If this is not a production environment and should be used by developers interactively there is no good reason to deny the ...


2

There are two problems: The :highlight command does not evaluate ctermfg values as expressions. It accepts only a literal color number, or a color name (see :help cterm-colors). You get E421 because s:base00 is not a number, nor a valid color name. You could use execute 'highlight GroupName ctermfg=' . s:base00 to build an command string and execute it ...


2

If you are working within a GUI or a window manager of some sort, you may be able to configure it to send a different keystroke to your terminal application or Gvim application when you type Ctrl;. You would need to tell it to send a keystroke that vim understands but that is harder for you to type. For instance, you could map Ctrl; to Ctrl^ (which I ...


2

Vim expects to find its installation files (eg help system, definitions for syntax highlighting) in a particular place but can run without many of them. It's possible that while you can run Vim, it cannot locate these installation files. Vim will try several methods to locate these files but if you have a unusual installation then they won't be found. If ...


2

To keep cursor position use something like: function! <SID>StripTrailingWhitespaces() let l = line(".") let c = col(".") %s/\s\+$//e call cursor(l, c) endfun else cursor would end up at beginning of line of last replace after save. Example: You have a space at end of line 122, you are on line 982 and enter :w. Not restoring ...


2

This should do it: augroup myvimrc au! au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif augroup END Found this solution on SuperUser in Q&A titled: How do you reload your .vimrc file without restarting vim?. See help on autocmd-patterns for more info: :help autocmd-patterns ...


2

Once you use sub-replace-special, introduced with \=, everything has to be a Vim expression; you cannot prepend / append literal replacement text. Therefore, your static text has to be encoded as Strings, and concatenated with .: :let i=1 | g/name/s//\='_first' . i/ | let i=i+1


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 ...



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