New answers tagged

2

That rule could be better written as %.o: %.cpp clang++ -Wall (...) $< This way, only the source files newer than their object files are compiled. And the highlighting will also work as expected.


0

Add below code in .vimrc file. map <F3> <ESC>:exec &mouse!=""? "set mouse=" : "set mouse=nv"<CR>


2

From here you can unbind the key combination in byobu: Create a file ~/.byobu/.tmux.conf with (or add if the file exists): set-window-option -g xterm-keys on Then add the following to ~/.byobu/keybindings.tmux: unbind-key -n C-Left unbind-key -n C-Right


3

C-b c already has a standard binding which it might be wise to leave unchanged. Choosing another character, eg C-b C you can setup a binding in your ~/.tmux.conf file as follows: bind C send-keys -t.- 'mvn install' Enter The -t.- means "the other pane". Enter stands for the key of that name, i.e. the newline at the end of the command.


1

This is still happening in Fedora 23. My solution was to update both packages: sudo dnf update vim-common vim-minimal If I tried to update either package separately, I got the conflict. But I was able to successfully update both of them at the same time.


2

You are free to choose whichever editor that you like. nano is much easier to use than vi, but vi is also much more powerful and features an elaborate set of macro programming commands, mass operations, multiple cut&paste buffers, and more.


30

vipe is a program for editing pipelines: command1 | vipe | command2 You get an editor with the complete output of command1, and when you exit, the contents are passed on to command2 via the pipe. In this case, there's no command1. So, you could do: : | vipe | pandoc -o foo.pdf Or: vipe <&- | pandoc -o foo.pdf vipe picks up on the EDITOR and ...


18

You can do this from within Vim: :w !pandoc -o file.pdf Or even write the buffer into a complex pipeline: :w !grep pattern | somecommand > file.txt And then you can exit Vim without saving: :q! However, considering your specific use case, there is probably a better solution by using vi as your command line editor. Assuming you use bash: set ...


4

Make sure that vim is set as your default editor (e. g. export EDITOR=vim in your .bash_profile or .bashrc. Then, at any prompt, you can type Ctrl-X followed by Ctrl-E. This will open your current command line in your configured editor (e. g. vim). Make your edits, save and exit, and the command will be executed as though you had typed it on the command ...


10

Running in a pipeline Try: quickedit() ( trap 'rm ~/temp$$' exit; vim ~/temp$$ >/dev/tty; cat ~/temp$$ ) The key is that, to be able to use vim normally, vim needs stdout to be the terminal. We accomplish that here with the redirect >/dev/tty. For purposes of security, I put the temporary file in the user's home directory. For more on this, see ...


0

py module flake8 is needed sudo pip install flake8


0

So first do find . -name "*.tex" -exec grep -il "agent" {} + | vim - In .vimrc, one macro from vi.stackexchange where gff opens many windows of the visual selection % http://vi.stackexchange.com/a/7627/2923 if has("win32") || has("win64") :vnoremap gff :<C-U>'<,'>g/^/silent! exec "!START /B gnvim " . shellescape('<cfile>') <bar> ...


1

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


1

t$v,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 ...


0

1Gyy7Gp #use 7 if you wish to paste the line at 8 3Gyy8Gp #use 8 if you wish to paste the line at 9


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


33

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


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

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


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 Note that [[:digit:]] is unicode-safe but [0-9] is not.


0

You sed does not understand the special sequence \d. Replace \d with [0-9] or character class [:digit:]: $ cat file.txt abcdX1yad45das abcdX2fad45das abcdX3had45das abcdX4wad45das abcdX5mad45das $ sed -nr 's/.*(X\d)(.*)45.*/\1\2/p' file.txt $ sed -nr 's/.*(X[0-9])(.*)45.*/\1\2/p' file.txt X1yad X2fad X3had X4wad X5mad


2

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


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


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


0

You want to move through each cell. So, in normal mode, w or b command will help you to move forward or backwards through every word. To get the same facility in insert mode, you can use map. :imap <Tab> <Esc>wi Put this in command line. When you are editing, you can press tab to move to next cell. The mapping I have done will come out ...


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


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



Top 50 recent answers are included