ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Vi Unix Editor – How to use Vi Editor and Common Problems – CLI Putty Errors and Terminal Type

Updated on August 27, 2009

The Vi Unix Editor

The Vi Unix Editor is the standard UNIX command line editor and if you’re planning on doing some configuring of a Unix Server you will definitely need to use the VI editor especially when you’re running a Command Line only operating system.

This hub will go through the basics of using the Vi unix editor, opening, creating, saving and writing to a file as well as the different modes for the Vi Editor. I will also go through common problems people have with the Vi editor especially the annoying problem when logging into your server using a SSH client such as Putty, where you find that the backspace key doesn’t work or the arrow keys simply return letters.

I’ll also cover basic terminal modes and types and how to make sure the server’s terminal type and the putty terminal type match so that you have no problems accessing and editing files remotely on your server.

Try these navigational keys if the usual arrows and backspace do not work for you, otherwise keep reading to get normal keyboard function back
Try these navigational keys if the usual arrows and backspace do not work for you, otherwise keep reading to get normal keyboard function back

Unix Vi Editor Modes

- Command mode – This is the basic mode of the Vi editor and can be accessed by opening a file using “vi file.conf”. Letters and combination of letters will be interpreted as commands.

- Insert Mode – The Insert mode as it sounds allows you to edit text and insert your own text into configuration files. Depending on how your Unix system is setup you can either navigate using the arrow keys and regular windows keyboard or use the following. Press the INSERT key on your keyboard to enter this mode.

- INSEERT IMAGE, ordinarily you can use the regular keyboard functions otherwise use these ones. Paste bigger list onto a copy code thingo

- Line Mode – The line mode can be entered by pressing ESC and then type colon (J

From here you can either save the file, save and quit , or quit without saving changes.

:wq write the file to disk and quit

:q! quit without saving any changes

:w! newfile write all lines from the entire current file into the file 'newfile', overwriting any existing newfile

:n,m w! newfile write the lines from n to m, inclusive, into the file newfile, overwriting any existing newfile

the Vim editor will solve all your problems :)
the Vim editor will solve all your problems :)

Common Problems when using Vi Editor

- Backspace function not working

- Arrow keys return A, B, C , alpha functions

- Keys generally acting strange and muddled

- Errors when using Putty or SSH client to remotely access server

Solution – Vim Editor **

There is an incredibly easy solution to this problem, instead of using the light weight Vi editor, instead use vim to edit your files. Simply type Vim “filename” to edit the files and you will notice all the regular functions are restored. You can backspace as usual and the arrows also work fine.

You can also choose to change the alias for vi to point to the vim editor in your bashrc profile. Follow the steps below

- Open up your terminal window , Command Line

- Type “vim ~/.bashrc” , create the file if it doesn’t already exist, or copy the file from your existing login directory

- At the end of the file type “alias vi=’vim’”

- Save and Quit

- Done

Checking terminal-type string in Putty SSH client
Checking terminal-type string in Putty SSH client
Keyboard settings for putty , Check settings for how putty will interpret a backspace function
Keyboard settings for putty , Check settings for how putty will interpret a backspace function
Remember to save your settings before testing them
Remember to save your settings before testing them

Other Problems - Cant Backspace, Weird arrow Keys etc

SSH client Putty Problem – Weird key functions, backspace not working

Solution – Make sure the Terminal mode on your server matches the Terminal mode used on the putty or ssh client. If they don’t match putty and the server won’t be able to agree on how to interpret keys and you may find it hard to carry out basic tasks.

Check what Terminal Mode you are running

Echo $SHELL or Echo $TERM

You can set the terminal type by typing “set term/device=vt100” replace vt100 with your chosen terminal mode. Vt100 is the most commonly used.

Check Terminal Mode on your SSH client (putty)

- Check terminal-type string and make sure they match

- Save your SSH client configuration

Note: If your problem is only to do with the backspace check the setting under keyboard and try using Backspace key , Control-H.

Setting the Backspace Key on Linux

stty erase ^v<press backspace key right after typing ^v>

(just incase you incorrectly assign the backspace key)


    0 of 8192 characters used
    Post Comment
    • expectus profile imageAUTHOR


      8 years ago from Land Downunder

      abani, you will need to type vi filename.c to bring up the vi editor

    • profile image


      8 years ago

      its helpful a lot. I am puzzled by my vi editor in ubuntu.

    • profile image


      8 years ago

      I had installed ubuntu 11.04 in compaq presario v3239 tu.In terminal after creating a .c file when I try to do program by pressing insert key or i,but it doesn't show any insert mode.

      please help

      Thank you

    • KMattox profile image


      8 years ago from USA


      Good article on vim. I appreciate you taking the time to write it. It is easy to become confused in the command line environment. I don't use vim much anymore since the gui's have improved so much over the last few years. Vim is one of those programs it is good to fall back on. KUDOS. I voted up and useful.


    • profile image


      8 years ago

      Here is a vim plugin script that I use that caused me some pain when I switched over to using Putty to remotely access development machines. Basically, you can just provide mappings for the character codes that Putty uses to represent the arrow keys.

      $ cat ~/.vim/plugin/window_resize.vim

      " Window resizing mappings /*{{{*/

      " Putty shift-arrow key mappings

      nnoremap [A :normal =Resize('+')

      nnoremap [B :normal =Resize('-')

      nnoremap [C :normal =Resize('')

      " Local shift-arrow key mappings

      nnoremap :normal =Resize('+')

      nnoremap :normal =Resize('-')

      nnoremap :normal =Resize('')

      function! Resize(dir)

      echo "Resize called!!!!"

      let this = winnr()

      if '+' == a:dir || '-' == a:dir

      execute "normal k"

      let up = winnr()

      if up != this

      execute "normal j"

      let x = 'bottom'


      let x = 'top'


      elseif '>' == a:dir || '' == a:dir && 'left' == x) || ('

    • htodd profile image


      8 years ago from United States

      Thanks for the great post..Nice

    • profile image


      9 years ago

      greate imfo

    • expectus profile imageAUTHOR


      10 years ago from Land Downunder

      yea that's true, I wrote this hub because I had so many problems using the vi editor it was driving me crazy:P

    • Portamenteff profile image


      10 years ago from Western Colorado, USA

      Actually in most modern Linux systems, the command "vi" is an alias to vim. It is a necessary tool for the server admin or tech.

      Great hub!


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
    ClickscoThis is a data management platform studying reader behavior (Privacy Policy)