Tag Info

Hot answers tagged

5

You should add it to your shell’s configuration file. For Bash, this is ~/.bashrc or ~/.bash_profile. You should also set $VISUAL, as some programs (correctly) use that instead of $EDITOR. Additionally, unless you know why, you should set it to vim instead of vi. TL;DR, add the following to your shell configuration (probably ~/.bashrc): export VISUAL=vim ...


4

I don't have an X11 machine around so I can't verify this myself, but you might want to look at a program like xclip: xclip is a command line interface to the X11 clipboard. That won't exactly let you paste into your current tty, but it should at least print the contents of the clipboard to stdout. Then you can capture that into a file, or pipe it to a ...


3

If it is a well-formatted CRLF file, vim will recognize it as such and set fileformat to dos. Try it with :set fileformat?. Thus set list will interpret CRLF, correctly, as legitimate line endings for this file format. See :help fileformats for more on file format auto detection. Also, this tips page expands on this and for example how to convert between ...


3

You can write the loop yourself: for file in ['foo.txt', 'bar.txt'] execute 'edit' fnameescape(file) " Your processing here. endfor Or if you already have all files loaded in Vim, use :bufdo and execute your commands conditionally, based on whether the buffer (or buffer number with bufnr('')) is in your list: bufdo if index(['foo.txt', 'bar.txt'], ...


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

TTY framebuffer console has no way to have more than 8-16 colors without kernel hacking, see this quote: "Although the Linux frame-buffer supports 256 (or more) colors, the Linux console driver does not; therefore, console applications are still limited to 16 colors on the Linux console, frame-buffer or not." So you can have no more than 16 or 8 colors. ...


2

I would do that in this way (really useful for many paste): Go somewhere into the word Linux, then "ayiw to copy the word "a to select register «a» y for copying i to specify we are "in" (the word, the paragraph, ...) w to choose the word Got to next word w (or somewhere into the word) Paste on time and save that as macro qbdiw"aPq qb to start recording ...


2

You can use dictionary completion, i.e. :setlocal dictionary+=/path/to/your/file and then trigger the insert-mode completion with <C-x><C-k>; see :help i_CTRL-X_CTRL-K. If you want this only for filetype xxx, put the :setlocal in ~/.vim/after/ftplugin/xxx.vim. In contrast, Omni completion gives you more power, but you have to write the ...


2

I got all the pieces together to do the trick. The best way is to create a custom mapping for all the commands: map <F8> :let mycurf=expand("<cfile>")<cr><c-w> w :execute("e ".mycurf)<cr><c-w>p Explanation: map <F8> maps on "F8" the commands that follow let mycurf=expand("<cfile>") gets the filename ...


2

Those are pipes, not regular files. It goes away when vim closes the file descriptor. You could do: hg cat -r 42 somefile | vim - (there vim is told it may not be a regular file so behaves accordingly. Use vim -R - or view - if you don't want vim to complain that the data has not been saved on exit). Or with zsh, using a temporary file: vim =(hg cat -r ...


2

Sometimes the vi command is an alias for vim and when called as vi enables its vi-mode. Even in traditional mode backspace is deleting the character, but does not display it as deleted immediately. (After pressing ESC the characters are gone.) Guess you have to choose between using vi which comes with the described behavior or using vim which is able to do ...


1

Checkout whether your are actually using plain vi via $ vi --version | head -n 1 This gives on my machine (Debian 7) VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 10 2013 02:27:59) vim can be made to behave more similar like vi. This is often enabled when calling vi instead of vim from the commandline, where vi is only a sym-link to vim. You can ...


1

Saving on lost focus is achieved through the following command in the .vimrc: autocmd BufLeave,FocusLost * silent! wall The syntax is: :au[tocmd] [group] {event} {pat} [nested] {cmd} In your case, you want to add VimResized to the list of events, see full doc here. The final result in the .vimrc file looks like: autocmd BufLeave,FocusLost,VimResized ...


1

The issue is caused by the sensible plugin:line 93. :help t_Co " Allow color schemes to do bright colors without forcing bold. if &t_Co == 8 && $TERM !~# '^linux' set t_Co=16 " << --- Causes hickup endif If you run vim in verbose log mode (vim -V15load_log.vim) – and search for t_Co= and RedundantSpaces you'll see that sensible is ...


1

I need this so often, I wrote a plugin to simplify and allow maximum speed: ReplaceWithRegister. This plugin offers a two-in-one gr command that replaces text covered by a {motion} / text object, entire line(s) or the current selection with the contents of a register; the old text is deleted into the black-hole register, i.e. it's gone. It transparently ...


1

Use registers and avoid visual mode. Move to 'L' (type 0fL) |L|inux Solaris Irix HP-UX "lye 'Linux' is now in the 'l' register. Move to 'S' (type fS) Linux |S|olaris Irix HP-UX "sde"lP Linux Linu|x| Irix HP-UX 'Solaris' is now in the 's' register. ...


1

After doing these commands: cd ~/.vim/bundle git clone git://github.com/mattn/calendar-vim You need to add the following line to your $HOME/.vimrc file: Bundle 'calendar-vim' After doing this when I start up vim I get the command: :Calendar Which shows the following in vim. screenshot ...


1

Try out this bash function in the console. Fittingly, it doesn't work in an X terminal (I think because of the tabs). Especially check out the three files used last, namely /sys/module/vt/parameters/default_red /sys/module/vt/parameters/default_grn /sys/module/vt/parameters/default_blu clr () { clear # GFX bug otherwise setterm -regtabs 4 ...


1

This short script will preserve the modified time if any parent dir of the file contains a .nomtime file: #!/bin/bash dir="${1%/*}" [ "$dir" = "$1" ] && dir=. dir=$( readlink -f "$dir" ) nomtime= while [ -n "$dir" ]; do if [ -f "$dir/.nomtime" ]; then nomtime=1 break fi dir="${dir%/*}" done if [ "$nomtime" = 1 ]; then ...



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