Hot answers tagged

23

"!" means don't nag me with warnings; just do it. If you try and vim /etc/hosts, and make changes and try and save with :wq! - the "!" is moot. That is a real error that can't be forced thus use of "!" won't work. A useful example.. touch ~/example chmod -w ~/example vim ~/example If you open a file where you have READ access only but have taken away ...


21

User-specific changes like that should go in your personal .vimrc, which should be located in your home directory. If this file doesn’t exist yet you can simply create it. This will add your set line to ~/.vimrc creating this file if necessary: echo 'set mouse=a' >>~/.vimrc After that, either restart vim or source the file in a running instance with ...


10

A freshly installed Ubuntu system has a vi command and does not have a vim command. In this configuration, vi is a symlink that ultimately resolves to vim.tiny, as you mentioned. However, if one of the other packages that provides a Vim binary such as vim.nox or vim.gtk3 (provided by the vim-nox and vim-gtk3 packages) is installed, then vi, as well as vim, ...


10

:wq! means "write this buffer then close it, no questions asked." If you have any other buffers open, they stay open and vim doesn't exit.


9

When vim gives you this warning, it also should give you some options at the bottom: [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: Chose "R" if you want to recover whatever changes and "E" if you don't. If you persistently get this message, delete the swap file named. More information is found in the error message normally.


6

Building on what others have already stated... You can use the following single-line vim command to create a .pdf file: :hardcopy > %.ps | !ps2pdf %.ps && rm %.ps Note: The % is shorthand for the current filename, so HelloWorld.C will print to HelloWorld.C.pdf If you want to also retain the intermediate .ps file, simply omit the && rm %...


4

Is there a standard editor to view config files in linux. vim I m just viewing the ls command (/bin) config file in vim editor but it shows my a lot of @ and alphabets. Then those are NOT config files. Inside /bin there are (or should be) only binaries. Config files are in /etc/ and likely (or often have) have an extension ".conf" or ".cnf" or are ...


4

In addition to the accepted answer, if you are working remotely over SSH (e.g. over tmux with multiple panes with different vim processes you want to copy between), you also need to export your X display since vim is using xterm-clipboard to interface between different processes. You can set the X display by running export DISPLAY=:0.0 This must be run ...


4

Since your issue is related to creating or deleting files, it's possible that the system's indexing/tracking activity is responsible for the delays you see. From the release notes for Disco Dingo: Tracker is now included by default. This allows the desktop to keep track of recently used files and improves searching. A graphical interface present in ...


4

In vi: navigate to the line where you wish to start commenting out enter command mode (Esc then :) type .,+20s/^/#/ or .,+20s/^/"""/ and hit Enter


4

What I typically do is this: Leave editing mode Esc, may need to hit couple times Press Shift+v to enter "Visual" mode Highlight the desired lines via arrow keys, or use 3j to select 3 lines down or 3k 3 lines up Enter command mode via :, and when you see :'<,'> displayed type in s/^/#/, and then hit Enter This is visual approach, sort of like using ...


4

Install the “External Editor” Thunderbird extension from http://globs.org/download.php?lng=en Configure the external editor. Option 1: use gvim This is an easy method which use gvim. In External Editor’s Preference, set the Text Editor to: gvim -f Option 2: use vim in a terminal If you prefer to use vim in a terminal as me, you may consider this ...


4

Using vim as an editor is a bit confusing. So, I suggest you use another text editor like gedit or nano. The command will be as follows: gedit ~/.bashrc The file will be opened, go to the end of the file and add the following lines: export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.32 After that ...


3

When you define a variable in ~/.bashrc, that variable will be present as soon as ~/.bashrc is "sourced" (read). This only happens when you start a new shell (e.g. when you open a new terminal). So, if you add the new line to your .bashrc file, you will then need to open a new terminal and run your python script there. Alternatively, you can run source ~/....


3

Looks like there's a leftover undo file for the specific file you're editing, but it's empty. Check for files ending in ~ in the file folder or, if you have persistent undo enable, in the undodir directory (should be in your .vimrc if configured). If it's really empty, you can safely remove it to get rid of the error message.


3

Try installing vim-gnome. That's what made it work for me.


3

It seems you have more then 1 vim on your system. ./snap/core/6964/usr/share/vim/vimrc control it with snap list and dpkg -l | grep vim


3

Two reasons Because vi is specified by POSIX standard and will be available on all POSIX compliant systems including Ubuntu, whereas vim is GNU version. You should not focus on vi vs vim, focus on consistent behavior and functionality. See https://pubs.opengroup.org/onlinepubs/009695399/utilities/vi.html. There exists more than one clone of vi.


2

You have most likely mixed tabs and spaces in your python file, you must use only one of them. In order to find the problem you can use the command :set list to have vim list all non-printable characters and see where the problem is. Tabs will be shown as ^I spaces will be shown as normal.


2

If you want save changes :wq!, but if something wrong and you want quit anyway (ignore changes) - :q! Often you can start edit file with no permissions to save it. You can make many changes and then understood, you can't save it. In this case i recommend save as it: :w tmp_filename then exit vim and replace old file with tmp_filename.


2

You could make is so if there were not support for grep already as @muru answered: :cexpr system("grep -n keyword") It can be used with another command, git grep for example. Also, you can open the output in a buffer and use "cbuffer" on it. See quickfix section from the manual about it.


2

Vim sets the VIMRUNTIME (and VIM) environment variables within the shell from :sh or :!bash, so you can detect it that way in your .bashrc: if [ "$VIMRUNTIME" ] then PS1="vim: $PS1" fi The above will prefix your existing prompt with "vim: ". You could change it to something else, like just vim $:, if you wanted. Put that at the end of the file so that ...


2

You are mixing the system-wide configuration with user configuration. The manual of Vundle suggests adding a script to “your .vimrc”, i.e. ~/.vimrc, particularly adding a link to ~/.vim/bundle/Vundle.vim. Both these files reside in a user’s home directory (~) and do not affect other users. However, if you put the script (including the link to a user’s home ...


2

Ranger can do that. Ranger is a VIM-inspired file manager for the console available in the universe repository of all currently supported versions of Ubuntu. The GitHub page is here. This answer is not meant to describe how to use Ranger but specifically to indicate that numbering files and folders is possible using Ranger. Users can edit ~/.config/...


2

In the example you gave, with a file containing /root/repo/my-gerrit/myData.cpp This can be changed to /repo/my-gerrit/myData.cpp with the command :%s/\root//gc. You attempted %s\/root\/\repo\/repo/gc, which lacks the normal forward slashes. To replace /root/repo/ with /repo/, the command would be %s/\/root\/repo\//\/repo\//gc Note that forward ...


2

You didn't read man checkinstall and didn't save any data from it. To uninstall software that was installed via make, thusly: cd vim/src make uninstall


2

I'm sure that system libclang and clangd are version 8.0.0 or higher in Ubuntu 18.04. clangd is provided by clang-tools-8 from the universe repository in Ubuntu 18.04. Clang 8 and libclang are provided by clang-8 and libclang1-8 oackages in Ubuntu 18.04. To install all of these packages open the terminal and type: sudo apt install clang-8 libclang1-8 clang-...


2

Simplest way? Just append the desired lines to the desired file: echo export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 >> ${HOME}/.bashrc echo export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.32 >> ${HOME}/.bashrc Now, you should investigate why vim doesn't work on that file. Check the permissions and ownership of .bashrc. That would ...


2

This happens because history expansion is performed before alias expansion. You can force history expansion in your alias by using the history command, using command substitution to replace a command that queries the history with its output: alias vv='$(history -p !vim)' but this will not handle filenames correctly if they contain characters that might ...


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