Hot answers tagged

308

Use dtc, where c is any character, e.g. for you, you want dt" This will delete upto but not including c. If you had: delete until exclamation point! And the cursor was at the first space and you typed dt!, you would get: delete! Also dfc. This will delete upto and including c. Using df! on the same example above would give you: delete Just ...


231

Plugin Installation: Install python-pip and git: Open terminal by hitting Ctrl+Alt+T and run: sudo apt-get install python-pip git Per user: In terminal run: pip install --user git+git://github.com/Lokaltog/powerline Add ~/.local/bin to $PATH by modifying ~/.profile with your favourite editor: gksudo gedit ~/.profile and adding following lines at the ...


191

Type sudo update-alternatives --config editor You will get a text like below. There are 4 choices for the alternative editor (providing /usr/bin/editor). Selection Path Priority Status ------------------------------------------------------------ * 0 /bin/nano 40 auto mode 1 /bin/ed ...


175

Functionally, vim is almost a proper superset of vi. Therefore, everything that is in vi is available in vim. Vim adds onto those features. Here are a some of the extended vim features: Vim has been ported to a much wider range of OS's than vi. Vim includes support (syntax highlighting, code folding, etc) for several popular programming languages (C/C++, ...


142

You can use process substitution (this also works with applications that can't read from STDIN): vim <(ls -la) Or use vim's function to read from STDIN: ls -la | vim -


125

You're probably in editing/insert mode. You need to type the following sequence : Esc, to quit edit mode and fallback to command mode ; :+w+q, start with a : (colon) then press w and finally q to write and quit (or just :w to write without quitting) then press Enter to valid.


119

Resolved it : /etc/vim/vimrc Already contains necessary feature. Just need to uncomment it: " Uncomment the following to have Vim jump to the last position when " reopening a file if has("autocmd") au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif endif (Infact, you can refer to /usr/share/vim/...


118

Including the vim package, there appear to be at least six "vim-variants" (not including available documentation, or plugin packages) as well as the main vim package in both the main and universe repositories. Below is a brief summary of each (links go to package description and dependencies in Ubuntu LTS release 16.04 "Xenial"): vim Vim compiled and set ...


89

This is what works for me (Ubuntu 13.10): Reinstall vim as vim-gtk: sudo apt-get install vim-gtk select what you want using the mouse - then type to copy to clipboard: "+y to paste to vim from clipboard type: "+p I don't know why but comparing the output of vim --version shows that the usual vim installation is quite restricted compared to vim-gtk. ...


80

Try from within vim ... :version and if your get ... Small version without GUI. You are missing package vim-gui-common. It is probably also advisable to install vim-runtime. Commands to install: sudo apt-get install vim-gui-common sudo apt-get install vim-runtime Another cause might be that alternatives is pointing to the wrong one: update-...


76

vim [your file] If this isn't working for you, make sure you have it installed with: sudo apt-get install vim If you're already IN vim do :edit [your file] Additionally, to move back to the previous file after you finish editing the new file you can use :e# This will return you to the previous file


67

I had this same problem and it turned out that the .viminfo file in my home directory had the wrong ownership. It was owned by root:root. Once I fixed the file ownership by changing it to myself, remembering file position started working for me again


67

You can send vim the SIGTSTP signal. You do this by pressing ctrl+z. Vim will get suspended in the background, and you can use the terminal. Type fg in the terminal to resume with vim. Bonus tip: This works on nearly all terminal applications. Use bg to enable the application to continue running in the background.


66

You can use the commands :set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:< :set list to show all characters that aren't whitespace. So spaces are the only thing that doesn't show up. If you absolutely need spaces to be marked as well, you'll need to try something less nice. Something like :%s/ /█/g Will replace all spaces with a block ...


64

"vi" is a text editor from the early days of Unix. It became quite popular and made its way into the Single Unix Specification (SUS) and POSIX, but wasn't freely available until 2002. So, several free vi-like editors emerged. Vim ("vi improved") is one of these editors. As the name suggest it adds lots of functions to the original vi interface. In Ubuntu ...


63

One of the best ways to do that graphically is to install Gnome Tweak Tool: sudo apt-get install gnome-tweak-tool Open tweak-tool and click on the typing section in the left column. You should now see the line Caps Lock key behavior on the left. Choose Make Caps Lock an additionnal Ctrl key instead of Disabled in the drop down list and you should be good. ...


59

Here's a way to do it without installing extra software: setxkbmap -layout us -option ctrl:nocaps Source: http://www.noah.org/wiki/CapsLock_Remap_Howto


59

To delete forward up to character 'X' type dtX To delete forward through character 'X' type dfX To delete backward up to character 'X' type dTX To delete backward through character 'X' type dFX


58

As @Rob already mentioned, you can only do this if you have write access to the directory containing the file. Attempting to do the same thing to a file in, for example, /etc will fail. As for how vim is doing this, it deletes the file and recreates it. To test this, I created a file owned by root: echo foo | sudo tee fff And then proceeded to edit the ...


54

Starting tmux with the following flag fixes this for me: tmux -2 from tmux man page: -2 Force tmux to assume the terminal supports 256 colours.


50

So, vim.basic is just plain vanilla Vim (as you can check with apt-file vim.basic or dpkg -S /usr/bin/vim.basic). While vim.tiny, as the name implies, is a trimmed-down version of Vim (this question explains it further). Kudos for @terdon at comments for sorting that out.


49

You can enter :pwd to display the current working directory. This is where your file will be saved if simply enter :w filename. You can change the working directory with :cd path/to/new/directory. Or you can enter the full path to the location where you want to save the file with the write command, e.g., :w /var/www/filename.


47

I think you should install a ncurses-dev library. you can do so by running sudo apt-get install libncurses5-dev libncursesw5-dev


46

In a nutshell: nano is simple, vim is powerful. If you only want to simply edit some textfiles, nano will be enough. In my opinion, vim is pretty advanced and complicated to use. You should expect some time to get into it before you're able to properly use it. Funny (but not too unrealistic) quote about vim: (source) I've been using vim for about 2 ...


43

Open the following for editing: sudo vi /etc/default/keyboard And edit XKBOPTIONS="ctrl:swapcaps" Then, reconfigure: sudo dpkg-reconfigure keyboard-configuration or /usr/bin/setxkbmap -option "ctrl:swapcaps"


42

You don't say how you are clicking on this file, so I will explain a way to do it in Gnome from Nautilus. It should work in other cases, I believe. First, to get Vim (or any app) into the "open with other application" list, you need to create a .desktop file in ~/.local/share/applications with a line in it like this: Exec=<command> %f. I just made ...


39

:r !command will read the output from the command and insert it into the line under the current line. This is how vi is programmed you cannot change the behavior. But say if you are in line number 3. If you try :r !date. It will insert the date value into line number 4. If you want the date value to be appeared on line number 3, then you try :2r !date ...


38

You're really close on your own. You were just missing one character. ls -la | vim -


37

To make sure you have the latest sources.list sudo apt-get update then run: sudo apt-get install vim


37

If you want just to make your user use by default a different editor, add export EDITOR=vim; in your .profile (or wherever you keep your startup environment if using a shell different from bash). Log out, log in, check that the variable is set: [romano:~] % env | grep EDI EDITOR=vim and now all the programs that call an editor (and are well written) ...


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