Sublime to dash board and Vi/vim edit files without permission to save when Ubuntu is configured.

Source: Internet
Author: User
Tags sublime text

"1" under Ubuntu Configuration sublime to dash board

Ubuntu is a good system, Sublime Text is a good editor.

Download & Install

Personal habits like to download software on the official website, HTTP://WWW.SUBLIMETEXT.COM/2 choose the appropriate package to download the format is. tar.bz2 format, need to be decompressed.

1. Unzip:

2.0.2.  tar.bz2 

2. In order to execute the./sublime_text file at any location in the terminal, save the extracted directory to the environment variable $path directory

2/usr/local/lib/

3. Create a shortcut to it (similar to the shortcut in Windows, actually a link)

2/sublime_text/usr/bin/subl

In this way, anywhere in the terminal can open sublime text.

Configure Desktop Icon Shortcuts

Although this looks good, but far less than the Windows desktop to double-click an icon to facilitate, so we want to add a graphical version of the shortcut to open the way.

All of the programs in the Ubuntu system default Dash menu are all placed in the

$ cd/usr/share/applications/

Under this directory, so we're going to create a sublime.desktop file in this directory, as a desktop Entry.

The basic format is this:

2genericname=Text editorexec=sublterminal=false2/icon/48x48/sublime_text.pngtype=  applicationcategories=texteditor;ide;developmentx-ayatana-desktop-shortcuts=NewWindow[NewWindow Shortcut group]name=New windowexec=subl-ntargetenvironment=unity      

Finally, the sublime text can be opened graphically in dash home.

Each parameter according to the name is not difficult to understand, in-depth understanding please refer to:

http://www.ibm.com/developerworks/cn/linux/l-cn-dtef/index.html Linux Desktop Entry file in-depth parsing

"2" vi/vim an issue with no rights to save when editing a file

In the Linux environment, if you use the Vi/vim command directly to edit the file without modifying the permissions, the user will be prompted to save the operation, the general solution is to close the file again with sudo permission to open the file edit and then save (if the user has sudo permissions). In fact, in the Vi/vim mode through a few simple commands, you can not close the current file to achieve the purpose of saving the file (thanks to the method provided by Xiao Zhe teacher):

    1. Input command:%! sudo tee% >/dev/null
    2. Follow the instructions to enter sudo permissions password
    3. Enter "l" (load File)
    4. Enter : Q command to exit

Instructions for the "%! sudo tee% >/dev/null" command are as follows:

% #VI/vim edited file contents

! #管道

sudo #以root权限操作

Tee # outputs the standard input (that is, the currently edited file content through the pipeline) to the standard output, while writing to the specified file ( that is, Vi/vim the currently edited file )

% #Vi/vim edited files

>/dev/null #将标准输出重定向到/dev/null (no output display)

In the actual operation of the individual, the following statement can be saved in real line, do not need the subsequent output statements.

: w!sudo Tee%

Sublime to dash board and Vi/vim edit files without permission to save when Ubuntu is configured.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.