Hot answers tagged

31

You can append to a register instead of erasing it by using the upper-case letter instead of the lower-case one. For example: :1y a # copy line 1 into register a (erases it beforehand) :3y A # copy line 3 into register a (after its current content) 8G # go to line 8 "ap # print register a


5

sed does not understand \d. You can use [0-9] or, more generally, [[:digit:]] in its place: $ sed -r 's/.*(X[[:digit:]])(.*)45.*/\1\2/' test.txt X1yad X2fad X3had X4wad X5mad


4

The best approach is to first modify Vim configuration files to automatically load your configurations. It can be done by writing the following lines to either ~/.vimrc if you want just to your user or /etc/vim/vimrc if you wish it applied to every user. syntax on set autoindent set smartindent set tabstop=4 set shiftwidth=4 set expandtab set ...


3

The vicmd mode, despite the name, is for Vi's normal-mode commands. The prompt started by : isn't for Vi's ex-mode commands, but for running ZLE (Zsh's line editor) commands: $ echo foo execute: e_ edit-command-line emacs-forward-word end-of-history end-of-line-hist exchange-point-and-mark execute-named-cmd ...


2

One option may be to remove the "r" formatoption, with: :set formatoptions-=r and also possibly other options, all of which I found at: http://vi.stackexchange.com/questions/1983/how-can-i-get-vim-to-stop-putting-comments-in-front-of-new-lines


2

Go into paste mode: :set paste after pasting, you want to end paste mode: :set nopaste


2

I cannot provide proof of any kind, but Ctrl-P and Ctrl-N belong to the emacs key bindings, in contrast to vi bindings (bindkey -e vs. bindkey -v). Under this premise, you should look for an explanation in emacs itself. emacs' tutorial tells There are several ways you can do this. You can use the arrow keys, but it's more efficient to keep your ...


1

sed 's/abcd\(X[0-9][a-z]ad\)45das/\1/g' your_file_name should do it.


1

You can use the :copy command, which can be abbreviated as :t: :1t8 :3t8 If you want to copy a range of lines (e.g. all lines from 1 to 3) you can do it like this: :1,3t8


1

Turns out that removing all ~/.zcompdump files solved it: rm -r ~/.zcompdump*


1

A solution from the StackOverflow: :help 'viminfo' ... < Maximum number of lines saved for each register. ... :set viminfo? :set viminfo='100,<100,s10,h


1

If that is a static file, most likely your browser doesn't really retrieve the new file, you can check that by pressing Shift while clicking refresh (at least in Firefox). If that doesn't work, it is probably your webserver doesn't notice the change in that case reloading the webserver is normally enough. E.g for apache2 service apache2 reload or ...


1

It turns out, that the terminal locales were setup somehow wrong. My .bashrc had a export LC_ALL=C. > locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="C" LC_NUMERIC="C" LC_TIME="C" ... LC_IDENTIFICATION="C" LC_ALL=C After removing LC_ALL=C I get this: > locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC=en_US.UTF-8 LC_TIME=en_GB.UTF-8 ...


1

I had this hack in my vimrc: set shellcmdflag=-ic to get bash aliases to work in vim. This caused the described behaviour. By piping ack to another process ack will be runned non-interactive. Solution, delete the hack.


1

T$c, Or if you want to create a text object: onoremap i$ :normal! T$v,<cr> vnoremap i$ <esc>T$v,


1

If you need to delete text with d without altering your yank register (say, you've already yanked text in it that you're not ready to paste before your delete some other text for instance), you can use the black hole register _. If you do "_dd for example, the current line will be immediately deleted and forgotten. Actually, I don't use this register very ...


1

This came to me after I asked the question in another forum AskUbuntu: vim.desktop - changes lost when terminal exits and a lot of experimental *.desktop files demonstrating that gnome-terminal would allow vim to be killed without warning even if it was running in an shell & even if there were other commands before or after it for bash or gnome-terminal ...



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